Inference track
Start here: serving a model, and what it costs
Four sites, one question: what does it take to serve a large language model well? Serving follows one request from prompt to answer and through a serving cluster; Architectures shows how modern models change what is served; Numerics covers the number formats that make it cheaper; Trade-offs measures every lever on the same workloads. Read them in order: each assumes the one before.
Reading order for the Inference track
Each site's chapters build on each other; start at chapter 1 of Serving. Every number is computed by the site's tested model or recorded by its simulator.
- 1Serving (this site): how a model is served: the generation loop, the KV cache, the roofline, batching, paging, kernels, speculation, quantisation, parallelism and disaggregation; assumes the Foundations track.
- 2Architectures: how modern models differ from the textbook decoder (attention variants, RoPE, norms, MoE, long context, MTP, CED) and what each costs to serve; assumes Serving's KV cache and roofline.
- 3Numerics: the number formats under it all, from bits and rounding to quantisation, outliers, GPTQ, AWQ and NF4, the KV cache and hardware; assumes Serving's quantisation chapter.
- 4Trade-offs: every serving lever measured on five workloads against goodput, latency, cost and energy, one chapter per lever; assumes the three before it.
What you need first
- How a transformer decoder works. Tokens, attention with its keys and values, the feed-forward block and sampling. The Foundations track (Decoder and Training) covers it.
- Latency and throughput. The difference between how long one request waits and how many requests are served a second, and why percentiles say more than averages.
- A little about GPUs. That memory bandwidth and arithmetic are separate limits. The Hardware track goes deep; Serving’s roofline chapter is enough to start.
- Reading code is optional. The Code layer shows the TypeScript that runs, and the simulator decks’ glossary defines the serving terms again; hide the code with the layer switch.
How a chapter works
A chapter opens with an animation of its mechanism, computed by the site’s tested model, then explains it in three layers you can switch on and off: Concept (words and pictures), Maths (the formulas) and Code (the code that runs). It ends with Check yourself, three questions to commit to before you reveal the answers (the numbers come from the same model), and What to remember, the chapter in a few lines.
Glossary
Each term links to the section that defines it, on the site that defines it. Some terms mean different things on different sites (goodput, ρ, the pipeline bubble); the shared definitions give each one definition and one formula, and say where a site differs.
- Prefill, decode
- one pass over the whole prompt, then one pass per output token
- KV cache
- every earlier token's keys and values, kept so decode steps need not recompute them
- GQA, MQA, MLA
- sharing or compressing key/value heads to shrink the cache
- Roofline, arithmetic intensity, ridge point
- a step takes the longer of its arithmetic and its memory time; the ridge is where they balance
- Memory-bound decode
- a batch-1 decode step reads every weight to make one token
- Continuous batching
- scheduling every step, so a finished sequence's slot is reused at once
- Chunked prefill
- a per-step token budget: decodes first, then a slice of a prompt
- PagedAttention, prefix sharing
- KV memory in fixed-size blocks with a block table per sequence
- FlashAttention, online softmax
- tiled attention that never writes the score matrix
- Speculative decoding
- a draft guesses tokens; one target pass checks them all
- Weight and KV quantisation
- fewer bytes per step: weights only, weights and activations, or the cache
- Tensor, pipeline and expert parallelism
- splitting a model over GPUs, and the messages each split adds
- TTFT, TPOT, ITL
- time to first token, time per output token, every inter-token gap
- Goodput
- requests per second that met both latency targets
- Little's law
- requests in the system = arrival rate × time in the system
- Disaggregated serving
- prefill and decode on separate GPU pools
- KV hand-off
- each prompt's cache crossing the link from the prefill to the decode pool
- Sliding window, sparse and linear attention
- token mixers that read or keep less than the whole cache
- RoPE and its base θ
- rotating query-key pairs so scores depend only on distance
- Pre-norm, post-LN, QK-norm
- where the normalisation sits on the residual stream
- Mixture of experts
- many expert FFNs and a router: total and active parameters come apart
- Depth and width
- the cache and attention's share grow with depth, embeddings with width
- Long-context cost
- with full attention every token adds cache and reads all of it
- Multi-token prediction
- extra heads that predict further ahead, and draft at inference
- Causal encoder-decoder (CED)
- prompt tokens run only the encoder half: cheaper prefill
- Floating-point format, binade
- sign, exponent and mantissa; relative precision about constant
- Round to nearest, stochastic rounding
- the default rounding and the one that is exact on average
- Accumulation, Kahan summation
- why long sums stall in low precision, and the fixes
- FP8, MX formats
- narrow formats, and blocks of elements sharing a scale
- Absmax, zero point, group size
- integer quantisation with a scale per group
- Outliers, LLM.int8(), SmoothQuant
- a few huge activation channels, and two ways around them
- GPTQ
- quantise column by column, compensating the error in the rest
- AWQ, NF4
- protecting the weights large activations meet; codes at normal quantiles
- KV-cache quantisation
- fewer bits per cached key and value
- Narrow numbers in hardware
- what bits cost to store, move and multiply
- Batching policy
- prefill-priority, decode-priority or chunked prefill, measured
- Prefix caching
- compute a shared prompt prefix once
- The pool split
- what disaggregation does to goodput, measured on five workloads
- Combining levers
- why levers compound, and where they do not