Repository navigation
Add pre-tokenized SFT input with assistant loss mask to the varlen path - #8468
Draft
VikingDeng wants to merge 3 commits into
Draft
VikingDeng wants to merge 3 commits into
VikingDeng wants to merge 3 commits into
Conversation
First step of the SFTDataset item in NVIDIA#5676. --varlen-pretokenized-dataset makes VarlenDataset read tokens and an assistant-only loss mask from two IndexedDataset streams (<prefix> and <prefix>.mask) instead of tokenizing at load time. tools/preprocess_varlen_sft.py writes both from SFTTokenizer targets and rejects prompt formats without assistant-only targets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: viking <emmmvkdeng@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: viking <emmmvkdeng@gmail.com>
main renamed hybrid_context_parallel to dynamic_context_parallel (NVIDIA#7047), and SFTDataset now reads the new name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: viking <emmmvkdeng@gmail.com>
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR do ?
First step for the SFTDataset item in #5676. With
--varlen-pretokenized-dataset,VarlenDatasetreads tokens and an assistant-only loss mask from two IndexedDataset streams (<prefix>and<prefix>.mask) instead of tokenizing at load time, so it works with the existing blend/split and DP-balanced scheduler code.tools/preprocess_varlen_sft.pywrites both streams fromSFTTokenizertargets and refuses prompt formats whose targets are all ones (likedefault), since those would silently train on the whole conversation.Not in this PR: MFFD packing and thinking/tool masks from #5017. I kept this to the data format and reader so it's easy to review; happy to adjust the scope if you had something else in mind.
Tests (CPU, Linux):
End to end, I preprocessed 5 hand-written multi-turn conversations with the Qwen2.5-0.5B tokenizer and read them back through
VarlenDataset; the masked positions decode to exactly the assistant replies. One existing limitation:SFTTokenizer'sidentityformat hits a BPE assertion across turns with the Qwen tokenizer, so that check used thenemotron-h-alignedformat.AI assistance: I used Claude Code to help write the code and tests. I chose the design, ran the validation above on my own machines and checked the results before opening this PR, and I'll handle the review.
🤖 Generated with Claude Code