Reduce diffusion-expert launch overhead with bounded CUDA graphs - #116
Open
brandonpelfrey wants to merge 1 commit into
Open
Reduce diffusion-expert launch overhead with bounded CUDA graphs#116brandonpelfrey wants to merge 1 commit into
brandonpelfrey wants to merge 1 commit into
Conversation
Signed-off-by: Brandon Pelfrey <bpelfrey@nvidia.com>
brandonpelfrey
marked this pull request as ready for review
August 21, 2026 16:02
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
This adds the same opt-in bounded CUDA-graph replay to Alpamayo R1 that is proposed for Alpamayo 1.5 PR #36 and Alpamayo 2 PR #12.
Only the repeated diffusion-expert forwards in trajectory sampling are captured. The autoregressive VLM rollout and training/autograd paths remain eager. The public API is consistent across the model repositories:
Keeping this capability on the model also lets downstream inference adapters and model subclasses enable the optimization without carrying a separate CUDA-graph implementation.
The Alpamayo 1.5 PR contains the corresponding end-to-end policy-workload results and pipeline-level analysis. This PR does not assume that the exact system-level improvement transfers unchanged to every Alpamayo R1 workload.
Variable batch sizes
Graphs are captured lazily for exact tensor and prompt-KV signatures. Different observed batch sizes therefore receive separate graphs automatically; callers do not need to pad to
max_batch_size.Up to
max_graphssignatures are retained. Once that bound is reached, unseen signatures use eager execution.max_batch_sizeis the accepted upper bound, rather than a padding target.Change
enable_diffusion_expert_cuda_graph(max_batch_size=..., max_graphs=...).The feature is off by default and is enabled only after model placement and
eval().Validation
Risk
Each captured signature retains static input and prompt-KV buffers, so enabling the feature increases CUDA memory use.
max_graphsbounds retained state, and unsupported or excess signatures use the eager path. Default behavior is unchanged.