LLM Inference Explained
How a model actually generates text, one token at a time.
An interactive guide to how real systems serve language models, from the KV cache to disaggregated serving.
New to transformers? First, how one forward pass works
Animated · driven by the model
The same requests, colocated or split
Llama-3-70B on eight H100s, the first 8 of 200 requests, simulated by Disaggregated_Inference_Sim (commit ac1846a).
t = 0.00 s. Colocated: 0 of 8 done, 0 decode stalls so far. Disaggregated: 0 of 8 done, 0 stalls.
When this is on screen, your browser re-runs all 200 requests with the same engine.
How this is checkedThe serving simulator in chapters 11–14 is Disaggregated_Inference_Sim's own engine, copied byte for byte from a pinned commit, and CI requires every request's timestamps to match its Python original; the tiny model's cached logits are bit-identical to full recomputation. How it is tested →
What you'll learn
A forward pass makes one prediction. Serving a model means running that pass thousands of times a second for many users at once. These chapters cover what real inference systems do about it: the KV cache, the roofline, batching, paged memory, FlashAttention, speculative decoding, quantisation, parallelism, the metrics that judge them, and disaggregated prefill and decode, with a live simulator. Every interactive runs tested code in your browser.
Chapters
Fourteen chapters, from the generation loop to disaggregated serving. Toggle the Concept, Maths and Code layers to choose your depth.
See the chapters →
The KV cache, live
A real tiny decoder generating in your browser, its cache filling column by column, checked against recomputation at every step.
Watch it fill →
The roofline
Why decode waits on memory and prefill on arithmetic, with H100 and A100 figures from a tested simulator.
Open the roofline →
New to the Inference track? Start here: the four sites in reading order, what you need first, and a glossary of the terms they define.
The companion sites: the Transformer Decoder Explainer walks through the forward pass itself, LLM Architectures Explained shows how real models’ designs differ, GPU Kernels Explained shows how a GPU executes the maths, Numerics Explained shows the number formats and quantisation behind it, Systolic Arrays Explained shows the matrix hardware of TPUs, and Inference Trade-offs Explained measures which serving lever helps which metric. The source of this one is on GitHub.