Repository navigation
fix(data): shuffle direct HF SFT with cyclic sampler - #5048
Merged
Merged
Conversation
Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>
Contributor
|
Light review - LGTM Deterministic shuffling for Direct-HF SFT splits with a clean opt-out and no source mutation. Logic is correct: list(examples) copies before shuffling so the loaded source is preserved, and random.Random(seed) keeps it deterministic and isolated from global RNG. Tests cover default-shuffle-without-mutation, the shuffle=False opt-out, and round-trip serialization of the two new config fields. Minor observations (non-blocking):
Suggested test cases
|
Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>
@yaoyu-33, there was an error processing your request: See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/2/ |
Contributor
Author
|
/ok to test 071fc4a |
going-song
added a commit
to going-song/Megatron-Bridge
that referenced
this pull request
Aug 12, 2026
By default every MegatronMIMO data-loading rank reads the full global micro-batch and forward_step slices out its module-DP shard, so per-rank read and preprocessing cost scales with the DP degree. This adds an opt-in dataset switch, `megatron_mimo_scalable_dp`, that shards reads at the sampler instead and skips the forward-step slice. Reads are sharded on a canonical grid: the LCM of the module DP sizes. Each rank covers `grid // dp` consecutive canonical groups and concatenates one flat Megatron sampler per group, all built with the same `(micro_batch // grid, grid)` geometry and the global consumed_samples. Group streams depend only on module-independent inputs, so every module materializes the identical ordered global micro-batch under both "single" and the default "cyclic" sampler, keeping the BridgeCommunicator's positional batch-dim routing aligned. (Sharding by each module's own DP - the original mechanism - only aligns under "single"; "cyclic" became the direct-HF-SFT default in NVIDIA-NeMo#5048.) Group geometries are truncated to whole global micro-batches so ragged dataset sizes cannot desynchronize the groups' window counts. Split (2/3) of NVIDIA-NeMo#4608 as agreed in NVIDIA-NeMo#4609. Original work by Chanwoo Park. Validated: unit tests for cross-geometry alignment, resume across epoch boundaries, and non-multiple dataset sizes; live PP=2 runs (language tp1/pp2/dp2 + images dp1): cyclic+scalable completes where module-DP sharding crashed on embedding-count mismatch, single scalable matches non-scalable losses within bf16 noise, and the default path reproduces prior losses exactly. Signed-off-by: kayeon.song <kayeon.song@navercorp.com> Signed-off-by: Yoonsik Kim <yoonsik.kim90@navercorp.com> Signed-off-by: Chanwoo Park <chanwoo.park98@navercorp.com> Co-authored-by: Yoonsik Kim <yoonsik.kim90@navercorp.com> Co-authored-by: Chanwoo Park <chanwoo.park98@navercorp.com>
going-song
added a commit
to going-song/Megatron-Bridge
that referenced
this pull request
Aug 12, 2026
By default every MegatronMIMO data-loading rank reads the full global micro-batch and forward_step slices out its module-DP shard, so per-rank read and preprocessing cost scales with the DP degree. This adds an opt-in dataset switch, `megatron_mimo_scalable_dp`, that shards reads at the sampler instead and skips the forward-step slice. Reads are sharded on a canonical grid: the LCM of the module DP sizes. Each rank covers `grid // dp` consecutive canonical groups and concatenates one flat Megatron sampler per group, all built with the same `(micro_batch // grid, grid)` geometry and the global consumed_samples. Group streams depend only on module-independent inputs, so every module materializes the identical ordered global micro-batch under both "single" and the default "cyclic" sampler, keeping the BridgeCommunicator's positional batch-dim routing aligned. (Sharding by each module's own DP - the original mechanism - only aligns under "single"; "cyclic" became the direct-HF-SFT default in NVIDIA-NeMo#5048.) Group geometries are truncated to whole global micro-batches so ragged dataset sizes cannot desynchronize the groups' window counts. Split (2/3) of NVIDIA-NeMo#4608 as agreed in NVIDIA-NeMo#4609. Original work by Chanwoo Park. Validated: unit tests for cross-geometry alignment, resume across epoch boundaries, and non-multiple dataset sizes; live PP=2 runs (language tp1/pp2/dp2 + images dp1): cyclic+scalable completes where module-DP sharding crashed on embedding-count mismatch, single scalable matches non-scalable losses within bf16 noise, and the default path matches prior losses within run-to-run noise. Signed-off-by: kayeon.song <kayeon.song@navercorp.com> Signed-off-by: Yoonsik Kim <yoonsik.kim90@navercorp.com> Signed-off-by: Chanwoo Park <chanwoo.park98@navercorp.com> Co-authored-by: Yoonsik Kim <yoonsik.kim90@navercorp.com> Co-authored-by: Chanwoo Park <chanwoo.park98@navercorp.com>
going-song
added a commit
to going-song/Megatron-Bridge
that referenced
this pull request
Aug 12, 2026
By default every MegatronMIMO data-loading rank reads the full global micro-batch and forward_step slices out its module-DP shard, so per-rank read and preprocessing cost scales with the DP degree. This adds an opt-in dataset switch, `megatron_mimo_scalable_dp`, that shards reads at the sampler instead and skips the forward-step slice. Reads are sharded on a canonical grid: the LCM of the module DP sizes. Each rank covers `grid // dp` consecutive canonical groups and concatenates one flat Megatron sampler per group, all built with the same `(micro_batch // grid, grid)` geometry and the global consumed_samples. Group streams depend only on module-independent inputs, so every module materializes the identical ordered global micro-batch under both "single" and the default "cyclic" sampler, keeping the BridgeCommunicator's positional batch-dim routing aligned. (Sharding by each module's own DP - the original mechanism - only aligns under "single"; "cyclic" became the direct-HF-SFT default in NVIDIA-NeMo#5048.) Group geometries are truncated to whole global micro-batches so ragged dataset sizes cannot desynchronize the groups' window counts. Split (2/3) of NVIDIA-NeMo#4608 as agreed in NVIDIA-NeMo#4609. Original work by Chanwoo Park. Validated: unit tests for cross-geometry alignment, resume across epoch boundaries, and non-multiple dataset sizes; live PP=2 runs (language tp1/pp2/dp2 + images dp1): cyclic+scalable completes where module-DP sharding crashed on embedding-count mismatch, single scalable matches non-scalable losses within bf16 noise, and the default path matches prior losses within run-to-run noise. Signed-off-by: kayeon.song <kayeon.song@navercorp.com> Signed-off-by: Yoonsik Kim <yoonsik.kim90@navercorp.com> Signed-off-by: Chanwoo Park <chanwoo.park98@navercorp.com> Co-authored-by: Yoonsik Kim <yoonsik.kim90@navercorp.com> Co-authored-by: Chanwoo Park <chanwoo.park98@navercorp.com>
going-song
added a commit
to going-song/Megatron-Bridge
that referenced
this pull request
Aug 18, 2026
By default every MegatronMIMO data-loading rank reads the full global micro-batch and forward_step slices out its module-DP shard, so per-rank read and preprocessing cost scales with the DP degree. This adds an opt-in dataset switch, `megatron_mimo_scalable_dp`, that shards reads at the sampler instead and skips the forward-step slice. Reads are sharded on a canonical grid: the LCM of the module DP sizes. Each rank covers `grid // dp` consecutive canonical groups and concatenates one flat Megatron sampler per group, all built with the same `(micro_batch // grid, grid)` geometry and the global consumed_samples. Group streams depend only on module-independent inputs, so every module materializes the identical ordered global micro-batch under both "single" and the default "cyclic" sampler, keeping the BridgeCommunicator's positional batch-dim routing aligned. (Sharding by each module's own DP - the original mechanism - only aligns under "single"; "cyclic" became the direct-HF-SFT default in NVIDIA-NeMo#5048.) Group geometries are truncated to whole global micro-batches so ragged dataset sizes cannot desynchronize the groups' window counts. Split (2/3) of NVIDIA-NeMo#4608 as agreed in NVIDIA-NeMo#4609. Original work by Chanwoo Park. Validated: unit tests for cross-geometry alignment, resume across epoch boundaries, and non-multiple dataset sizes; live PP=2 runs (language tp1/pp2/dp2 + images dp1): cyclic+scalable completes where module-DP sharding crashed on embedding-count mismatch, single scalable matches non-scalable losses within bf16 noise, and the default path matches prior losses within run-to-run noise. Signed-off-by: kayeon.song <kayeon.song@navercorp.com> Signed-off-by: Yoonsik Kim <yoonsik.kim90@navercorp.com> Signed-off-by: Chanwoo Park <chanwoo.park98@navercorp.com> Co-authored-by: Yoonsik Kim <yoonsik.kim90@navercorp.com> Co-authored-by: Chanwoo Park <chanwoo.park98@navercorp.com>
going-song
added a commit
to going-song/Megatron-Bridge
that referenced
this pull request
Aug 27, 2026
By default every MegatronMIMO data-loading rank reads the full global micro-batch and forward_step slices out its module-DP shard, so per-rank read and preprocessing cost scales with the DP degree. This adds an opt-in dataset switch, `megatron_mimo_scalable_dp`, that shards reads at the sampler instead and skips the forward-step slice. Reads are sharded on a canonical grid: the LCM of the module DP sizes. Each rank covers `grid // dp` consecutive canonical groups and concatenates one flat Megatron sampler per group, all built with the same `(micro_batch // grid, grid)` geometry and the global consumed_samples. Group streams depend only on module-independent inputs, so every module materializes the identical ordered global micro-batch under both "single" and the default "cyclic" sampler, keeping the BridgeCommunicator's positional batch-dim routing aligned. (Sharding by each module's own DP - the original mechanism - only aligns under "single"; "cyclic" became the direct-HF-SFT default in NVIDIA-NeMo#5048.) Group geometries are truncated to whole global micro-batches so ragged dataset sizes cannot desynchronize the groups' window counts. Split (2/3) of NVIDIA-NeMo#4608 as agreed in NVIDIA-NeMo#4609. Original work by Chanwoo Park. Validated: unit tests for cross-geometry alignment, resume across epoch boundaries, and non-multiple dataset sizes; live PP=2 runs (language tp1/pp2/dp2 + images dp1): cyclic+scalable completes where module-DP sharding crashed on embedding-count mismatch, single scalable matches non-scalable losses within bf16 noise, and the default path matches prior losses within run-to-run noise. Signed-off-by: kayeon.song <kayeon.song@navercorp.com> Signed-off-by: Yoonsik Kim <yoonsik.kim90@navercorp.com> Signed-off-by: Chanwoo Park <chanwoo.park98@navercorp.com> Co-authored-by: Yoonsik Kim <yoonsik.kim90@navercorp.com> Co-authored-by: Chanwoo Park <45866990+sailor1493@users.noreply.github.com>
This branch was previously 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?
Use the standard Megatron
cyclicdataloader for Direct-HF SFT shuffling instead of mutating loaded examples inside the dataset builder.Direct-HF SFT configs now default to
dataloader_type="cyclic". The in-tree VLM/audio SFT and PEFT recipes that previously pinned the sequentialsinglesampler now explicitly selectcyclic, and the MegatronMIMO Qwen3.5-VL example uses the same CLI default.Why
cyclicinstead ofbatch?cyclicselectsMegatronPretrainingRandomSampler, which provides deterministic epoch shuffling and resume-aware sample ordering while keeping DataLoader collation at microbatch granularity. That preserves the existing VLM in-batch packing behavior.The
batchsampler collates a rank-local global batch before the finetuning step splits it into microbatches. For Direct-HF VLM recipes this can change the packing scope and can be incompatible with collators that pack the input down to a batch dimension of one.Changelog
DirectHFSFTDatasetConfig.dataloader_typetocyclic.cyclicin Direct-HF SFT/PEFT recipes for common VLM, Nemotron Omni, Qwen2-Audio, and Qwen3-Omni.cyclic.Users can still request source-order sampling explicitly with
dataloader_type="single".Validation
uv run --isolated --no-project --with pre-commit==4.6.0 pre-commit run --all-files— passed.uv run --isolated --no-project python -m compileall -q <changed Python files>— passed.git diff --check— passed.uv runis blocked before pytest by the Linux-onlynvidia-resiliency-extwheel; the current Megatron-Core import also requires Triton.Before your PR is Ready for review