Skip to content

Pass the model's process groups through training, data and checkpoint I/O - #8891

Draft
Connor-XY wants to merge 24 commits into
NVIDIA:mainfrom
Connor-XY:yx/pstate-unit-U8
Draft

Connor-XY wants to merge 24 commits into
NVIDIA:mainfrom
Connor-XY:yx/pstate-unit-U8

Conversation

@Connor-XY

@Connor-XY Connor-XY commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

This PR moves the training loop's I/O onto the model's ProcessGroupCollection. pretrain() builds one collection and passes it to DDP, the schedules, batch loading, the data loaders and checkpoint save and load. The GPT and ModelOpt spec builders take the collection's pipeline rank. A model built on its own grid, such as an RL inference model or a distillation teacher, then loads, builds and checkpoints the right stage on the right ranks. On the standard grid, results are unchanged. It consolidates six draft PRs from #6307 without changes. Each member is one commit, so review commit by commit. It does not depend on any other unit. It lands after the optimizer unit #8889, which also edits training.py and checkpointing.py, and before the FP8/FP4 amax, CUDA graphs and 1F1B unit #8893, which also edits training.py.

Review

The unit's own commits: Connor-XY/Megatron-LM@eb768e2...74906a8

The full PR diff also includes #7487, #6259, #6293, #6257, #6303, the optimizer unit #8889 and the core process-group API unit #8890 until they merge.

Members

Behavior changes for callers

  • --create-all-gather-group now takes effect under pretrain(). All-gather groups whose ranks differ from the data-parallel groups are rejected.
  • wrap_data_iterator raises ValueError where it raised AssertionError, or AttributeError for a None collection.
  • GPT and hybrid get_batch raise ValueError for a collection with cp=None. pretrain() always sets cp.
  • With GTP remat, checkpoint RNG state and legacy writers use the replicate dp and expt_dp, as the training loop already did. With expert GTP remat, the fully parallel expert save and load group becomes expt_dp.
  • fsdp_dtensor loads read each rank's own rng_state.(pp, tp) instead of (0, 0). A strict load into a different TP/PP layout fails on the missing key.
  • Legacy shard names follow the model's collection, not the _MPU_* setters. External converters that emulate stages with those setters must also set their stand-in pipeline group's rank, as tools/checkpoint/loader_base.py now does.
  • With a virtual pipeline and account_for_embedding_in_pipeline_split or account_for_loss_in_pipeline_split, the ModelOpt spec no longer gives the first or last chunk one extra layer.

Teams

core-adlr, core-nemo, training, datasets, post-training. Needs the determinism-exempt label: megatron/training/utils/common_utils.py is a registered kernel file, and only its stage predicate changes.

Testing

Each member was GPU-tested against its base before consolidation. The consolidated chain (every unit in landing order, on current main) was run against main on 4 GPUs: 258 test files, and no test fails on the chain that passes on main. Tests in 28 files fail on both, mostly tests written for 8 GPUs, and one file times out on both.

🤖 Generated with Claude Code

Connor-XY and others added 24 commits November 2, 2026 18:22
Originally NVIDIA#7487.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Yan Xu <yxu1@nvidia.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Yan Xu <yxu1@nvidia.com>
Originally NVIDIA#6259.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Yan Xu <yxu1@nvidia.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Yan Xu <yxu1@nvidia.com>
Originally NVIDIA#6293.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Yan Xu <yxu1@nvidia.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Yan Xu <yxu1@nvidia.com>
…groups

Originally NVIDIA#8042.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Yan Xu <yxu1@nvidia.com>
Originally NVIDIA#8043.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Yan Xu <yxu1@nvidia.com>
Originally NVIDIA#8045.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Yan Xu <yxu1@nvidia.com>
Originally NVIDIA#8731.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Yan Xu <yxu1@nvidia.com>
Originally NVIDIA#6257.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Yan Xu <yxu1@nvidia.com>
Originally NVIDIA#6303.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Yan Xu <yxu1@nvidia.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Yan Xu <yxu1@nvidia.com>
Originally NVIDIA#8026.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Yan Xu <yxu1@nvidia.com>
Originally NVIDIA#8723.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Yan Xu <yxu1@nvidia.com>
Originally NVIDIA#8017.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Yan Xu <yxu1@nvidia.com>
Originally NVIDIA#8039.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Yan Xu <yxu1@nvidia.com>
Originally NVIDIA#8049.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Yan Xu <yxu1@nvidia.com>
Originally NVIDIA#8037.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Yan Xu <yxu1@nvidia.com>
Originally NVIDIA#8048.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Yan Xu <yxu1@nvidia.com>
Originally NVIDIA#8726.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Yan Xu <yxu1@nvidia.com>
Originally NVIDIA#8727.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Yan Xu <yxu1@nvidia.com>
Originally NVIDIA#8740.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Yan Xu <yxu1@nvidia.com>
Originally NVIDIA#8742.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Yan Xu <yxu1@nvidia.com>
@copy-pr-bot

copy-pr-bot Bot commented Nov 3, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant