-
Notifications
You must be signed in to change notification settings - Fork 205
Megatron tokenization pipeline #1259
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
Conversation
Signed-off-by: asolergi-nv <asolergibert@nvidia.com>
Signed-off-by: asolergi-nv <asolergibert@nvidia.com>
Signed-off-by: asolergi-nv <asolergibert@nvidia.com>
Signed-off-by: asolergi-nv <asolergibert@nvidia.com>
Signed-off-by: asolergi-nv <asolergibert@nvidia.com>
Signed-off-by: asolergi-nv <asolergibert@nvidia.com>
Signed-off-by: asolergi-nv <asolergibert@nvidia.com>
Signed-off-by: asolergi-nv <asolergibert@nvidia.com>
Signed-off-by: asolergi-nv <asolergibert@nvidia.com>
Signed-off-by: asolergi-nv <asolergibert@nvidia.com>
Signed-off-by: asolergi-nv <asolergibert@nvidia.com>
Signed-off-by: asolergi-nv <asolergibert@nvidia.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional Comments (2)
-
nemo_curator/stages/text/io/writer/megatron_tokenizer.py, line 133 (link)logic: If
write_idx_data()fails, the.binfile remains on disk without its.idxmetadata file. Consider wrapping both file writes in a single try-except or moving idx write into the existing try block to clean up both files on failure -
nemo_curator/stages/text/io/writer/utils.py, line 23 (link)syntax: Docstring says "Batch an iterable into lists" but the function returns tuples. Update docstring to say "tuples" instead of "lists"
9 files reviewed, 2 comments
Description
In this PR I’m including the
MegatronTokenizerWriter, which tokenizes and produces the.binand.idxfiles required for training with Megatron and its dataloading solution..binfile contains the tokenized documents. We will use 4 bytes per token if the vocabulary size is greater than2**16; otherwise, we’ll use 2 bytes per token..idxfile contains metadata about the.binfile, mainly the number of tokenized documents and their lengths. More details about this can be found in theclosemethod ofMegatronTokenizerWriter.At first, I tried creating a
CompositeStageusingTokenizerStage, but as we already discussed,TokenizerStagecaused OOM issues. To address this, I added abatch_sizeargument that controls how many documents we tokenize at once, write to disk, and then immediately discard.I’ve also included the
tokenizer-testfolder, which contains thetest.shscript I used to verify that the produced files match those created by Megatron’spreprocess_data.pyscript. To run the checks, you only need to set theDATA_ROOTfolder in the script and execute it; it will clone Megatron, start the Ray server, download and convert the TinyStories dataset to JSONL, tokenize the dataset with 8 different configurations, and finally confirm that the files generated by Curator and the Megatron script match.We perform this validation using 4 different tokenizers, including in the dataset one sample with all tokenizer-specific special tokens, and toggling the
append_eodconfig (also present in the Megatron script). Of these 4 tokenizers, GPT-2 uses 2 bytes per token since its vocabulary size is≤ 2**16.I’m now writing some unit tests, similar to the ones in
tests/stages/text/io/writer/test_jsonl.py. I’d like to know whether…MegatronTokenizerWriterintutorials/text/tinystories/main.py— what do you think?Let me know your thoughts!
Usage
Checklist