The Three Budgets
Roofline, arithmetic intensity, and the one ratio that explains why decoding and training feel like different machines.
Memory, compute, and bandwidth are the only three budgets there are. Every technique for training and serving large language models — checkpointing, flash attention, GQA, quantization, ZeRO, tensor and pipeline parallelism, speculative decoding — spends one to buy back another. This is that ledger, derived rather than listed.
Built on the outline of Gauri Gupta's LLM optimization notes — an excellent index of this material that this book tries to add depth to. Every technical claim here is written from the primary sources, cited throughout.
Roofline, arithmetic intensity, and the one ratio that explains why decoding and training feel like different machines.
Parameters, gradients, optimizer state, activations — and why an 8B model needs 128 GB before it stores a single activation.
The autograd tape, sublinear memory, and why selective recompute beats the full version by an order of magnitude.
Derive online softmax first and tiling falls out of it. An exact algorithm, not an approximation.
MHA, MQA, GQA, MLA, paged attention, prefix caching — one problem and six responses to it.
Bit layouts, emergent outliers, GPTQ, AWQ, SmoothQuant, and training through a non-differentiable rounding step.
Ring all-reduce from first principles, then ZeRO's three stages accounted in both memory and network traffic.
Why Megatron splits column-then-row, what sequence parallelism buys, and why this never leaves the node.
The bubble, derived. GPipe versus 1F1B, weight staleness, zero-bubble schedules, and what Llama 3 actually changed.
Splitting the sequence, splitting the FFN — ring attention, routing, capacity factors, and load balance.
How DP, TP, PP, CP, and EP actually compose on a real cluster, and how to pick the layout.
Continuous batching, chunked prefill, disaggregation, and why speculative decoding is provably lossless.
An honest postmortem on efficient-attention research, plus the full bibliography.