Skip to content

Fix MoE checkpoint save skipping TP ranks when TP > EP * ETP (#4200) - #4234

Closed
aarushisingh04 wants to merge 2 commits into
NVIDIA:mainfrom
aarushisingh04:fix/moe-checkpoint-save-missing-tp-ranks
Closed

Fix MoE checkpoint save skipping TP ranks when TP > EP * ETP (#4200)#4234
aarushisingh04 wants to merge 2 commits into
NVIDIA:mainfrom
aarushisingh04:fix/moe-checkpoint-save-missing-tp-ranks

Conversation

@aarushisingh04

Copy link
Copy Markdown

What does this PR do?

fixes a bug where MoE checkpoints skip saving state dicts for certain TP ranks when TP > EP * ETP.

fixes #4200

Description

  • when MoE is used with a topology where TP > EP * ETP, the Expert Data Parallel (EDP) group is larger than the regular Data Parallel (DP) group.
  • the previous save condition gated checkpoint generation strictly on edp_rank == 0.
  • in this topology some ranks have dp_rank == 0 (they hold a unique dense/attention shard) but edp_rank > 0, so they were incorrectly skipped resulting in missing model_optim_rng.pt files and a crash on reload.

fix: replace edp_rank == 0 with min(dp_rank, edp_rank) == 0 in both save-condition locations. a rank now saves if it is primary for either its dense parameters (DP group) or its expert parameters (EDP group).

scope: this only affects CheckpointType.LEGACY. For modern distributed formats, the ckpt_type != CheckpointType.LEGACY clause short-circuits the check entirely so those paths are unaffected.

Pre-checks

  • I have added relevant unit tests
  • I have added relevant functional tests
  • I have added proper typing to my code Typing guidelines
  • I have added relevant documentation
  • I have run the autoformatter.sh on my PR

@copy-pr-bot

copy-pr-bot Bot commented Apr 9, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@aarushisingh04
aarushisingh04 marked this pull request as ready for review April 9, 2026 16:13
@aarushisingh04
aarushisingh04 requested review from a team as code owners April 9, 2026 16:13
@svcnvidia-nemo-ci
svcnvidia-nemo-ci requested a review from a team April 9, 2026 16:13
@chtruong814 chtruong814 added the needs-follow-up Issue needs follow-up label Apr 11, 2026
@svcnvidia-nemo-ci svcnvidia-nemo-ci added waiting-on-maintainers Waiting on maintainers to respond and removed needs-follow-up Issue needs follow-up labels Apr 21, 2026
@dimapihtar

Copy link
Copy Markdown
Contributor

Hi, PR which resolves that issue has been already merged: #4678

Thanks!

@dimapihtar dimapihtar closed this May 14, 2026
@svcnvidia-nemo-ci svcnvidia-nemo-ci removed the waiting-on-maintainers Waiting on maintainers to respond label May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug of save_checkpoint with ckpt_format is torch.

5 participants