[PyTorch] Share CUDA graph memory across dynamic CP variants - #3353
Draft
xiaoyao0115 wants to merge 3 commits into
Draft
[PyTorch] Share CUDA graph memory across dynamic CP variants#3353xiaoyao0115 wants to merge 3 commits into
xiaoyao0115 wants to merge 3 commits into
Conversation
Signed-off-by: xiaoyao0115 <1804647152@qq.com>
for more information, see https://pre-commit.ci
Signed-off-by: xiaoyao0115 <1804647152@qq.com>
xiaoyao0115
force-pushed
the
test/dcp-cg-gap-fix
branch
from
August 12, 2026 09:24
e1cfcd3 to
c095214
Compare
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.
Summary
make_graphed_callablestorch.cuda.MemPoolMotivation
Dynamic context parallelism captures several CP-size alternatives. Capturing every alternative with independent graph allocations multiplies the CUDA graph memory footprint. Same-slot CP alternatives are mutually exclusive at replay time, so they should reuse the canonical branch's physical allocations.
This change keeps one allocator pool and reuses addresses at the same liveness slot while retaining compatibility, allocator-liveness, saved-tensor interval, and StorageImpl ownership checks.
Compatibility
The slot-memory interface is private and accepts only the production nine-field plan. The ordinary CUDA graph path is unchanged when no slot plan is supplied.
Companion change
Validation
Static checks on commit
c095214af883862527b5e6d35d978acd9b272844:git diff --checkFocused GPU validation:
6073801)6073868)Full regression used 8 GB200 GPUs across 2 nodes with a Qwen3-30B-A3B-shaped 48-layer model: PP4, VPP4, EP2, sequence length 8192, global batch 64, 32 runtime microbatches, and
pad-packed-seq-alignment=max-seqlen-per-dp-cp-rank=8192. The dynamic schedule exercised CP1 and CP2. Capture logs report2 dynamic-CP variants over 8 slot-aliased physical TE pool slots, confirming one physical slot ring rather than one bank per CP size.6074897): no skipped or NaN iterations; maximum logged absolute LM-loss difference was0.00398(0.0351% of the corresponding loss), and auxiliary-loss values matched at logged precision.6074298,6074899): after iteration 3 andtorch.cuda.empty_cache(), per-rank whole-device deltas were-440to+16 MiBand-366to+96 MiB. The largest observed positive delta was 0.1001% of device usage. There is no multiplicative memory growth with two CP variants.+80to+272 MiB, while reserved-memory deltas ranged from+758to+1296 MiBacross both runs. This is reported separately from whole-device usage and remains visible for follow-up profiling.CI notes
fatbinary fatal: Could not open input file 'gelu.compute_75.ptx'; JAX C++ and JAX Python checks pass.ast.StrAPI. The same changed-file hook set passes locally.