Repository navigation
Conversation
Signed-off-by: Chen Cui <chcui@nvidia.com>
Signed-off-by: Chen Cui <chcui@nvidia.com>
Signed-off-by: Chen Cui <chcui@nvidia.com>
Signed-off-by: Chen Cui <chcui@nvidia.com>
Signed-off-by: Chen Cui <chcui@nvidia.com>
|
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. |
4 of 5 tasks
…#8010 Signed-off-by: Chen Cui <chcui@nvidia.com>
wujingyue
reviewed
Oct 14, 2026
wujingyue
left a comment
Contributor
There was a problem hiding this comment.
Can you split? This PR seems to contain several changes. We should be able to separate the checkpointing fix at least. I guess the changes in finalize_model_grads and the changes in adapter are separatable as well.
This branch has not been 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.
Depends on #8010 for shared-embedding initialization with meta-device construction. This PR contains no replacement initialization logic. Keep it draft until that dependency is available.
What does this PR do?
Fix Megatron-FSDP v1 mesh construction and checkpoint restart with non-interleaved pipeline parallelism.
With eight ranks and PP=2, the mesh helpers reshape all eight ranks using stage-local dimensions whose product is four. Include the outer PP axis in both FSDP and HSDP construction, then select the current stage and expert rank. Existing process-group consistency checks remain in place.
FSDP DTensor checkpointing also bypasses the block
sharded_state_dict()methods that normally give pipeline layers global names. Two stages can consequently save different weights and Adam moments under the samedecoder.layers.0.*keys. Add a shared handler that uses each layer's globallayer_numberfor model tensors, optimizer state, and optimizer group metadata. Run it after fused-parameter, expert, and MTP processing on save and load, preserving the original tensor aliases for in-place loading. MTP retains its separate namespace.Precision-aware v1 optimizers put gradients in
decoupled_grad. Recognize that attribute when reducing shared embeddings across pipeline stages. Empty shards remainNonefor the optimizer, while synchronization retrieves their metadata-bearing buffer tensors so every DP rank participates.Existing checkpoints affected by stage-local key collisions cannot recover the omitted weights and must be regenerated. The new checkpoint remapping applies only to v1; v2 optimizer keys are already global and must not be renamed again. PP=1 checkpoint names remain unchanged. The existing default missing-weight validation rejects incomplete legacy checkpoints.
Validation
5920bd95) plus this PR: eight hybrid layers, MTP=2, PP=2/EP=2/TP=1, BF16 compute and FP32 master weights/Adam moments. Three training steps, save at step two, then restart: all saved weights and optimizer tensors restored bitwise exactly on all eight ranks. The next loss (5.374913215637207) and gradient norm (2.875216245651245) match uninterrupted training exactly. After that step, 281/287 complete model/Adam tensors are bitwise equal; all pass rtol=1e-5/atol=1e-6, maximum absolute difference 4.331e-8.tools/autoformat.shcheck mode passed Black/isort/pylint/ruff. Mypy is not installed in the pinned lint group and is optional in that script.Training probes use function-level patch injection into NeMo 26.08.01, including #8010 and the existing main-branch embedding-gradient handling from #6486. Distributed unit tests use the full proposed Core source based on
cab97ebd1.Training probes set
deallocate_pipeline_outputs=False, since v1's backward hooks return output views rejected by pipeline output deallocation. Coverage is non-interleaved PP; these short synthetic-data tests do not establish convergence or performance.Focused Core command:
torchrun --standalone --nproc_per_node=8 -m pytest tests/unit_tests/distributed/mfsdp_v1/test_fsdp_mesh.py tests/unit_tests/distributed/mfsdp_v1/test_pipeline_checkpoint.py tests/unit_tests/distributed/mfsdp_v1/test_pipeline_embedding_grads.py -q.Independent subagent review of the removal and remaining diff completed; no source blockers.
Contribution checks
tools/autoformat.shin check mode (Black/isort/pylint/ruff passed; mypy is not installed in the pinned lint group and is optional in that script).Bridge requires the companion call-site change: NVIDIA-NeMo/Megatron-Bridge#6424.