Is your decode limited by bandwidth,
or by the CPU?

Most LLM decode optimisation assumes the memory system is the wall. On a Tesla T4 it was not: the GPU sat idle for over half of every token while the CPU issued about six thousand operations. Replaying a captured CUDA graph was worth more than every fused kernel combined.

1.72×decode, CUDA graph replay
28 → 48tokens/sec, Qwen2.5-1.5B
86%of the gap the roofline predicted

The explorer

Pick a device and a model. The arithmetic below is the same as hag.roofline, with constants measured on the hardware named. Devices marked measured were benchmarked; the others use datasheet figures and are labelled so.

Decode streams every weight once per token.
0 ms

Watch the difference

Both sides generate the same text with the same weights, one word at a time. The left issues about six thousand instructions per word; the right replays a recording of them. Paced by the measured token rates, so what you are watching is the real difference in speed rather than a guess at it.

Eager PyTorch idle

CUDA graph replay idle

An animation paced by measured throughput, not a model running in your browser. The real side-by-side is demos/gradio_app.py, which needs a GPU. Identical output is the point: the recording must not change a single word, and the benchmark refuses to report a speed until it does not.

What that means

Slide dispatches to zero: that is a perfectly captured CUDA graph. Slide precision to int4: that is quantisation. Whichever bar shrinks more is where your next week of work belongs, and for the measured configuration it was not the one most people reach for first.

What was actually measured

Decode time split into GPU work and CPU dispatch, before and after capture Speedup against row count for both kernels on both platforms

Running it yourself

The notebook runs the whole pipeline on a free T4 in about ten minutes and writes every number on this page: correctness, the op sweep, the profile, the end-to-end benchmark and the CUDA graph capture. Nothing here is a figure you have to take on trust.

Open in Colab → View on GitHub Read the write-up

Prefer Kaggle: its GPU quota is larger and the machine is quieter. The same benchmark measured a standard deviation of 0.53 tok/s there against 3.68 on Colab, which decided whether an effect resolved at all.