[feat][SFT] Union sampling for multi-dataset runs without explicit weights - #1990
Draft
avigyabb wants to merge 1 commit into
Draft
[feat][SFT] Union sampling for multi-dataset runs without explicit weights#1990avigyabb wants to merge 1 commit into
avigyabb wants to merge 1 commit into
Conversation
…ights Multiple train datasets with no train_dataset_weights previously defaulted to equal-weight mixing via DataMixingSampler: 1/N per source, sampled with replacement. Two consequences surprised users expecting 'train on the union of my datasets': a small source mixed with a large one was heavily oversampled by default, and an 'epoch' was len(union) weighted draws rather than a pass -- some rows repeated, others never seen. Unset weights now select union sampling: config normalization preserves None instead of filling 1/N, and build_train_sampler returns None (the dataloader's built-in shuffle), i.e. one permutation of the concatenated datasets per epoch, without replacement. Every sample of every dataset is seen exactly once per epoch and each dataset's share follows its size. Explicit weights select weighted mixing exactly as before (with replacement -- the only way per-batch ratios can hold independent of dataset sizes). Behavior change: runs that relied on the implicit equal-weight default should set train_dataset_weights explicitly (e.g. [0.5, 0.5]). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Avi Basnet <avigyabb@stanford.edu>
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
Multiple
train_datasets(orpretokenized_dataset_paths) with notrain_dataset_weightsnow sample as the union of the datasets: one shuffle over the concatenation per epoch, without replacement -- every sample of every dataset is seen exactly once per epoch, and each dataset's share of the batches follows its size.Explicit weights behave exactly as before: weighted per-source mixing via
DataMixingSampler, with replacement (the only way per-batch ratios can hold independent of dataset sizes).Why
Previously, unset weights were silently defaulted to equal mixing (
1/Nper source, with replacement). Two consequences surprised users who mentally modeled "I gave it two datasets, it trains on their union":num_epochs=1waslen(union)weighted draws, not a pass: some rows repeated, others were never seen (~37% missed even in the equal-size case), so "1 epoch" did not mean "saw everything once".With this change the two sampling semantics map onto explicit user intent:
len(union)weighted drawsHow
Small diff -- the machinery already existed:
_normalize_mixing_weightsno longer fills[1/N] * N; unset weights stayNoneas the union-sampling signal (explicit weights are validated as before).build_train_samplerreturnsNone(the dataloader's built-in statefulshuffle=True-- arandpermover theConcatSFTDataset) forsampler="random"unless weights are set. Checkpoint/resume is unchanged: the built-in shuffle path is the same one single-dataset runs already use.multi_dataset.mdx,overview.mdx, README) updated to describe both modes and the replacement semantics of each.Multi-dataset runs that relied on the implicit equal-weight default will now train on the union instead of a 1/N mix. To keep the old behavior, set the weights explicitly, e.g.
train_dataset_weights="[0.5,0.5]".Tests
None(no defaulted mixing); explicit-weights validation unchanged.None(union); multi + weights ->DataMixingSampler.tests/trainsuite green: 893 passed.🤖 Generated with Claude Code