Repository navigation
[MFSDP] Integrate v2 partial CUDA Graph capture with MoE validation - #9112
Open
WEIXILIN0307 wants to merge 11 commits into
Open
WEIXILIN0307 wants to merge 11 commits into
WEIXILIN0307 wants to merge 11 commits into
Conversation
WEIXILIN0307
force-pushed
the
feat/mfsdp-v2-partial-cuda-graphs
branch
from
November 12, 2026 06:17
45bc0d3 to
5c12bd9
Compare
This was referenced Nov 12, 2026
Suspend owned FSDP hooks during capture, retain existing gathered buffers and replay through normal module hooks. Clone mutable RNG contents for rollback. Cover MoE state parity, communication streams, deletion, native checkpoint continuation and recapture. Keep Combined1F1B, EP reordering and TE-private recovery outside this change. Signed-off-by: Pinoeer-kingxi <13022943007@163.com>
WEIXILIN0307
force-pushed
the
feat/mfsdp-v2-partial-cuda-graphs
branch
from
November 12, 2026 08:05
5c12bd9 to
26714de
Compare
Signed-off-by: Pinoeer-kingxi <13022943007@163.com>
…acts Signed-off-by: Pinoeer-kingxi <13022943007@163.com>
Move wrapper-aware graph dispatch to TECudaGraphMixin after the upstream TE refactor. Preserve native deletion callbacks and migrate retained-graph lifecycle checks to te_cuda_graphs. Signed-off-by: Pinoeer-kingxi <weixilin307@gmail.com>
Exercise GPT, Hybrid, and MLA with representative sharding and stream policies. Fold successful RNG, address, and recapture checks into the parity test, and keep the distinct capture failure paths. Reference evaluation and checkpoint composition evidence from the independent fixes. Signed-off-by: Pinoeer-kingxi <weixilin307@gmail.com>
Use representative GPT and Hybrid MoE cases and reuse one warmed model for recoverable startup and post-capture failures. Check a secondary cleanup failure without retrying after the helper requires a restart. Signed-off-by: Pinoeer-kingxi <weixilin307@gmail.com>
Restore the MLA ZeRO-2 path and numerical parity after rollback and retry. Guard against capture over live graphs and confirm launches after recapture. Exercise configuration rejection and caller hook restoration in the existing rollback case. Signed-off-by: Pinoeer-kingxi <weixilin307@gmail.com>
Signed-off-by: Pinoeer-kingxi <weixilin307@gmail.com>
Attach any capture-exit reshard failure to the original exception and let the graph helper finish cleanup. Exercise this fault in the existing cleanup case and share standalone configuration validation with the parity case. Signed-off-by: Pinoeer-kingxi <weixilin307@gmail.com>
Use the real Transformer Engine hook rejection to verify that a capture-exit reshard failure preserves the original error and the caller hook. Signed-off-by: Pinoeer-kingxi <weixilin307@gmail.com>
Gathered buffers can already be allocated before the first eager gather. Keep the original eager resize path, and skip resize only when a capture owns the allocation. Both paths refresh weights and record readiness as before. Signed-off-by: Pinoeer-kingxi <weixilin307@gmail.com>
WEIXILIN0307
marked this pull request as ready for review
November 25, 2026 01:50
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.
What does this PR do?
A BF16 Hybrid MoE model can complete eager steps with Megatron FSDP v2 and then fail at partial CUDA Graph capture. Transformer Engine (TE) rejects the installed FSDP hooks. FSDP can also release gathered weights whose addresses the graph needs for replay.
Pause the FSDP execution hooks during capture and keep the existing gathered-weight allocations alive until graph deletion. Replay goes through the normal module call, so those hooks refresh current weights in the same allocations and keep the existing readiness waits and gradient reduction. Deletion drains GPU work and resets the graph before releasing the allocations.
This preserves the opportunity for independent FSDP all-gather and reduce-scatter to run alongside graph compute. The four-GPU trace at
e497dd0records both, with zero overlap for expert-parallel token all-to-all. The trade-off is higher weight residency at the existing FSDP unit boundaries. The measured proxy retained about 513 MiB per rank. Design and trade-offs · Trace and dependency analysisReview guide
Validation
e54d389and matches eager after replay on4d48616. All five focused cases pass per rank at4d48616, covering GPT, MLA, Hybrid, ZeRO-1/2/3, two-microbatch accumulation, deletion, recapture and controlled rollback. Testsc6b78bband [MFSDP] Preserve native v2 DTensor checkpoint projections #9374 at4a968a8. The evaluation test applies to that follow-up revision. The tested retry after an exception in TE warmup uses the graph implementation from TE Pass gracefully if token_id not found in message #3862 at22d4727. Normal training uses stock TE. TE #3862e497dd0shows ordinary and expert-DP all-gather and reduce-scatter overlapping graph compute with EP=2 and expert-DP=2. Thea8a8424WikiText-103 proxy had 13.10% lower step time at EP2 and 0.53% higher step time at EP1 versus eager. Normal EP1 graph execution took 4.95% less step time than the serialized graph control. These measurements apply to those revisions and configurations. The control measures total step time under serialization. Trace and commands · Historical performance, memory and logsScope
The initial path uses fixed-shape BF16, TP=PP=CP=1, TE ≥2.10 for explicit graph reset, and no symmetric memory. It captures attention, dense MLP, the MoE router and router-paired preprocess. Expert dispatch, expert compute and combine remain eager. Upstream GPU CI and functional-test registration are pending. Configuration and limits
Issue tracking
Design discussion in #9113.
Code provenance
No external code copied or adapted.
Contribution process
Pre-checks
jit_fuser/torch.compile, CUDA extension, TE or external-library dispatch, or a scatter/index accumulation), I have added or updated its bit-exact determinism test and registered it intests/unit_tests/determinism/kernels/manifest.py(guide). No numerical kernel changed.