# LLM decode speed: why generating tokens is bound by memory bandwidth, not by compute

An H100 can do almost a thousand trillion operations a second, yet a chatbot on it types at around a hundred tokens a second. The reason is memory traffic. Pick a model, a batch and a context length and see how bytes moved, not FLOPs, set the speed of generation.

<div data-sim="specx" data-spec="{&#34;head&#34;:&#34;LLM decode speed: the memory-bandwidth roofline on an H100&#34;,&#34;sub&#34;:&#34;Twelve open-weight models. Every generated token reads the weights and the whole KV cache from GPU memory. Change batch, context and precision and see when decoding is bound by bandwidth and when by compute.&#34;,&#34;params&#34;:[{&#34;id&#34;:&#34;batch&#34;,&#34;label&#34;:&#34;Batch (sequences decoded together)&#34;,&#34;min&#34;:1,&#34;max&#34;:256,&#34;step&#34;:1,&#34;value&#34;:16},{&#34;id&#34;:&#34;ctx&#34;,&#34;label&#34;:&#34;Context length per sequence&#34;,&#34;min&#34;:512,&#34;max&#34;:131072,&#34;step&#34;:512,&#34;value&#34;:8192,&#34;unit&#34;:&#34;tokens&#34;},{&#34;id&#34;:&#34;wbytes&#34;,&#34;label&#34;:&#34;Bytes per weight&#34;,&#34;min&#34;:0.5,&#34;max&#34;:2,&#34;step&#34;:0.5,&#34;value&#34;:2,&#34;note&#34;:&#34;2 = BF16, 1 = FP8, 0.5 = 4-bit&#34;},{&#34;id&#34;:&#34;kvb&#34;,&#34;label&#34;:&#34;Bytes per KV-cache value&#34;,&#34;min&#34;:1,&#34;max&#34;:2,&#34;step&#34;:1,&#34;value&#34;:2,&#34;note&#34;:&#34;2 = BF16 cache, 1 = FP8 cache&#34;},{&#34;id&#34;:&#34;bw&#34;,&#34;label&#34;:&#34;Memory bandwidth per GPU&#34;,&#34;min&#34;:1,&#34;max&#34;:8,&#34;step&#34;:0.05,&#34;value&#34;:3.35,&#34;unit&#34;:&#34;TB/s&#34;,&#34;note&#34;:&#34;H100 SXM: 3.35 TB/s&#34;},{&#34;id&#34;:&#34;peak&#34;,&#34;label&#34;:&#34;Dense compute per GPU&#34;,&#34;min&#34;:100,&#34;max&#34;:2500,&#34;step&#34;:1,&#34;value&#34;:989,&#34;unit&#34;:&#34;TFLOPS&#34;,&#34;note&#34;:&#34;H100 SXM BF16 dense: 989 (NVIDIA lists 1,979 with sparsity)&#34;},{&#34;id&#34;:&#34;hbm&#34;,&#34;label&#34;:&#34;Memory per GPU&#34;,&#34;min&#34;:16,&#34;max&#34;:192,&#34;step&#34;:1,&#34;value&#34;:80,&#34;unit&#34;:&#34;GB&#34;},{&#34;id&#34;:&#34;pick&#34;,&#34;label&#34;:&#34;Model for the chart (row number)&#34;,&#34;min&#34;:1,&#34;max&#34;:12,&#34;step&#34;:1,&#34;value&#34;:4}],&#34;data&#34;:{&#34;columns&#34;:[&#34;model&#34;,&#34;total_b&#34;,&#34;active_b&#34;,&#34;layers&#34;,&#34;kv_heads&#34;,&#34;head_dim&#34;],&#34;rows&#34;:[[1,0.6,0.6,28,8,128],[2,1.7,1.7,28,8,128],[3,4,4,36,8,128],[4,8.2,8.2,36,8,128],[5,14.8,14.8,40,8,128],[6,32.8,32.8,64,8,128],[7,30.5,3.3,48,4,128],[8,235,22,94,4,128],[9,480,35,62,8,128],[10,8,8,32,8,128],[11,70,70,80,8,128],[12,405,405,126,8,128]],&#34;note&#34;:&#34;1-6 Qwen3 0.6B, 1.7B, 4B, 8B, 14B, 32B; 7-9 Qwen3 MoE 30B-A3B, 235B-A22B, Coder-480B-A35B; 10-12 Llama 3 8B, 70B, 405B. Billions of parameters; shapes from Qwen model cards and configs and Llama 3 paper Table 3.&#34;},&#34;row&#34;:[{&#34;id&#34;:&#34;wres&#34;,&#34;label&#34;:&#34;weights GB&#34;,&#34;expr&#34;:&#34;total_b*wbytes&#34;,&#34;tex&#34;:&#34;W = P_{\\text{total}} \\times b_w&#34;},{&#34;id&#34;:&#34;wread&#34;,&#34;label&#34;:&#34;weights read per step GB&#34;,&#34;expr&#34;:&#34;total_b*(1 - (1 - active_b/total_b)^batch)*wbytes&#34;,&#34;tex&#34;:&#34;W_{\\text{read}} = P_{\\text{total}}\\Big[1 - \\big(1 - \\tfrac{P_{\\text{act}}}{P_{\\text{total}}}\\big)^{B}\\Big] b_w&#34;,&#34;note&#34;:&#34;dense models read every weight; an MoE reads only the experts its B tokens touch&#34;},{&#34;id&#34;:&#34;kvmb&#34;,&#34;label&#34;:&#34;KV MB per token&#34;,&#34;expr&#34;:&#34;2*layers*kv_heads*head_dim*kvb/1e6&#34;,&#34;tex&#34;:&#34;kv = 2 \\cdot L \\cdot H_{kv} \\cdot d_h \\cdot b_{kv}&#34;},{&#34;id&#34;:&#34;kvgb&#34;,&#34;label&#34;:&#34;KV cache GB&#34;,&#34;expr&#34;:&#34;batch*ctx*kvmb/1000&#34;,&#34;tex&#34;:&#34;K = B \\cdot S \\cdot kv&#34;},{&#34;id&#34;:&#34;gpus&#34;,&#34;label&#34;:&#34;GPUs needed&#34;,&#34;expr&#34;:&#34;ceil((wres + kvgb)/hbm)&#34;,&#34;fmt&#34;:&#34;i&#34;,&#34;tex&#34;:&#34;G = \\Big\\lceil \\frac{W + K}{M_{\\text{GPU}}} \\Big\\rceil&#34;},{&#34;id&#34;:&#34;tmem&#34;,&#34;label&#34;:&#34;memory time ms&#34;,&#34;expr&#34;:&#34;(wread + kvgb)/(gpus*bw*1000)*1000&#34;,&#34;tex&#34;:&#34;t_{\\text{mem}} = \\frac{W_{\\text{read}} + K}{G \\cdot BW}&#34;},{&#34;id&#34;:&#34;tcomp&#34;,&#34;label&#34;:&#34;compute time ms&#34;,&#34;expr&#34;:&#34;batch*2*active_b/(gpus*peak*1000)*1000&#34;,&#34;tex&#34;:&#34;t_{\\text{comp}} = \\frac{2 \\cdot P_{\\text{act}} \\cdot B}{G \\cdot F}&#34;},{&#34;id&#34;:&#34;tpsu&#34;,&#34;label&#34;:&#34;tokens/s per user&#34;,&#34;expr&#34;:&#34;1000/max(tmem, tcomp)&#34;,&#34;tex&#34;:&#34;\\text{tok/s per user} = \\frac{1}{\\max(t_{\\text{mem}}, t_{\\text{comp}})}&#34;},{&#34;id&#34;:&#34;tpg&#34;,&#34;label&#34;:&#34;tokens/s per GPU&#34;,&#34;expr&#34;:&#34;batch*tpsu/gpus&#34;,&#34;tex&#34;:&#34;\\text{tok/s per GPU} = \\frac{B}{G\\,\\max(t_{\\text{mem}}, t_{\\text{comp}})}&#34;},{&#34;id&#34;:&#34;sel&#34;,&#34;label&#34;:&#34;chart model&#34;,&#34;expr&#34;:&#34;gt(0.5, abs(model - pick))&#34;,&#34;hide&#34;:true}],&#34;derived&#34;:[{&#34;id&#34;:&#34;pt&#34;,&#34;label&#34;:&#34;Total parameters (B)&#34;,&#34;expr&#34;:&#34;dot(sel, total_b)&#34;,&#34;hide&#34;:true},{&#34;id&#34;:&#34;pa&#34;,&#34;label&#34;:&#34;Active parameters (B)&#34;,&#34;expr&#34;:&#34;dot(sel, active_b)&#34;,&#34;hide&#34;:true},{&#34;id&#34;:&#34;pkv&#34;,&#34;label&#34;:&#34;KV cache per token (MB)&#34;,&#34;expr&#34;:&#34;dot(sel, kvmb)&#34;},{&#34;id&#34;:&#34;pwr&#34;,&#34;label&#34;:&#34;Weights read per step (GB)&#34;,&#34;expr&#34;:&#34;dot(sel, wread)&#34;},{&#34;id&#34;:&#34;pkvg&#34;,&#34;label&#34;:&#34;KV cache of the batch (GB)&#34;,&#34;expr&#34;:&#34;dot(sel, kvgb)&#34;},{&#34;id&#34;:&#34;pg&#34;,&#34;label&#34;:&#34;GPUs needed&#34;,&#34;expr&#34;:&#34;dot(sel, gpus)&#34;,&#34;fmt&#34;:&#34;i&#34;},{&#34;id&#34;:&#34;pmem&#34;,&#34;label&#34;:&#34;Memory time per step (ms)&#34;,&#34;expr&#34;:&#34;dot(sel, tmem)&#34;},{&#34;id&#34;:&#34;pcomp&#34;,&#34;label&#34;:&#34;Compute time per step (ms)&#34;,&#34;expr&#34;:&#34;dot(sel, tcomp)&#34;},{&#34;id&#34;:&#34;ptpsu&#34;,&#34;label&#34;:&#34;Tokens/s per user&#34;,&#34;expr&#34;:&#34;dot(sel, tpsu)&#34;},{&#34;id&#34;:&#34;ptpg&#34;,&#34;label&#34;:&#34;Tokens/s per GPU&#34;,&#34;expr&#34;:&#34;dot(sel, tpg)&#34;},{&#34;id&#34;:&#34;ai&#34;,&#34;label&#34;:&#34;Arithmetic intensity (FLOP/byte)&#34;,&#34;expr&#34;:&#34;batch*2*pa/(pwr + pkvg)&#34;,&#34;tex&#34;:&#34;I = \\frac{2 \\cdot P_{\\text{act}} \\cdot B}{W_{\\text{read}} + K}&#34;},{&#34;id&#34;:&#34;ridge&#34;,&#34;label&#34;:&#34;GPU ridge point (FLOP/byte)&#34;,&#34;expr&#34;:&#34;peak/bw&#34;,&#34;tex&#34;:&#34;I^{*} = \\frac{F}{BW}&#34;,&#34;note&#34;:&#34;below this intensity the GPU waits on memory&#34;},{&#34;id&#34;:&#34;kvceil&#34;,&#34;label&#34;:&#34;KV-cache ceiling (tokens/s per GPU)&#34;,&#34;expr&#34;:&#34;bw*1e6/(ctx*pkv)&#34;,&#34;tex&#34;:&#34;\\lim_{B\\to\\infty} \\text{tok/s per GPU} = \\frac{BW}{S \\cdot kv}&#34;}],&#34;chart&#34;:{&#34;title&#34;:&#34;Tokens per second per GPU against batch size, for the chosen model&#34;,&#34;x&#34;:{&#34;var&#34;:&#34;q&#34;,&#34;label&#34;:&#34;Batch size (sequences)&#34;,&#34;from&#34;:1,&#34;to&#34;:256},&#34;series&#34;:[{&#34;label&#34;:&#34;Tokens/s per GPU&#34;,&#34;expr&#34;:&#34;min(q*bw*1e6/(pt*(1 - (1 - pa/pt)^q)*wbytes*1000 + q*ctx*pkv), peak*1000/(2*pa))&#34;},{&#34;label&#34;:&#34;KV-cache ceiling&#34;,&#34;expr&#34;:&#34;bw*1e6/(ctx*pkv)&#34;,&#34;dash&#34;:true}],&#34;mark&#34;:&#34;batch&#34;},&#34;level&#34;:&#34;advanced&#34;,&#34;bars&#34;:{&#34;title&#34;:&#34;Tokens per second each user sees, by model&#34;,&#34;y&#34;:&#34;tpsu&#34;,&#34;label&#34;:&#34;model&#34;},&#34;steps&#34;:[{&#34;title&#34;:&#34;Count the bytes per step&#34;,&#34;text&#34;:&#34;Each decoding step reads the weights the batch needs ({pwr} GB for the chosen model) plus the KV cache of every sequence ({pkvg} GB at {pkv} MB per token).&#34;,&#34;show&#34;:[&#34;pwr&#34;,&#34;pkvg&#34;,&#34;pkv&#34;]},{&#34;title&#34;:&#34;Fit it in memory&#34;,&#34;text&#34;:&#34;Weights plus cache need {pg} GPU(s) of {hbm} GB. Their bandwidth and compute add up under ideal tensor parallelism.&#34;,&#34;show&#34;:[&#34;pg&#34;]},{&#34;title&#34;:&#34;Time the memory reads&#34;,&#34;text&#34;:&#34;At {bw} TB/s per GPU the reads take {pmem} ms per step.&#34;,&#34;show&#34;:[&#34;pmem&#34;]},{&#34;title&#34;:&#34;Time the arithmetic&#34;,&#34;text&#34;:&#34;Each token costs about 2 FLOPs per active parameter: {pcomp} ms per step at {peak} TFLOPS.&#34;,&#34;show&#34;:[&#34;pcomp&#34;]},{&#34;title&#34;:&#34;Take the slower one&#34;,&#34;text&#34;:&#34;Arithmetic intensity is {ai} FLOP/byte against the GPU&#39;s ridge point of {ridge}: below the ridge, memory sets the pace. Each user sees {ptpsu} tokens/s; each GPU produces {ptpg}.&#34;,&#34;show&#34;:[&#34;ai&#34;,&#34;ridge&#34;,&#34;ptpsu&#34;,&#34;ptpg&#34;]},{&#34;title&#34;:&#34;Find the ceiling&#34;,&#34;text&#34;:&#34;Bigger batches share the weight reads, but the KV cache grows with every sequence: per-GPU throughput can never pass {kvceil} tokens/s at this context length.&#34;,&#34;show&#34;:[&#34;kvceil&#34;]}]}"><p>Interactive simulation. It needs JavaScript; the text below explains what it shows.</p></div>

