Walk through how CUDA graphs reshape per-step decode latency and when the win disappears
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Explain what CUDA graphs do during decode and why the speedup is most visible at small batch. Then identify two conditions under which CUDA graphs help less, or break entirely.
CUDA graphs record the kernel-launch sequence of one decode step and replay the whole graph as a single submission, collapsing dozens of per-step CPU dispatches into one.
Picture a busy chef shouting instructions to a fast cook for each tiny task: chop, stir, pour, taste. The cook is so fast that most of the wall-clock time is the chef finishing one sentence and starting the next. CUDA graphs let the chef write the whole recipe down once and just say 'do that recipe' on every batch, so all the talking happens once. This makes a big difference when the cook is much faster than the chef can talk, which is exactly what happens during decode at small batch. But if the recipe changes every batch (different ingredients, different steps), writing it down does not help, and that is when CUDA graphs stop working.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
3 min: explain the ~10-30 us per-launch CPU overhead, count kernels per decode step, identify the small-batch regime where overhead dominates, describe what a CUDA graph captures and replays, then name the large-batch erosion and the shape-variability break with shape bucketing as the standard mitigation.
| Regime | Per-step time without graphs | Per-step time with graphs | Win |
|---|---|---|---|
| Small batch (1-4) on 7B-13B model | ~3-8 ms (mostly dispatch) | ~1.5-4 ms | 1.5-2x |
| Small batch on 70B model | ~25-30 ms (dispatch is ~10-20% of step) | ~22-26 ms | 1.1-1.3x |
| Large batch (32-64) on 70B | ~50-60 ms (dispatch <5%) | ~48-58 ms | <1.05x |
| Variable-shape continuous batching | Per-step recapture cost | Per-bucket graphs + padding | Depends on bucket coverage |
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Thinking CUDA graphs make the GPU work faster. The kernels themselves run at the same speed; CUDA graphs only remove the CPU-side dispatch overhead between them. The win comes from eliminating idle gaps, not from accelerating compute.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.