M4 + Dist Checkpoint: Replace global parallel state with explicit group parameters - #2053
Merged
Conversation
…for_checkpoint` for m4 entrypoint
# Conflicts: # megatron/training/checkpointing.py
# Conflicts: # megatron/core/transformer/moe/experts.py
Contributor
Author
|
/ok to test 8344474 |
yaoyu-33
approved these changes
Nov 25, 2025
Contributor
|
/ok to test 272f126 |
deepakn94
approved these changes
Dec 6, 2025
Contributor
Author
|
/ok to tests c60d4ca |
JRD971000
approved these changes
Dec 9, 2025
JRD971000
left a comment
Contributor
There was a problem hiding this comment.
Reviewed the Mamba parts and LGTM, thanks!
Contributor
Author
|
/ok to test c60d4ca |
Signed-off-by: dimapihtar <dpihtar@gmail.com>
kvareddy
approved these changes
Dec 9, 2025
Contributor
Author
|
/ok to test 467bcb2 |
Signed-off-by: dimapihtar <dpihtar@gmail.com>
Contributor
Author
|
/ok to test ee1d6b5 |
Signed-off-by: dimapihtar <dpihtar@gmail.com>
Contributor
Author
|
/ok to test 49df433 |
Signed-off-by: dimapihtar <dpihtar@gmail.com>
Contributor
Author
|
/ok to test defaf33 |
Signed-off-by: dimapihtar <dpihtar@gmail.com>
Contributor
Author
|
/ok to test d37fdfb |
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 ?
This PR refactors the parallel group management to eliminate dependencies on global parallel_state.xxx APIs and instead use explicit group parameters (tp_group, pp_group, dp_cp_group) with fallbacks to existing global state when not provided.
Key Changes
1. Explicit Group Parameters
tp_group,pp_group,dp_cp_groupparameters to key functions in:megatron/training/checkpointing.pymegatron/training/utils.pymegatron/core/utils.pyOptional[torch.distributed.ProcessGroup]parameters withNonedefaultsNone, code falls back to existingmpu.get_xxx_group()APIs for backward compatibility2. Enhanced Metadata Handling
_build_sharded_state_dict_metadata()to includedp_cp_groupin metadatadp_cp_groupnow consistently sourced from metadata across checkpoint operations3. Improved Group Sourcing Strategy
module.tp_groupandmodule.pp_groupget_pg_size()andget_pg_rank()utilities for group introspection4. Function Signature Updates
Key functions updated with explicit group parameters:
save_checkpoint()load_checkpoint()get_rng_state()_build_sharded_state_dict_metadata()Contribution process
flowchart LR A[Pre-checks] --> B[PR Tests] subgraph Code Review/Approval C1[Expert Review] --> C2[Final Review] end B --> C1 C2 --> D[Merge]Pre-checks
Core 0.8)Code review
The following process is enforced via the CODEOWNERS file for changes into
megatron/core. For changes outside ofmegatron/core, it is up to the PR author whether or not to tag the Final Reviewer team.For MRs into `main` branch
(Step 1): Add PR label
Expert Review(Step 2): Collect the expert reviewers reviews
Expert Reviewlabel when your PR is ready for review.Final Review might get declined if these requirements are not fulfilled.
(Step 3): Final Review
Final Reviewlabel(Optional Step 4): Cherry-pick into release branch
If this PR also needs to be merged into
core_r*release branches, after this PR has been merged, selectCherry-pickto open a new PR into the release branch.For MRs into `dev` branch
The proposed review process for `dev` branch is under active discussion.MRs are mergable after one approval by either
eharper@nvidia.comorzijiey@nvidia.com.Merging your PR
Any member of core-adlr and
core-nemowill be able to merge your PR.