## What you are looking at

Each row is a real open-weight model: six dense Qwen3 models from 0.6B to 32B parameters, three Qwen3 mixture-of-experts models (30B-A3B, 235B-A22B and Coder-480B-A35B), and the three Llama 3 sizes, 8B, 70B and 405B. For each you have total and active parameters, the number of layers, the number of key-value heads and the head size, taken from the model cards and configs.

The sliders describe the hardware and the workload. The defaults are an NVIDIA H100 SXM: 80 GB of memory, 3.35 TB/s of bandwidth and 989 dense BF16 teraFLOPS (NVIDIA's headline 1,979 assumes sparsity). For every model the simulation computes how many GPUs are needed, how long one decoding step takes, and how many tokens per second each user and each GPU get. The bars compare the per-user speed of all twelve models; the chart follows the chosen model as the batch grows.

## The algorithm

Generating a token is one forward pass for every sequence in the batch. Two costs compete:

1. **Bytes.** The step must read the weights from memory: W = parameters × bytes per weight. A dense model reads them all. A mixture-of-experts model reads only the experts its tokens are routed to; with B tokens each touching a fraction a = active/total of the weights, roughly a share 1 − (1 − a)^B is read.
2. **KV cache.** Each sequence keeps keys and values for every past token: 2 × layers × KV heads × head size × bytes per value, per token. The step reads all of it: K = batch × context × that size.
3. **Capacity.** Weights plus cache must fit, so the model needs G = ⌈(W + K) / 80 GB⌉ GPUs. Under ideal tensor parallelism their bandwidth and FLOPs add up.
4. **Memory time** t_mem = bytes read / (G × bandwidth). **Compute time** t_comp = 2 × active parameters × batch / (G × FLOPS), since a token costs about two FLOPs per active parameter.
5. The step takes the larger of the two. Each user gets 1 / step tokens per second; the GPUs together produce batch / step.

The ratio that decides the regime is arithmetic intensity, FLOPs per byte read. An H100 does 989 / 3.35 = 295 FLOPs in the time it reads one byte. Decoding at batch 1 does about one FLOP per byte, hundreds of times too few to keep the arithmetic units busy.

**Worked example.** Qwen3-8B in BF16, batch 16, 8,192 tokens of context. KV cache per token: 2 × 36 layers × 8 heads × 128 × 2 bytes = 147,456 bytes, 0.147 MB. For the batch that is 16 × 8,192 × 0.147 MB = 19.33 GB, more than the 16.4 GB of weights. Total 35.7 GB fits on one GPU. Reading it takes 35.7 / 3,350 GB/s = 10.67 ms, while the arithmetic takes 16 × 2 × 8.2 × 10⁹ / 989 × 10¹² = 0.265 ms. The step is memory-bound by a factor of 40: arithmetic intensity is 7.3 FLOPs per byte against the ridge point of 295. Each user sees 1 / 10.67 ms = 93.8 tokens per second and the GPU produces 1,500. However big the batch, per-GPU throughput cannot pass 3,350 GB/s ÷ (8,192 × 0.147 MB) = 2,773 tokens per second, because every sequence brings its own cache.

## Things to try

- Set the batch to 1: one user gets 190 tokens per second, but the GPU produces only 190. Raise it to 128 and each GPU makes 2,507 tokens per second (the model now needs 3 GPUs for the cache), while each user drops to 58.8.
- Switch weights to FP8 (1 byte): per-GPU throughput rises from 1,500 to 1,947. Then put the KV cache in FP8 too, with weights back at 2 bytes: 2,057 tokens per second and the ceiling doubles to 5,547.
- Raise the context to 32,768 tokens: the cache needs 2 GPUs, per-GPU throughput falls to 572 and the ceiling to 693. Long context is a memory problem.
- Pick model 7, Qwen3-30B-A3B. At batch 1 it reads only 6.6 GB a step and one user gets 452 tokens per second, faster than the dense 8B. At batch 16 the tokens touch most experts, it reads 51.2 GB, and each user drops to 52.2.
- Pick model 12, Llama 3 405B: 11 GPUs, 42 tokens per second per user and only 61 per GPU.
- Make decoding compute-bound: pick model 11 (Llama 3 70B), set weights to 4-bit, context to 512 and batch to 256. Compute time (36.2 ms) now exceeds memory time (23.3 ms) and one GPU produces 7,064 tokens per second. It takes many short sequences and few bytes per weight to get there.

## How it works in real systems

This is why the main inference optimisations are about bytes, not FLOPs. Grouped-query attention cuts the number of KV heads (all these models use 4 or 8 instead of one per query head), see the [KV cache simulation](/ai-simulations/kv-cache). Weight and cache [quantization](/ai-simulations/quantization) halves or quarters the bytes. Paged attention lets servers such as vLLM pack more sequences into memory, and continuous batching keeps the batch full. [Speculative decoding](/ai-simulations/speculative-decoding) spends spare compute to verify several tokens per weight read, and [mixture-of-experts](/ai-simulations/mixture-of-experts) models activate only a fraction of their parameters per token.

The simple model leaves things out: prefill (processing the prompt) is compute-bound, attention FLOPs grow with context, real kernels reach only part of peak bandwidth, tensor parallelism adds communication, and the MoE formula assumes tokens choose experts independently. Treat the numbers as upper bounds and ratios, not benchmarks. The ranking they produce still matches practice: memory bandwidth, cache size and batch size decide how fast a model talks.

## Sources

- [NVIDIA H100 Tensor Core GPU specifications](https://www.nvidia.com/en-us/data-center/h100/)
- [Qwen3-8B model card](https://huggingface.co/Qwen/Qwen3-8B)
- [Qwen3-30B-A3B model card](https://huggingface.co/Qwen/Qwen3-30B-A3B)
- [The Llama 3 Herd of Models (Table 3)](https://arxiv.org/html/2407.21783v3)
- [How to Scale Your Model: inference chapter](https://jax-ml.github.io/scaling-book/inference/)
