Repository navigation
[graph_trainer] Remove cuda_graph passes in graph_trainer by default - #5023
Merged
Merged
Conversation
IvanKobzarev
requested review from
SherlockNoMad,
aditvenk,
sanketpurandare and
tianyu-l
as code owners
October 2, 2026 14:30
IvanKobzarev
force-pushed
the
gt-cudaconfigs
branch
from
October 7, 2026 12:32
2ad2cac to
2ad0d7f
Compare
IvanKobzarev
force-pushed
the
gt-cudaconfigs
branch
from
October 7, 2026 13:03
2ad0d7f to
822d58f
Compare
IvanKobzarev
force-pushed
the
gt-cudaconfigs
branch
2 times, most recently
from
October 8, 2026 12:26
08930d5 to
978824f
Compare
IvanKobzarev
force-pushed
the
gt-cudaconfigs
branch
from
October 8, 2026 12:34
978824f to
52eb67b
Compare
IvanKobzarev
force-pushed
the
gt-cudaconfigs
branch
from
October 8, 2026 16:11
52eb67b to
a93b971
Compare
SherlockNoMad
approved these changes
Oct 13, 2026
SherlockNoMad
left a comment
Contributor
There was a problem hiding this comment.
mostly looks good to me, should be good for land when you address the comment.
IvanKobzarev
force-pushed
the
gt-cudaconfigs
branch
2 times, most recently
from
October 13, 2026 17:57
f6bda32 to
f7fbdfc
Compare
syed-ahmed
added a commit
that referenced
this pull request
Oct 13, 2026
#5023 moves CUDA graph capture out of `cuda_graph_pass` and into the client `TrainingEngine`, which captures the whole forward/backward as one graph. Paged stashing composed with the old pass-level capture by sitting outside each captured subgraph; with a whole-step graph it ends up inside one, where `PagedStashRunner`'s host-side work is not capturable -- the overflow flag's `event.query()`, the freelist reset, and the Triton warmup, which cannot compile during capture. Invert the nesting. Wrap the eager forward/backward in the CUDA graph first, then run the runner around that: the runner stays on the host and may rerun the step, and the graph holds only the step itself. An overflow still has to drop the graph before the pages it baked pointers into are released, so `PagedStashRunner` takes a `reset_cuda_graphs` callback rather than calling the module-level function, which after #5023 has no trainer graph to reset. The trainer passes one that tears its graph down and rebuilds the wrapper, and the rebuilt wrapper is looked up on every attempt so a blocking rerun picks it up. Whole-step capture also lifts the pipeline-parallel restriction in `next_entries`, which returned no entries under capture: a stage-level graph captured at one point in the schedule would replay that point's skip and prefetch decisions for every microbatch. The trainer captures every pipeline action at its own place, so the schedule-dependent answers replay correctly and skipping and prefetching work under GraphPP with graphs on. Measured on 4xGB200, DeepSeek-V3 debugmodel + HybridEP, PP=2 Interleaved1F1B / 4 microbatches, FSDP 2, EP 2, round-robin routing; peak reserved on the worst rank, saved-but-not-paged against paged: HybridEP capacity factor 1.0 2.0 4.0 8.0 saved, not paged 10.89 14.72 23.05 39.19 GiB paged 9.68 10.00 11.22 13.82 GiB Capture is what makes the un-paged side cost `layers x padded`: it pins every layer's padded buffer in the graph's private pool. The stash pool that replaces them is 2217.56 MiB at capacity factor 1, 2 and 4 and 2219.01 MiB at 8, while the padded residency grows 2016 -> 16138 MiB, so the pool follows live rows and not the padding. Over the sweep the un-paged slope is 4.06 GiB per capacity-factor unit against 0.61 paged. The runtime mechanics are now tested the way they run, with the step captured. `test_blocking_mode` drives the whole-step graph and absorbs the separate pass-level CUDA graph case it duplicated. `test_deferred_mode` gains a captured step, so the default overflow policy is covered around a graph and not only eagerly. `test_reloads_are_prefetched_one_schedule_entry_ahead` captures and replays a prefetched reload, since prefetching is how the stash runs under the trainer's graph. `test_paged_activation_lives_until_its_copy_is_joined` captures the release, which is where it bites: an activation held past its join keeps its padding in the graph's private pool for the life of the graph, and that per-layer residency is what paging removes. `test_schedule_decides_which_stashes_stay_resident` pins `next_entries` under capture with a pipeline schedule -- the one place the lifted restriction needs covering, since skipping and prefetching both read it. `test_sizing_keeps_one_pool_of_live_pages` gains the `worst_case + actual` decomposition an earlier consolidation dropped. What stays eager is what capture cannot reach: the graph-pass and partition tests run at trace time, before there is a stream to capture; the schedule and sizing tests are arithmetic over actions and page counts; and the optimizer-skipping test turns on `optimizers.step()` honoring the flag on device, which runs outside the forward-backward graph. Paged stashing had two integration tests, one per concurrency mode, because the modes could not be combined. They can, so one covers it: `aot_fx_trace_deepseek_v3_graph_pp_hybridep_paged_stash` drops `disable_cuda_graphs` and runs GraphPP, the whole-step CUDA graph and paged stashing together. It passes on 4 GPUs with "Recorded CUDA graph" on every rank, GraphPP sizing engaged on every rank, and no token drops. The FSDP+TP config it replaces is the only coverage lost; TP does not fit alongside PP 2 and FSDP 2 at 4 GPUs.
Remove cuda_graph_pass from GraphTrainer default pass construction, configuration, precompile, and GraphPP wiring while keeping the pass implementation available for explicit callers. The client TrainingEngine owns outer capture around the complete forward/backward execution.
IvanKobzarev
force-pushed
the
gt-cudaconfigs
branch
from
October 13, 2026 18:53
f7fbdfc to
f11154c
Compare
syed-ahmed
added a commit
that referenced
this pull request
Oct 13, 2026
#5023 moves CUDA graph capture out of `cuda_graph_pass` and into the client `TrainingEngine`, which captures the whole forward/backward as one graph. Paged stashing composed with the old pass-level capture by sitting outside each captured subgraph; with a whole-step graph it ends up inside one, where `PagedStashRunner`'s host-side work is not capturable -- the overflow flag's `event.query()`, the freelist reset, and the Triton warmup, which cannot compile during capture. Invert the nesting. Wrap the eager forward/backward in the CUDA graph first, then run the runner around that: the runner stays on the host and may rerun the step, and the graph holds only the step itself. An overflow still has to drop the graph before the pages it baked pointers into are released, so `PagedStashRunner` takes a `reset_cuda_graphs` callback rather than calling the module-level function, which after #5023 has no trainer graph to reset. The trainer passes one that tears its graph down and rebuilds the wrapper, and the rebuilt wrapper is looked up on every attempt so a blocking rerun picks it up. Whole-step capture also lifts the pipeline-parallel restriction in `next_entries`, which returned no entries under capture: a stage-level graph captured at one point in the schedule would replay that point's skip and prefetch decisions for every microbatch. The trainer captures every pipeline action at its own place, so the schedule-dependent answers replay correctly and skipping and prefetching work under GraphPP with graphs on. Measured on 4xGB200, DeepSeek-V3 debugmodel + HybridEP, PP=2 Interleaved1F1B / 4 microbatches, FSDP 2, EP 2, round-robin routing; peak reserved on the worst rank, saved-but-not-paged against paged: HybridEP capacity factor 1.0 2.0 4.0 8.0 saved, not paged 10.89 14.72 23.05 39.19 GiB paged 9.68 10.00 11.22 13.82 GiB Capture is what makes the un-paged side cost `layers x padded`: it pins every layer's padded buffer in the graph's private pool. The stash pool that replaces them is 2217.56 MiB at capacity factor 1, 2 and 4 and 2219.01 MiB at 8, while the padded residency grows 2016 -> 16138 MiB, so the pool follows live rows and not the padding. Over the sweep the un-paged slope is 4.06 GiB per capacity-factor unit against 0.61 paged. The runtime mechanics are now tested the way they run, with the step captured. `test_blocking_mode` drives the whole-step graph and absorbs the separate pass-level CUDA graph case it duplicated. `test_deferred_mode` gains a captured step, so the default overflow policy is covered around a graph and not only eagerly. `test_reloads_are_prefetched_one_schedule_entry_ahead` captures and replays a prefetched reload, since prefetching is how the stash runs under the trainer's graph. `test_paged_activation_lives_until_its_copy_is_joined` captures the release, which is where it bites: an activation held past its join keeps its padding in the graph's private pool for the life of the graph, and that per-layer residency is what paging removes. `test_schedule_decides_which_stashes_stay_resident` pins `next_entries` under capture with a pipeline schedule -- the one place the lifted restriction needs covering, since skipping and prefetching both read it. `test_sizing_keeps_one_pool_of_live_pages` gains the `worst_case + actual` decomposition an earlier consolidation dropped. What stays eager is what capture cannot reach: the graph-pass and partition tests run at trace time, before there is a stream to capture; the schedule and sizing tests are arithmetic over actions and page counts; and the optimizer-skipping test turns on `optimizers.step()` honoring the flag on device, which runs outside the forward-backward graph. Paged stashing had two integration tests, one per concurrency mode, because the modes could not be combined. They can, so one covers it: `aot_fx_trace_deepseek_v3_graph_pp_hybridep_paged_stash` drops `disable_cuda_graphs` and runs GraphPP, the whole-step CUDA graph and paged stashing together. It passes on 4 GPUs with "Recorded CUDA graph" on every rank, GraphPP sizing engaged on every rank, and no token drops. The FSDP+TP config it replaces is the only coverage lost; TP does not fit alongside PP 2 and FSDP 2 at 4 GPUs.
This was referenced Oct 13, 2026
This was referenced Oct 15, 2026
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.
The main goal is to make GraphTrainer to work seamlessly with outer CUDA graph capture by default.
In torchtitan case - torchtitan trainer is doing cudagraph capture.