Predict the arithmetic intensity of decode at varying batch sizes
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Single-token decode on a model with N parameters, FP16 weights (2 bytes / weight). Ignoring KV cache reads (for a short context this is small relative to weight reads), each decoded token requires: - Reading the entire weight matrix: 2N bytes from HBM - Performing one matmul forward pass: ~2N FLOPs per token With batch size B, ONE weight read serves B parallel token streams; FLOPs scale linearly with B. Compute the arithmetic intensity (FLOPs / bytes read) for B = 1, 8, 64, and 512. Express each as a plain FLOP/byte number.
Decode arithmetic intensity equals the batch size B, because one shared 2N-byte weight read serves 2N*B FLOPs. At small batch this sits far below the hardware ridge point, so decode is memory-bandwidth-bound.
Picture a chef who must walk to a far pantry and haul out every ingredient before cooking a single dish. The walk is slow and fixed; the cooking is quick. If she makes that long trip for just one plate, she spends almost all her time walking, not cooking. So the kitchen mostly sits idle. Now imagine she cooks eight plates from the same single trip to the pantry. The walk costs the same, but the cooking grows eightfold, and she finally spends real time at the stove. The expensive trip is now shared across many plates. The lesson: when fetching the ingredients dominates and the cooking is tiny, the trick is to serve many plates from one trip, so the slow fetch is paid once and the stove stays busy.
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: define arithmetic intensity, derive AI = B for decode, place it against the H100 ridge point, explain the memory-bound regime, then connect batching and the KV cache ceiling.
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.
Concluding decode is compute-bound because it does billions of FLOPs. The FLOP count is large but the byte count is larger relative to compute throughput, so the ratio is tiny and memory wins.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.