Part V Serve at scale¶
Requests arrive at a router, which picks a slice for each one. Every slice keeps a cache of the conversations it is serving, the teal stacks, and streams tokens back one at a time. Part V is about what each of those pieces costs: the chips' time per token, the cache's HBM, and the router's choice of where a request should go.
Part IV ended with a trained model. Part V serves it. Training cared about one number, throughput per chip; serving adds latency per user, and the two pull against each other. A request is processed in two phases with opposite bottlenecks: prefill pushes the whole prompt through the model at once and is limited by the MXUs, while decode produces one token per step and is limited by how fast HBM can stream the weights and the KV cache. Every serving engine, flag and routing policy in this Part exists to manage that difference.
TorchTPU keeps the PyTorch serving stacks you already know. vLLM-TorchTPU and SGLang-TorchTPU are platform plugins underneath unmodified upstream engines: the scheduler, the KV cache manager and the OpenAI-compatible server are the same code that runs on GPUs, and the model runs under torch.compile(backend="tpu") with Pallas kernels for attention, MoE and quantized matmuls. llm-d 1.0 then spreads those engines over a GKE cluster and routes each request to the replica best placed to serve it. Each chapter ends with a check that ties a measured latency or throughput back to the arithmetic of chapter 17.
The chapters¶
| Chapter | Summary | Reading time (min) |
|---|---|---|
| 17. Inference math: prefill, decode, KV cache | Why prefill is compute-bound and decode memory-bound, how large the KV cache is, and the fastest a token can be produced. | 35 |
| 18. vLLM-TorchTPU | Serving a model with vLLM on TPU: parallelism layout, quantization, speculative decoding and benchmarking. | 40 |
| 19. SGLang-TorchTPU | Serving the same model with SGLang, and when its prefix sharing pays off. | 35 |
| 20. llm-d 1.0 on GKE: routing, disaggregation, KV management | Routing requests to the replica that holds their prefix, splitting prefill from decode, and moving KV caches between pools. | 50 |
| 21. Operating llm-d: autoscaling, rollouts, observability | Scaling, updating and watching a serving fleet, and reading its metrics to find what limits it. | 45 |
| 22. Case study: Muse Glimmer 30B inference | A real 30B decode loop on Ironwood: what it measures, and how close it comes to what the hardware allows. | 30 |
Read end to end, Part V takes about four hours, plus the time to bring up a server and a cluster.
What links them¶
Chapter 17 gives the arithmetic for the rest of the Part. It counts a transformer's parameters and FLOPs, applies the roofline of chapter 2 to prefill and to decode separately, and derives the size of the KV cache from a model's layers, KV heads and head dimension. From those it gets a floor for time to first token and for time per output token, the batch size at which decode stops being memory-bound, and how many sequences fit in what HBM is left after the weights. Continuous batching, paged KV caches, speculative decoding, quantization and tensor parallelism all appear here first, as answers to that arithmetic.
Chapters 18 and 19 apply it with two engines. Both pad every step to a precompiled shape, the fixed-shape discipline of chapter 7, keep the KV cache in pages read by a ragged paged attention kernel, and expose the same kinds of choices: a parallelism layout, an fp8 KV cache, and several speculative decoding methods. Chapter 18 is the reference path; chapter 19 shows what SGLang does differently, in particular RadixAttention's sharing of cached prefixes between requests.
Chapters 20 and 21 move from one engine to a fleet. Chapter 17 shows why prefill and decode want different hardware layouts and why a long prefill stalls the decodes beside it; llm-d's answer is to disaggregate them into separate pools, move the KV cache between them, and route each request by where its prefix is already cached. Chapter 20 explains the router, the disaggregation path and KV cache management; chapter 21 runs them, with autoscaling on the router's signals, rollouts and the metrics that show saturation.
Chapter 22 studies a complete example. The Muse Glimmer 30B decode loop on one v7x chip is the measurement chapter 17 uses to check its decode floor. Chapter 22 takes the whole example apart: its static KV cache, its compile behaviour and its per-token latency against the hardware's limits.
Chapter 17 is a prerequisite of every other chapter in this Part, so its arrows share one line. Read 18, 19, 20 and 21 in order; chapter 22 needs only 17 and 18, so you can take it straight after chapter 18.
Chapter 17 builds directly on chapter 2's ridge points, on chapter 7 (static KV caches and padding to buckets) and on chapter 13 (the cost of the all-reduces that tensor parallelism adds to every layer). Every later chapter in this Part uses chapter 17's arithmetic. Chapter 19 assumes chapter 18's engine vocabulary, and chapter 20 needs chapter 19's radix cache to explain why routing must follow the cache, so read 18, 19 and 20 in order. Chapter 22 needs only chapters 17 and 18, so you can read it straight after chapter 18.
What this Part covers¶
- The KV cache per token, the decode floor for a batch, the prefill floor for a prompt and the largest batch that fits, from a model's configuration and a TPU.
- Whether a serving step is compute-bound or memory-bound, and which lever (batch, quantization, speculative decoding, tensor parallelism) moves it.
- Serving with vLLM-TorchTPU or SGLang-TorchTPU: the parallelism layout, the KV cache dtype, warming up the compiled shapes, and measuring TTFT and TPOT.
- How llm-d routes a request, when it disaggregates prefill from decode and how a KV cache moves between pools, and deploying and scaling it on GKE.
- Recomputing the floor of a published serving result from the model and the hardware, and how close the measurement comes to it.
Part VI turns to trust: parity gates that prove the numbers are right, and benchmarks that prove the speed.

