-
Notifications
You must be signed in to change notification settings - Fork 193
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
base: main
Are you sure you want to change the base?
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.
9 files reviewed, no comments
ayushdg
left a comment
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.
Minor comment about cloud testing but overall looks great! Thanks a lot @asolergi-nv
| help="Path to folder containing Parquet files", | ||
| ) | ||
| group.add_argument( | ||
| "--output-path", |
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.
Is it possible to test if this works when output_path is a cloud path like s3? Things should work but we've been bitten by not testing cloud IO better for other tutorials in the past and are in the process of updating it for this release.
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