-
Notifications
You must be signed in to change notification settings - Fork 32
Add prepare command #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
7304119
fix GPTMemmapDataset
tscholak 47d453b
fix GPTMemmapDataset
tscholak bef3a72
add prepare-dataset command
tscholak 0ffc75c
add prepare-dataset command
tscholak fda6386
add prepare-dataset command
tscholak acae7d9
add prepare-dataset command
tscholak eb7da59
add prepare-dataset command
tscholak b5ed2f0
add prepare-dataset command
tscholak c8f746a
only push latest tag for commits to main
tscholak e0f813c
use older generics syntax
tscholak b88c9d3
remove user and install Fast-LLM globally
tscholak 4df12d9
simplify Dockerfile
tscholak 3737bc0
improvements
tscholak 4b6b195
add docstring
tscholak 52a6f0b
use full imports
tscholak 55b0b88
use full imports
tscholak 1f975d2
use full imports
tscholak b665e91
don't load tokenizer during validatin
tscholak af1439e
Merge remote-tracking branch 'origin/main' into tscholak/prepare-dataset
tscholak e51677f
simplify
tscholak 1f447bb
simplify
tscholak fb50c13
address comments
tscholak 33067c8
address comments
tscholak dbc221c
address comments
tscholak a2ae051
address comments
tscholak 81162b3
fixes
jlamypoirier a134a52
fix
jlamypoirier fbb011a
No venv
jlamypoirier 4827f49
Faster tests
jlamypoirier f8c328f
use dtype
tscholak ded3027
remove unused venv package
tscholak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,39 @@ | ||
# syntax=docker/dockerfile:1.7-labs | ||
FROM nvcr.io/nvidia/pytorch:24.07-py3 | ||
|
||
# Install git-lfs for Huggingface hub interaction and sudo for system adjustments | ||
# Install dependencies. | ||
RUN apt-get update \ | ||
&& apt-get install --no-install-recommends -y git-lfs sudo util-linux \ | ||
&& apt-get install --no-install-recommends -y acl git-lfs \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& git lfs install | ||
|
||
# Add a user for Fast-LLM with sudo privileges for runtime adjustments | ||
ARG FAST_LLM_USER_ID=1000 | ||
RUN useradd -m -u $FAST_LLM_USER_ID -s /bin/bash fast_llm \ | ||
&& echo 'fast_llm ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers | ||
|
||
USER fast_llm | ||
# Set the working directory. | ||
WORKDIR /app | ||
# Set the permission to 777 for all files and directories in `/app`, `/home` and python install directories: | ||
# 1. Create directories explicitly because docker use the wrong permission for explicit creation. | ||
# 2. For the rest, set the default ACL to 777 for all users. | ||
RUN mkdir -m 777 /app/Megatron-LM /app/examples /app/fast_llm /app/tests /app/tools \ | ||
&& setfacl -m d:u::rwx,d:g::rwx,d:o::rwx,u::rwx,g::rwx,o::rwx \ | ||
/app \ | ||
/home \ | ||
/usr \ | ||
/usr/local \ | ||
/usr/local/bin \ | ||
/usr/local/lib \ | ||
/usr/local/lib/python3.10 \ | ||
/usr/local/lib/python3.10/dist-packages \ | ||
/usr/local/lib/python3.10/dist-packages/__pycache__ | ||
|
||
# Environment settings for Python and PATH | ||
ENV PYTHONPATH=/app:/app/Megatron-LM \ | ||
PATH=$PATH:/home/fast_llm/.local/bin/ | ||
|
||
# Copy the dependency files and install dependencies | ||
COPY --chown=fast_llm setup.py setup.cfg pyproject.toml ./ | ||
COPY --chown=fast_llm ./fast_llm/csrc/ fast_llm/csrc/ | ||
RUN PIP_NO_INPUT=1 pip3 install --no-cache-dir --no-build-isolation -e ".[CORE,OPTIONAL,DEV]" | ||
# Copy dependency files with universal write permissions for all users. | ||
COPY --chmod=777 setup.py setup.cfg pyproject.toml ./ | ||
COPY --chmod=777 ./fast_llm/csrc/ fast_llm/csrc/ | ||
|
||
# Copy the rest of the code | ||
COPY --chown=fast_llm ./Megatron-LM Megatron-LM | ||
COPY --chown=fast_llm ./examples examples | ||
COPY --chown=fast_llm ./tests tests | ||
COPY --chown=fast_llm ./tools tools | ||
# Install dependencies within the virtual environment. | ||
RUN pip install --no-cache-dir --no-build-isolation -e ".[CORE,OPTIONAL,DEV]" | ||
|
||
# Copy the main source code for Fast-LLM | ||
COPY --exclude=./fast_llm/csrc/ --chown=fast_llm ./fast_llm/ fast_llm/ | ||
# Copy the remaining source code with universal write permissions. | ||
COPY --chmod=777 ./Megatron-LM Megatron-LM | ||
COPY --chmod=777 ./examples examples | ||
COPY --chmod=777 ./tests tests | ||
COPY --chmod=777 ./tools tools | ||
COPY --chmod=777 --exclude=./fast_llm/csrc/ ./fast_llm/ fast_llm/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from fast_llm.data.preparator.gpt_memmap.config import GPTMemmapDatasetPreparatorConfig | ||
from fast_llm.utils import Registry | ||
|
||
dataset_preparator_registry = Registry( | ||
"DatasetPreparator", | ||
{ | ||
dataset_preparator.preparator_name: dataset_preparator | ||
for dataset_preparator in [ | ||
GPTMemmapDatasetPreparatorConfig, | ||
] | ||
}, | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import abc | ||
import argparse | ||
import typing | ||
|
||
from fast_llm.config import config_class | ||
from fast_llm.engine.config_utils.runnable import RunnableConfig | ||
from fast_llm.utils import Assert | ||
|
||
|
||
@config_class() | ||
class DatasetPreparatorConfig(RunnableConfig): | ||
preparator_name: typing.ClassVar[str] | ||
|
||
@classmethod | ||
def get_dataset_preparator_class(cls) -> type["DatasetPreparator"]: | ||
raise NotImplementedError | ||
|
||
def _get_runnable(self, parsed: argparse.Namespace) -> typing.Callable[[], None]: | ||
dataset_preparator = self.get_dataset_preparator_class()(config=self) | ||
return dataset_preparator.run | ||
|
||
|
||
class DatasetPreparator(abc.ABC): | ||
_config: DatasetPreparatorConfig | ||
config_class: typing.ClassVar[type[DatasetPreparatorConfig]] = DatasetPreparatorConfig | ||
|
||
def __init__(self, config: DatasetPreparatorConfig) -> None: | ||
Assert.custom(isinstance, config, self.config_class) | ||
config.validate() | ||
self._config = config | ||
|
||
@abc.abstractmethod | ||
def run(self) -> None: | ||
raise NotImplementedError |
Empty file.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.