Repository navigation
fix(python): isolate filtered batch sampler shuffle state - #11721
Open
zhangyue19921010 wants to merge 1 commit into
Open
zhangyue19921010 wants to merge 1 commit into
zhangyue19921010 wants to merge 1 commit into
Conversation
Problem Filtered batch iterators draw shuffle priorities from Python's global generator between yields. Interleaving iterators with the same seed and epoch changes their order. Solution Give each randomized filtered traversal its own generator initialized with the sampler's seed and epoch. Result Interleaved iterators reproduce the uninterrupted order on each rank. The filtered shuffle leaves the caller's random state intact.
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.
Problem
Two filtered
ShardedBatchSampleriterators with the same seed and epoch can yield different orders when consumed together. Each draw for the next shuffle priority uses Python's global random generator.Solution
Initialize a generator inside each randomized filtered traversal and use it for the shuffle priorities.
Result
On a two-fragment dataset, interleaved scans reproduce the uninterrupted order on both ranks. Caller-side random draws also leave that order intact, and the filtered shuffle preserves the caller's random state.
Python lint and all 125 CPU sampler and persistent-worker cases passed. The CUDA-marked
test_pytorch_integrationfails on both main and this branch because it passes the unsupportedtotal_num_rowsargument toShardedBatchSampler.Fixes #11720