Why is autoregressive LLM decoding at batch size 1 memory-bandwidth bound? For a 7-billion-parameter fp16 model (14 GB) on a GPU with 2 TB/s memory bandwidth and 300 TFLOP/s of fp16 compute, what is the upper bound on tokens/s at batch size 1, what is the arithmetic intensity, and near what batch size does decoding reach the compute ridge point?

Sequence models and transformers, Inference
Level L3 Intermediate. Length Medium. Nature Mat Mathematical.

What's being asked

Whether you can quantify the compute-versus-memory bottleneck in autoregressive decoding using roofline analysis (read time, compute time, arithmetic intensity and ridge point), and explain how batching changes it.

Key idea

Generating one token at batch size 1 multiplies a vector by every weight matrix, so the GPU (graphics processing unit) must read all 14 GB of weights from memory to do only ≈2N FLOPs (floating-point operations) — an arithmetic intensity of 1 FLOP/byte. Because 1 FLOP/byte is 150× below the hardware ridge point, the compute cores sit idle waiting on memory bandwidth.

Steps

  1. Compute the weight-read time at batch size 1: the model has N=7×109 parameters in fp16 (16-bit floating point, 2 bytes each), so weights total W=14 GB (14×109 B). Streaming them once from HBM (high-bandwidth memory) at 2 TB/s=2×1012 B/s takes tmem=14×109 B2×1012 B/s=7×10−3 s=7 ms.
  2. Compute the arithmetic time at batch size 1: each weight takes part in one multiply and one add (2 FLOPs) per token, giving roughly 2N=14×109 FLOPs=14 GFLOPs (billion FLOPs, ignoring smaller attention-dot-product terms at short contexts). At 300 TFLOP/s=300×1012 FLOP/s (trillion FLOPs per second), compute takes tcomp=14×109300×1012≈0.047 ms, over 150× faster than reading the weights.
  3. Find the batch-1 throughput upper bound: limited by weight loading alone (before counting KV, key–value, cache reads), the GPU can produce at most throughputmax⁡=17 ms=2×101214×109≈142.9≈143 tokens/s.
  4. Define arithmetic intensity and the ridge point: arithmetic intensity is FLOPs divided by bytes transferred from HBM. Ignoring KV cache reads, batch size 1 has intensity I(1)=2N FLOPs2N bytes=1 FLOP/byte. The hardware ridge point (where memory time equals compute time) is Iridge=300×1012 FLOP/s2×1012 B/s=150 FLOP/byte.
  5. Show how batching B sequences shifts the regime: reading the weights stays 14 GB per step while weight FLOPs grow B-fold to 2NB, so arithmetic intensity rises roughly B-fold (I(B)≈B FLOP/byte). Total tokens/s therefore scales almost linearly with B until B approaches the ridge point (B≈150), where decoding turns compute-bound.
  6. Add the KV cache caveat: at every decoding step, the GPU must also read each sequence's cached keys and values (covered in detail in KV-cache questions). Because KV cache reads grow linearly with B and context length, they lower effective arithmetic intensity and cap batch size in VRAM (video memory) before B=150 on long contexts.

Common mistakes

How long your answer should be

3–4 minutes; compare 7 ms vs 0.047 ms, derive ~143 tokens/s, intensity 1 FLOP/B, ridge point 150, and note the KV cache.

Read this

Previous in Sequence models and transformers: How much GPU memory do model states take when fine-tuning a 7-billion-parameter model with mixed-precision Adam under (a) full fine-tuning, (b) LoRA with 20 million trainable adapter parameters on an fp16 base, and (c) QLoRA with a 4-bit NormalFloat base? How do NF4, double quantisation and paged optimisers work, and what is the trade-off?
Next in Sequence models and transformers: In speculative decoding, a draft model proposes k tokens and each is accepted independently with probability α. How do you derive the expected number of tokens produced per target-model forward pass, what is its value for α=0.8 and k=4, and what is the expected speedup if one draft forward pass costs c=0.05 of a target forward pass?