Repository navigation
Conversation
|
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 was referenced Oct 30, 2026
save_checkpoint and load_checkpoint read the global parallel grid for every group they did not receive: the shard name of a legacy checkpoint (tensor, pipeline and expert ranks), the writers of a legacy checkpoint (data-parallel and expert data-parallel ranks), the RNG shard key and gather, the replica ids of the sharded state, the fully parallel save and load groups, the local checkpoint group, the layer-wise optimizer file index and the log lines. A model built on its own grid was saved under the ranks of the global grid, and the fsdp_dtensor optimizer metadata replaced the caller's data-parallel group with the global one. Both functions take a pg_collection keyword argument. It defaults to the collection the model was built on, and to the global grid only for a model built without one. The explicit group arguments keep overriding the matching group. The RNG state and the checkpoint writers use the replicate groups (dp, expt_dp), the replica ids the GTP-remat-inclusive dp_cp_gtp_remat, and the dataloader state dp_gtp_remat, as the training loop already passes them; a collection without the GTP-remat fields falls back to the plain groups. get_checkpoint_name takes the collection for the ranks it is not given, and the rank-0 read of a local checkpoint no longer looks up a group it does not use. On the standard grid every group is the one the global accessors return, so checkpoint names, writers and contents are unchanged. With GTP remat, callers that pass no groups now use the same replicate groups for RNG state and writers as the training loop. The checkpoint converter names the shard of each pipeline stage by the rank of the model's stand-in pipeline group, so its loader sets that rank alongside the tensor-parallel one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Yan Xu <yxu1@nvidia.com>
The training loop copied seven groups out of the model's collection into save_checkpoint and five into load_checkpoint, with getattr fallbacks to the global grid for each of them. Pass the collection itself; checkpointing selects the same groups from it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Yan Xu <yxu1@nvidia.com>
Connor-XY
force-pushed
the
yx/pstate-t1-training-checkpointing
branch
from
November 1, 2026 01:37
eb66937 to
5e885d9
Compare
Connor-XY
added a commit
to Connor-XY/Megatron-LM
that referenced
this pull request
Nov 1, 2026
The checkpoint helpers' fallback warnings that follow cover the save and load paths that NVIDIA#8740 moves onto the model's process groups, and their tests extend NVIDIA#8740's checkpointing collection test. The merge is clean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Yan Xu <yxu1@nvidia.com>
Connor-XY
added a commit
to Connor-XY/Megatron-LM
that referenced
this pull request
Nov 1, 2026
load_checkpoint() and save_checkpoint() take the model's process-group collection, and get_checkpoint_name() takes it to name the shard of a stage. The checkpoint converter changes that follow load and save on the converter's registered groups through those arguments. The merge is clean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Yan Xu <yxu1@nvidia.com>
Connor-XY
added a commit
to Connor-XY/Megatron-LM
that referenced
this pull request
Nov 1, 2026
The checkpoint tools changes that follow edit the converter code that NVIDIA#8744 adds: the loader's own collection, its stand-in pipeline rank setter, build_checkpoint_converter_process_groups and the converter tests. NVIDIA#8744 also brings NVIDIA#8033's initialize_checkpoint_converter_distributed and pipeline-stage test, and NVIDIA#6303. tools/checkpoint/loader_base.py conflicts in the per-stage load loop. Keep NVIDIA#8744's set_checkpoint_converter_pipeline_rank() call and its get_models_for_pipeline_stage(pp_rank, ...) signature, which already set the stand-in group's rank that NVIDIA#8740's side sets by hand. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Yan Xu <yxu1@nvidia.com>
Conflicts: - megatron/training/checkpointing.py: Main (NVIDIA#8213) moves the layer-wise distributed optimizer check in save_checkpoint to cfg.optimizer. The PR names the layer-wise optimizer file by the rank in the dp_gtp_remat group instead of the global data-parallel rank. The result keeps main's cfg.optimizer condition and the PR's group-based file index. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Yan Xu <yxu1@nvidia.com>
Contributor
Author
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.
Why.
save_checkpointandload_checkpointread the global parallel grid for every group they were not given:A model built on its own grid was checkpointed under the global ranks. The training loop copied seven groups out of the model's collection into
save_checkpointand five intoload_checkpoint, and any group it did not find fell back to the global grid.What.
save_checkpointandload_checkpointtakepg_collection, defaulting to the model's own collection. Only a model built without one uses the global grid.dpandexpt_dpfor RNG state and writers,dp_cp_gtp_rematfor replica ids,dp_gtp_rematfor dataloader state. A collection without the GTP-remat fields falls back to the plain groups.get_checkpoint_namereads the ranks it is not given from the collection.Tests. New
tests/unit_tests/training/test_checkpointing_pg_collection.py: legacy and torch_dist round trips on a TP2×PP2 collection over a TP1×PP1 global grid, with checkpointing's global accessors replaced by a stand-in that fails on any read, plus CPU tests for shard naming and collection resolution.On 4 GPUs against main:
test_checkpointing_pg_collection.pypasses all 5 of its tests, which are new, including the 3 round trips.test_checkpointing.py: 102 passed here vs 102 on main.dist_checkpointing/test_layer_wise_optimizer.py: 75 passed here vs 75 on main, with 31 skipped on both sides; 44 of its tests fail on both sides because they need 8 ranks. No test regresses. Before the sync with main, on 4 CPU gloo ranks, the 2 CPU tests pass and the 3 round trips need CUDA. In the integration run (main with all #6307 PRs merged), this PR's test files show no regressions against main, and the 44 layer-wise optimizer tests pass on 8 GPUs (two nodes). That run covers the full unit test suite;test_checkpointing.py,test_attention.py,test_multi_token_prediction.py,test_moe_single_grouped_weight_numerics.py,test_training.py,tests/unit_tests/tools/checkpoint/and the Megatron-FSDP v1 fused-MLA checkpoint test show no regressions there. End-to-end training smokes on that tree, including train-and-resume runs, give bit-identical losses to main, and resumed runs match their uninterrupted runs. The converter loader change has no unit test in this PR. Theckpt_converterfunctional test exercises it, but its recipe sits in themr-brokenscope.Compatibility. Only new keyword arguments. On the standard grid the groups, names and contents are unchanged. For callers that pass no groups:
dpandexpt_dp, like the training loop, instead of the GTP-inclusive defaults. With expert GTP remat, the fully parallelep_dpsave and load group moves from the GTP-inclusive expert-DP group toexpt_dp.rng_state.(pp, tp)instead of(0, 0), so each rank restores its own RNG state. A strict load into a different TP/PP layout fails on the missing key._MPU_*setters. An external converter that emulates stages with those setters must also set its stand-in pipeline group's rank, astools/checkpoint/loader_base.pydoes here. Otherwise it reads stage 0's shard for every stage.MultiModuleProcessGroupCollectionraisesValueError.Not covered here:
get_ep_layer_offset; Name FSDP-DTensor experts by the model's expert-parallel layout #8045 fixes that.get_checkpoint_name,get_rng_state,_build_sharded_state_dict_metadata,maybe_save_dataloader_state, ...) still fall back to the global grid silently for callers without a collection and for hand-built collections that lack a field. Warn when training checkpoint helpers fall back to the global grid #8758 adds warnings to them.Landing: #8033 adds the same
set_rankcall in the converter loader's per-stage loop, on the other side ofset_pipeline_model_parallel_rank. Git merges both without a conflict, so whichever PR lands second drops one copy. #8744 rewrites that loop and conflicts with this PR intools/checkpoint/loader_base.py. Whichever lands second takes that PR's loop. #8037 merges cleanly with this PR.Synced with main 77391e7 on 2026-11-01 by a merge commit that lists each conflict and its resolution, so existing commits and review links stay valid.
Part of #6307.
🤖 Generated with Claude Code