Apply the roofline model to LLM inference and identify where decode and prefill sit on it.
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Sketch the roofline model and place LLM prefill and LLM decode (at varying batch sizes) on it. Use H100 numbers (peak ~3 TB/s HBM, ~989 TFLOPs FP16). Identify where each workload's performance is bound and how interventions move them on the plot.
The roofline plots attainable FLOP/s against arithmetic intensity. Decode sits far left on the bandwidth slope, prefill sits higher, and batching shoves decode rightward toward the compute roof.
Imagine a highway carrying parts from a warehouse to a factory. The factory assembles incredibly fast, but only if parts keep arriving. If each truck carries one tiny part, the factory sits idle waiting for deliveries, so the road is the bottleneck. If each truck is packed full, the factory finally runs flat out and the assembly line becomes the limit. The roofline is a chart of this tradeoff. The slanted part says you are limited by the road, the flat ceiling says you are limited by the factory. LLM decode is the under-loaded truck reading huge weights to make one token. Batching packs more work onto each delivery, pushing you off the road limit toward the factory ceiling.
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.
4 min: roofline axes + ridge point derivation on H100 + place prefill and decode + batch scan rightward + interventions that raise AI or cut bytes.
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.
Treating decode as compute-bound and optimizing FLOPs. Decode at batch 1 hits well under one percent of peak compute; it is starved by HBM bandwidth, so the fix is raising arithmetic intensity, not adding more math units.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.