fix(sampling): preserve remainder samples across shards - #9859
Open
RerankerGuo wants to merge 1 commit into
Open
fix(sampling): preserve remainder samples across shards#9859RerankerGuo wants to merge 1 commit into
RerankerGuo wants to merge 1 commit into
Conversation
Distribute dataset remainders across data_range shards so parallel sampling covers every input exactly once, including datasets smaller than the shard count. Test: .venv/bin/python tests/run.py --test_dir tests/sample --pattern test_sampling.py
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.
PR type
PR information
SwiftSampling._get_datasetcalculated one fixed shard size with integerdivision. When the dataset size was not divisible by the number of
data_rangeshards, every shard used that truncated size and the remaindersamples were never processed.
For example, 10 samples split across 3 processes produced shard sizes
[3, 3, 3], silently dropping sample 9.This PR distributes the remainder across the first shards. The resulting
shards remain contiguous and ordered, differ in size by at most one, and cover
each input exactly once. Datasets smaller than the shard count are also
handled, with empty shards only after all samples have been assigned.
The change is limited to dataset partitioning for
data_range; sampling,resume, and output behavior are unchanged.
Experiment results
Before the fix:
After the fix: