Actually correct training w/ packed datasets defaults#2610
Draft
joecummings wants to merge 3 commits intopytorch:fix-pos-idfrom
Draft
Actually correct training w/ packed datasets defaults#2610joecummings wants to merge 3 commits intopytorch:fix-pos-idfrom
joecummings wants to merge 3 commits intopytorch:fix-pos-idfrom
Conversation
Add a position buffer that tracks per-document RoPE positions, resetting at each document boundary. These positions are yielded alongside input tokens and used when block_causal attention is configured. Also add is_packed validation to catch misconfigured attention backends at trainer init time: packed dataloaders require flex or varlen with block_causal to prevent cross-document attention leakage.
- Add is_packed attribute on HuggingFaceTextDataset, delegated through the dataloader to the trainer for early validation that packed datasets use flex/varlen + block_causal attention. - Remove the % seq_len clamp on position IDs. Document positions are valid indices into the RoPE cache (sized to max_seq_len), and unclamped positions preserve correct absolute offsets for document fragments spanning chunk boundaries.
…causal With packed datasets, sdpa/causal allows cross-document attention leakage and uses sequential positions across document boundaries. flex/block_causal isolates documents in attention and enables per-document RoPE position IDs. llama4, deepseek_v3, and gpt_oss already used flex/block_causal.
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.
No description provided.