Decode-phase attention is memory bandwidth bound. Explain what flips the regime.
During prefill, attention is compute-bound, but during decode, the same layer becomes memory bandwidth bound. Explain why generating one token per step changes the regime, and name two optimizations that exploit this insight.
At decode, Q has length 1 per step, so the attention matmul is tiny, but the full KV cache must stream from HBM, making bandwidth (not FLOPs) the bottleneck.
Imagine a chef cooking one omelette per minute (decode) versus a chef cooking 100 omelettes in a batch (prefill). For the single omelette, the time is dominated by walking to the fridge to fetch all the ingredients (streaming the cache from memory), the actual cooking is a few seconds. For the batch, the chef opens the fridge once, takes out everything, and the cooking dominates. The kitchen bottleneck flips from 'how fast can the chef cook' (compute) to 'how fast can you fetch ingredients' (memory bandwidth). Decode-time LLM serving has the same flip every single token step.
Detailed answer & concept explanation~7 min readEverything 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. 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.
8 min: Q shape difference between prefill and decode, arithmetic intensity calculation, roofline interpretation, concrete cache bytes for production models, GQA and MQA as cache shrinkers, KV quantization, Flash-Decoding parallelization, speculative decoding as a regime-flipper, multiplicative composition in the 2026 stack.
| Property | Prefill | Decode |
|---|---|---|
| Q shape per layer per head | (T, d) | (1, d) |
| K, V shape | (T, d), built from input | (T, d), cached |
| FLOPs per layer | O(T^2 d), large | O(T d), small |
| Bytes loaded per layer | O(T d), amortized over T queries | O(T d), per single query |
| Arithmetic intensity | O(T), high | O(1), low |
| Regime | Compute-bound (tensor cores) | Memory bandwidth bound (HBM) |
| Bottleneck | FLOPs | Bytes streamed per step |
| Main optimizations | FlashAttention, tensor-core efficient kernels | GQA/MQA/MLA, KV quantization, Flash-Decoding |
Real products, models, and research that use this idea.
- Llama 4 Maverick uses GQA with grouped K and V heads to cut decode-time KV bandwidth, the standard production technique for long-context serving.
- DeepSeek V4's MLA compresses KV into a small latent, achieving roughly 10x cache reduction vs GQA on long contexts.
- vLLM and TensorRT-LLM ship INT8 and FP8 KV cache quantization options that combine multiplicatively with GQA for further bandwidth savings.
- Flash-Decoding (Dao et al. 2023) parallelizes the key axis across multiple SMs to break past single-SM HBM bandwidth limits on long-context decode.
- Speculative decoding with draft models like Llama-3-8B verifying for Llama-3-70B raises decode arithmetic intensity and is now standard in 2026 production serving for GPT-5.5, Claude Opus 4.7, and large open models.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhy does FlashAttention not solve the decode bandwidth problem?
QHow does speculative decoding raise arithmetic intensity?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Assuming decode is slow because of FLOPs. The FLOPs per decode step are tiny; the bottleneck is moving the KV cache from HBM to SRAM, which is why every decode optimization targets bytes per token rather than ops per token.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.