Özer Cem KELAHMETKELAHMET
AI Simulations · Language models

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.

Download Markdown

Interactive simulation. It needs JavaScript; the text below explains what it shows.

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. Weight and cache 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 spends spare compute to verify several tokens per weight read, and 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

Last updated Nov 25, 2026
Type to search.
    ↑↓ navigate↵ open