Imagine a chat product built on a 70-billion-parameter model. A user pastes in a long document, about 8,192 tokens, and asks a question about it. A couple of seconds later the first word of the answer appears, and the rest streams out at a steady pace. We'll follow that one request through the chapter, and the prompt will stay 8,192 tokens long the whole way so the numbers are easy to compare.
Page 31 explained what happens to that request on a single GPU server. The engine first runs prefill, one parallel pass over the whole prompt that builds the KV cache, the saved keys and values of every earlier token, so later steps don't have to recompute them. Then it runs decode, which produces one token at a time and re-reads the weights and the cache at every step. That page also gave us four numbers for judging a server: time to first token (TTFT), the gap between consecutive tokens (inter-token latency, or ITL), throughput (tokens per second across all users), and goodput (throughput that counts only the requests that met their latency target). Everything in it, continuous batching included, is about getting the most out of one machine.
A real service gets thousands of such requests a minute, and no single machine can hold that load, so the unit we reason about stops being a GPU and becomes a fleet of them. That raises three questions page 31 had no reason to ask. Where should the two phases run, given that they want opposite things from a GPU? How many bits should each stored number use, now that bytes are both the memory bill and the network bill? And how can hundreds of customer-specific variants of a model, or a model split into hundreds of experts, share the same hardware? Those are the questions of placement, precision and sharing.
One small calculation ties the answers together. Each token leaves behind some number of bytes of KV cache, and producing it cost some amount of compute. Dividing the first by the second gives a bandwidth, the link speed at which shipping the cache costs the same as recomputing it. We'll call it the break-even bandwidth, derive it in section 02, and use it again in section 03. If you need one sentence for an interview, it's this: at fleet scale you stop tuning a server and start deciding which bytes move, how wide they are, and who they belong to.
01What changes when the unit is a fleet
Let's start from where page 31 left off. Continuous batching lets requests join and leave the batch at every step, so the GPU never waits for the slowest request to finish. Chunked prefill cuts a long prompt into pieces, so decode steps for other users can slip in between the pieces. Both interleave the two phases so that neither starves the other, and inside a single engine that's about the best you can do.
Even so, the two phases still share one device. When our 8,192-token prompt arrives, its prefill needs the GPU's streaming multiprocessors (SMs, the units that do the matrix arithmetic), its HBM bandwidth (high-bandwidth memory, where the weights and the cache live), and room in the pool of memory blocks that holds the KV cache. Everyone else's decode steps need those same three things. Chunking makes each piece of interference smaller and more even, but it can't remove it, because a prefill chunk and a decode step still run on the same hardware.
So the move at fleet scale is to stop sharing. We give prefill its own GPUs, give decode its own GPUs, and pay a transfer cost to carry the KV cache from the first group to the second. Each pool can then be sized, sharded and batched for its own phase. Both layouts are drawn below, and the bottom row holds costs that we'll derive in the next section.
Read that bottom row carefully, because it says the transfer isn't a fixed tax. It's a fraction of the prefill that produced it, and the link between the pools decides the size of that fraction. Three more things change once you have a fleet, and each gets its own section. Bytes become the budget, since weights and cache can be stored in 8 or 4 bits, and that changes both what fits and what moves. One model has to serve many jobs, which means hundreds of adapters on one base or hundreds of experts across many GPUs. And throughput stops being the target, because a fleet is provisioned against a latency contract. That contract is called a service-level objective (SLO), for example "first token within 2 seconds and each later token within 25 milliseconds", and the metric that respects it is goodput. First, though, the question the diagram raises: when is that wire cheap enough to be worth it?
02Prefill/decode disaggregation, and where the crossover is
Splitting the phases is attractive for two reasons that reinforce each other. Besides contending for the same GPU, the phases want different machines. Prefill is compute-bound (the arithmetic units are the limit) and latency-sensitive, so it prefers wide tensor parallelism, where each weight matrix is cut across several GPUs that all work on one prompt, together with small batches. Decode is bandwidth-bound (reading memory is the limit), so it prefers the largest batch the KV pool will hold. A single pool has to pick one configuration for both, while two pools can each be tuned for their own phase, and the prefill-to-decode GPU ratio can follow the traffic.
Published results agree that the win can be large. DistServe reports serving "7.4x more requests or 12.6x tighter SLO" than the systems it compared against, while staying inside the latency constraints for over 90% of requests. Splitwise reports "1.4x higher throughput at 20% lower cost", or "2.35x more throughput with the same cost and power budgets". At production scale, Moonshot's Mooncake describes a KV-cache-centric disaggregated architecture and reports that it "enables Kimi to handle 75% more requests" under real workloads, and NVIDIA's Dynamo packages the same idea as an orchestration layer above vLLM, SGLang and TensorRT-LLM.
Before reaching for any of this, read vLLM's own caveat. Its documentation states plainly that "Disaggregated prefill DOES NOT improve throughput", and it marks the feature experimental. What splitting buys is separate control over TTFT and inter-token latency, and it doesn't manufacture any extra FLOPs. If your problem is cost per million tokens and not a latency contract, a bigger batch is the right tool and disaggregation is the wrong one.
The cost, derived
Prefill produces a KV cache and decode consumes it, so splitting the phases means the cache has to cross a wire. How big is it? That size is fixed by the architecture. For every token, every layer stores one key vector and one vector of values for each KV head. Modern models use grouped-query attention (GQA), where several query heads share one KV head, so the number of KV heads is much smaller than the number of attention heads. Multiplying it all out gives the bytes per token:
The leading 2 is for K and V, is the length of each head's vector, and is bytes per element, so 2 in FP16 and 1 in FP8 (an 8-bit floating-point format, covered in section 05). For our 70B model (80 layers, 8 KV heads, 128 numbers per head, 2 bytes each) that's 2 × 80 × 8 × 128 × 2 = 327,680 bytes, or 320 KiB per token. Our 8,192-token prompt therefore leaves 2.5 GiB of cache behind, and that's what has to cross the wire.
Now we need the cost of making it. Prefill on a prompt of tokens takes roughly floating-point operations, where is the number of parameters active per token (each parameter takes part in one multiply and one add per token). If the pool sustains FLOP/s and the link carries bytes per second, the transfer as a fraction of the prefill is:
Why doesn't the prompt length matter?
Look at the middle expression: appears in both the numerator and the denominator and cancels. Both the cache and the compute grow linearly with the prompt, so a 100,000-token prompt pays the same proportional transfer cost as a 1,000-token one, and that's why disaggregation scales to long prompts. Attention makes prefill grow faster than linearly in , so at very long contexts the ratio improves.
Setting the ratio to 1 gives the link speed at which shipping the cache costs as much as making it:
This is the break-even bandwidth from the opening. It depends on the model and the GPU but not on the workload, so we can compute it once per deployment. The code below does that for three configurations, then prices four real interconnects for our 70B request. NVLink is the fast link between GPUs inside one server, PCIe is the bus between a GPU and the host machine, and InfiniBand and 25 GbE are networks between servers. The code uses an assumed prefill rate F of 4.0e14 FLOP/s, which is a placeholder: yours will differ, and the project at the end of the chapter shows how to measure it. Here kv_per_token is the equation above, and the last loop divides the 2.5 GiB by each link speed and compares that with the prefill time.
Try it Compute the break-even bandwidth, then price four real interconnects against it
import numpy as np
# KV bytes per token = 2 (K and V) x layers x kv_heads x head_dim x dtype
def kv_per_token(layers, kv_heads, head_dim, nbytes):
return 2 * layers * kv_heads * head_dim * nbytes
F = 4.0e14 # assumed achieved prefill rate, FLOP/s. Yours differs.
# name, layers, kv_heads, head_dim, bytes/elem, params active per token
cfgs = [("Llama-3.1-8B ", 32, 8, 128, 2, 8.0e9),
("Llama-3.1-70B", 80, 8, 128, 2, 70.0e9),
("70B, FP8 KV ", 80, 8, 128, 1, 70.0e9)]
print("model KV per token break-even link")
for name, L, h, d, nb, P in cfgs:
c = kv_per_token(L, h, d, nb)
print(f"{name} {c/1024:6.0f} KiB {c*F/(2*P)/1e9:6.2f} GB/s")
c70 = kv_per_token(80, 8, 128, 2)
print("\n70B, an 8k-token prompt: KV =",
round(c70 * 8192 / 2**30, 2), "GiB to move.")
print("shipping it costs this share of the prefill that made it:")
for link, bw in [("NVLink 4, one direction", 450e9),
("PCIe Gen5 x16 ", 64e9),
("InfiniBand NDR 400G ", 50e9),
("25 GbE ", 3.125e9)]:
print(f" {link} {c70*F/(2*70e9*bw)*100:7.1f} %")
0.94 GB/s, and every datacentre interconnect sits one to three orders of magnitude above it. Hence 0.2 % on NVLink and 1.9 % on InfiniBand NDR. At 25 GbE it reads 30.0 %, and disaggregation has stopped being free. The 8B's break-even is higher, 3.28 GB/s, because a small model makes prefill cheap and the same transfer then looks expensive.Start with the break-even column. For the 70B it's 0.94 GB/s, and every datacentre link in the list sits one to three orders of magnitude above that, so the transfer costs 0.2% of the prefill on NVLink and 1.9% on InfiniBand. At 25 GbE it's 30%, and disaggregation has stopped being free. Notice also that the 8B model has a higher break-even, 3.28 GB/s. A small model makes prefill cheap, which makes the same cache look expensive to move. In the FP8 row, halving halves the break-even too.
Link bandwidths come from vendor specifications. NVLink 4 is listed at 900 GB/s total on an H100 SXM, which we've halved to get one direction. PCIe Gen5 x16 is 128 GB/s bidirectional, also halved. InfiniBand NDR is 400 Gb/s per port.
So when does disaggregation stop being worth it? Only the first of four cases is about bandwidth. A slow link is the obvious one, meaning anything within about 10x of . Short prompts are another, because the per-transfer overhead isn't amortised and the prefill was cheap anyway. A small fleet is a third, because two pools of one GPU each can't rebalance, and a shift in traffic strands one of them. Uniform traffic is the last, since if no request is long enough to block anyone, chunked prefill has already solved the problem for free. In other words, disaggregation is the expensive answer to interference and chunked prefill is the cheap one, which page 31 covers. Chunked prefill may still be enough for you, so measure that it has run out before you buy the expensive answer.
Keep the break-even number in mind, because the same cache and the same quantity decide a completely different question next. If a cache is going to sit around, should it stay on the GPU, shrink, or go elsewhere?
03The KV cache: make it narrower, or move it off the GPU
There are two independent ways to shrink the GPU's KV bill. One changes the bytes per token, and the other changes where those bytes live. NVIDIA's inference optimization guide gives the size directly: "Size of KV cache per token in bytes = 2 * (num_layers) * (num_heads * dim_head) * precision_in_bytes". Under grouped-query attention the head count there means the number of KV heads, the from section 02. Three of the four terms are fixed by the architecture, and only the last, the precision, is yours to change.
Quantizing the cache
Quantizing means storing each number in fewer bits, usually with a shared scale factor that stretches the small range of stored values back to the true range. Section 05 looks at the formats closely, so for now it's enough to know that FP8 is an 8-bit floating-point format. vLLM's quantized KV cache supports fp8_e4m3 and fp8_e5m2, which halves compared with FP16. That doubles how many tokens fit in the block pool, and it also halves the break-even bandwidth from section 02.
Below eight bits the cache stops behaving like a generic tensor, because keys and values have different shapes of outliers. KIVI found that the two halves need opposite treatment: "the key cache should be quantized per-channel" while "the value cache should be quantized per-token". Per-channel means one scale for each column of the key matrix, and per-token means one scale for each row of the value matrix. With that asymmetry it reports 2-bit KV at "2.6x less peak memory" and "2.35x ~ 3.47x throughput". KVQuant attacks the same problem from the accuracy side and reports "< 0.1 perplexity degradation with 3-bit quantization" (perplexity measures how surprised a model is by held-out text, and lower is better). It turns that into context length: "serving LLaMA-7B with a context length of up to 1 million on a single A100-80GB GPU".
Be careful with how you read those results. vLLM recommends calibrating FP8 KV scales and not leaving them at 1.0, and it notes that "some attention layer types (e.g. sliding-window) are more sensitive to KV-cache quantization". It publishes no blanket accuracy figure, and you shouldn't assume one either. KV quantization is the one compression on this page whose damage is invisible in a smoke test. It hurts long-context recall first, and a 200-token chat exchange won't show it, so evaluate it at the context length you serve.
Offloading the cache
The second approach leaves the precision alone and moves the bytes to host memory (the CPU's RAM) or NVMe storage. Whether that helps comes down to arithmetic, and there are two completely different cases.
Case one is KV that decode is actively reading. Every decode step reads the whole cache of every request in the batch. Take 32 requests like ours at 8,192 tokens on the 70B, at 320 KiB per token. That's roughly 85.9 GB read for every token generated. Over H100 HBM3 at 3.35 TB/s that read takes 25.6 ms. Over PCIe Gen5 x16 at 64 GB/s it takes 1.34 seconds, a 52x slowdown of the inner loop. That's no tradeoff. It's a different product.
Case two is KV that nobody is reading yet, such as a cached prefix from a previous turn sitting in host RAM. Now the question isn't one memory bus against another. It's whether fetching the cache beats recomputing it, which is exactly the comparison we solved in section 02:
It's the same break-even bandwidth, now answering a question that looks nothing like the first one. For the 70B, was 0.94 GB/s and PCIe Gen5 x16 runs at 64 GB/s, about 68 times higher. Fetching a cached prefix over PCIe is far cheaper than recomputing it, and that's the entire case for KV offload. LMCache productised it. Its paper describes storing KV "out of the GPU memory" and sharing it "across engines and queries", supporting "both cache offloading (prefix reuse across queries) and prefill-decode (PD) disaggregation", and reports "up to 15x improvement in throughput" on workloads like multi-round question answering.
FlexGen is the extreme version of case two:, it aggregates GPU, CPU and disk to run OPT-175B on a single 16 GB GPU at "1 token/s ... with an effective batch size of 144". It's a throughput system for offline work, and its latency is roughly what the arithmetic above predicts. Both cases boil down to a short rule, and it probably deserves to be memorised. Offload KV that will be read once, later, because that's a fetch racing a recompute and it wins comfortably. Don't offload KV that will be read on every step, because that's a memory bus racing a peripheral bus and it loses by a factor of about 50.
So far we've treated the fleet as serving one model. In practice a product often serves a base model plus a long tail of customer-specific versions of it, and that changes what has to be stored.
04Multi-LoRA: hundreds of models, one set of weights
Suppose our chat product sells a fine-tuned version of the model to each of a thousand customers. Giving every customer a private copy of the weights is out of the question, as the numbers below will show, so the only affordable approach is to share the base model and keep each customer's changes separate. Page 29 covers what a LoRA adapter is: instead of changing a large weight matrix, you train two thin matrices whose product is a small correction to it. Serving asks something different. Given a batch of requests where each one wants a different adapter, what does that cost?
Start with memory. A LoRA on a weight of shape adds two matrices, and , where the rank is how thin they are. That's parameters per adapted matrix. To keep the arithmetic small, the code switches from our 70B to Llama-3-8B, adapts its four attention projections (query, key, value and output) in all 32 layers, and counts the bytes. Its second half asks what a decode step pays when the batch contains several distinct adapters, with the base weights being 16.0 GB that every step reads.
Try it What a thousand adapters cost, and what a batch of distinct ones costs per step
import numpy as np
# LoRA on a weight of shape (d_out, d_in) adds A (r, d_in) and
# B (d_out, r): r * (d_in + d_out) new parameters.
def adapter_params(r, shapes):
return sum(r * (d_in + d_out) for d_out, d_in in shapes)
H, KV, LAYERS = 4096, 1024, 32 # Llama-3-8B, 32 q heads, 8 kv
attn = [(H, H), (KV, H), (KV, H), (H, H)] # q, k, v, o
for r in (8, 16, 64):
p = adapter_params(r, attn) * LAYERS
print(f"rank {r:3d}: {p/1e6:6.2f}M params, {p*2/1e6:6.1f} MB in BF16"
f" 1000 of them = {p*2*1000/1e9:6.1f} GB")
print(f"\nbase model in BF16 = {8e9*2/1e9:.0f} GB;"
f" 1000 full fine-tunes = {8e9*2*1000/1e12:.0f} TB")
print("\ndecode step reads 16.0 GB of base weights, plus, for n"
"\nDISTINCT adapters in the batch:")
for r in (16, 64):
mb = adapter_params(r, attn) * LAYERS * 2 / 1e6
for n in (1, 32, 128):
print(f" rank {r:3d}, {n:3d} distinct: {n*mb/1000:6.2f} GB"
f" -> step is {1 + n*mb/16000:5.3f}x longer")
27.3 MB, so a thousand of them take 27.3 GB against 16 TB for a thousand full fine-tunes. In the second table the adapter bytes scale with the number of distinct adapters in the batch and not with the batch size, because a shared adapter is read once. At rank 64 with 128 distinct adapters, the step is 1.872x longer.Why are adapters practical? The first table answers it: a rank-16 adapter is 27.3 MB, so a thousand of them take 27.3 GB, against 16 TB for a thousand full fine-tunes of the 8B. The second table is the one people miss. Adapter bytes read per step scale with the number of distinct adapters in the batch and not with the batch size, because an adapter shared by several requests is read once. At rank 64 with 128 distinct adapters in the batch, the step is 1.872x longer.
That result is the design constraint. One big matrix multiplication on the base path is shared by the entire batch. The LoRA path can't be shared, because each sequence needs its own and gathered and applied. Done naively, that becomes a Python loop over requests, which destroys the batching we worked to build. Punica solved it with a kernel, "Segmented Gather Matrix-Vector Multiplication (SGMV)", which "allows batching GPU operations for the concurrent execution of multiple, different LoRA models". It reports "12x higher throughput ... while only adding 2ms latency per token". S-LoRA added the memory-management half. Its "Unified Paging" puts adapter weights of different ranks and KV tensors of different lengths in one pool. That's PagedAttention generalised to a second kind of variable-size object, and it reports up to 4x throughput over prior LoRA serving.
One more cost catches teams late. vLLM's documentation says to set --max-lora-rank "to the maximum rank among all LoRA adapters you plan to use", and that if your ranks are 16, 32 and 64, you should use --max-lora-rank 64 and not 256. Buffers are sized for the maximum, so one customer who trained at rank 256 makes every other adapter in the fleet pay for it. Rank is a fleet-wide decision, and it has to be capped at training time, because by serving time it's no longer negotiable.
Adapters are small precisely because they're thin. Base weights are the opposite, the largest block of bytes in the whole system, and the way to shrink them is to store each weight in fewer bits.
05FP8 and MXFP4: where the scale factors live
FP8 comes first and is the easy case. In the format paper, two encodings are defined: "E4M3 (4-bit exponent and 3-bit mantissa) and E5M2 (5-bit exponent and 2-bit mantissa)". A floating-point number is stored as a sign, an exponent that sets its rough size, and a mantissa that sets its precision within that size, so E4M3 spends more bits on precision and E5M2 on range. It reports "effectively matching the result quality achieved by 16-bit training sessions". There's a hardware reason to care, and it's on the datasheet. An H100 SXM lists 1,979 TFLOPS for BF16 tensor cores and 3,958 for FP8, both quoted with sparsity and both halved without it. That's exactly 2x, and it comes from the format and not from the silicon generation.
What gets quantized
"The model is in FP8" is three separate decisions with different risk profiles. Weights are static, so they're quantized once, offline. vLLM's llm-compressor FP8 scheme is "static, per-channel quantization on the weights", meaning one scale per output channel, stored alongside them. Activations, the intermediate values computed from each input, have a range that depends on the input, so their scale is computed at runtime. vLLM uses "dynamic, per-token quantization on the activations". Third comes the KV cache from section 03, which has a separate flag and a separate risk, and it's the one that breaks long context first.
TensorRT-LLM's precision reference names the same three granularities: "per-tensor" with a single scaling factor for all elements, "per-token", and "per-channel". Finer granularity costs more storage for scales and buys tolerance to outliers, which are the few values far larger than the rest. That tradeoff is what explains the four-bit formats.
Microscaling: the scale moves inside the tensor
At four bits there are only 16 distinct values per element, so a single scale for a whole tensor is too coarse, and the natural fix is a scale for every small block of elements. OCP's Microscaling (MX) specification v1.0 builds that granularity into the format itself. MXFP4 stores each element as an E2M1 number, four bits, and gives every block of 32 elements one shared E8M0 scale. E8M0 is a bare Float32 exponent with no sign and no mantissa, so the scale is always a power of two. Counting the bits, four per element plus eight per block of 32 is bits per weight. NVIDIA's NVFP4 halves the block "from 32 values to 16" and upgrades the scale to E4M3, giving 4.5 bits, plus a per-tensor FP32 scale on top.
Why does one outlier hurt a single tensor scale so badly?
Next, some code. It builds 4,096 normally distributed weights and plants one outlier of 50, as real weights have. Then it quantizes them two ways. int4_tensor uses one scale for the whole tensor, so the step between representable values is set by the largest weight, 50 divided by 7. mxfp4 does the block version: it reshapes the weights into rows of 32, picks a power-of-two scale per row from that row's largest value, and snaps each scaled weight to the nearest of the eight E2M1 magnitudes in E2M1. A snap helper does that nearest-value search, and the last lines count the storage cost of the scales.
Try it One outlier weight, and what block scaling does about it that a tensor scale cannot
import numpy as np
# MXFP4 (OCP Microscaling v1.0): 32 elements share one E8M0 scale
# (a raw power of two); each element is E2M1, four bits.
E2M1 = np.array([0., .5, 1., 1.5, 2., 3., 4., 6.]) # magnitudes
def snap(q, grid):
i = np.abs(np.subtract.outer(np.abs(q), grid)).argmin(axis=-1)
return np.sign(q) * grid[i]
def mxfp4(x, blk=32):
y = x.reshape(-1, blk)
s = 2.0 ** np.floor(np.log2(np.abs(y).max(1, keepdims=True) / 6))
return (snap(y / s, E2M1) * s).ravel()
def int4_tensor(x): # one scale for the whole tensor
s = np.abs(x).max() / 7.0
return np.clip(np.round(x / s), -7, 7) * s
rng = np.random.default_rng(0)
w = rng.normal(0, 1, 4096)
w[137] = 50.0 # one outlier, as real weights have
for name, q in [("MXFP4, 32-elem blocks ", mxfp4(w)),
("INT4, one tensor scale", int4_tensor(w))]:
e = q - w
print(f"{name} rms err {np.sqrt((e**2).mean()):6.3f}"
f" weights flushed to zero {(q == 0).mean():6.1%}")
print("\nbits per weight, scale included:")
for nm, elem, blk, sc in [("MXFP4", 4, 32, 8), ("NVFP4", 4, 16, 8)]:
b = elem + sc / blk
print(f" {nm} {b:.2f} bits {16/b:.2f}x smaller than BF16")
99.9% of the tensor rounds to zero and the RMS error is 0.997, the standard deviation of the data. The model is ruined. MXFP4 confines that outlier to its own block of 32 and lands at 0.220. Both formats store four bits per element; one has 128 scales and the other has one.That outlier forces a per-tensor step of 50/7, about 7, larger than almost every ordinary weight, so 99.9% of the tensor rounds to zero and the error is as large as the data itself. Blocks contain the damage: the outlier lives in one block of 32 and the other 127 blocks keep fine scales, so MXFP4 lands at 0.220. Both formats store four bits per element, and the difference is that one has a single scale and the other has 128.
Does the damage show up in real models? NVIDIA reports NVFP4 against FP8 on DeepSeek-R1-0528 at "1% or less accuracy degradation", with MMLU-Pro at 85 against 84 and GPQA Diamond at 81 against 80. OpenAI's gpt-oss. Its model card states the models "were post-trained with MXFP4 quantization of the MoE weights, making gpt-oss-120b run on a single 80GB GPU ... and the gpt-oss-20b model run within 16GB of memory". That sentence follows from the 4.25 bits above. 120 billion weights at 4.25 bits each is 63.75 GB, and only the MoE weights are at that width, so the real footprint is somewhat higher. In BF16 the same weights would be 240 GB and would need four cards.
Why the MoE weights specifically? A mixture of experts (MoE) layer replaces one feed-forward network with many smaller ones, the experts, and sends each token to only a few of them. In a sparse MoE the expert networks hold the overwhelming majority of the parameters, and each one is read only by the tokens routed to it. They're the biggest, coldest, most redundant weights in the model, which makes them the cheapest place to spend accuracy. Attention projections, embeddings and the router are left at higher precision. The router decides which experts run at all, and an error there costs a whole expert, where other layers lose only a few low-order bits. That brings us to the machinery that makes placement, precision and sharing run at speed, starting with the attention computation that decode depends on.
06Decode needs its own attention kernel
A kernel is a program that runs on the GPU, and the attention kernel most people know is FlashAttention, which was designed with prefill in mind. It splits the work across batch entries, attention heads, and blocks of queries, giving each piece to an SM. During prefill there are thousands of queries, one per prompt token, so there's plenty to go around. At decode each request has exactly one query, the token being generated, so that third dimension collapses to 1 and only batch times heads is left to fill the machine.
Here's how the Flash-Decoding authors put the consequence plainly: "if the batch size is smaller than the number of streaming multiprocessors (SMs) on the GPU (108 for an A100), the operation will only use a small part of the GPU! ... With a batch size of 1, FlashAttention will use less than 1% of the GPU!" We can check the shape of that claim ourselves. A 32-head model at batch 1 offers 32 independent work units against an A100's 108 SMs, under a third of the machine. No amount of kernel tuning recovers the other two thirds, because the work isn't there.
The fix is the same trick as split-K in a matrix multiplication, where the shared summation is split across workers and their partial sums are added afterwards. If there isn't enough parallelism across the output, create some across the reduction. Flash-Decoding splits the keys and values into chunks and attends to each chunk in parallel, and each chunk writes "1 extra scalar per row and per split: the log-sum-exp of the attention values", the quantity needed to merge partial softmaxes correctly. A second, cheap pass rescales the partial outputs by those log-sum-exps and sums them. Splitting the KV into 8 chunks turns 32 work units into 256, and the reported result is "up to 8x faster generation for very long sequences".
Splitting only pays when the KV sequence is long relative to the batch, because that's exactly when parallelism over batch and heads is scarce and parallelism over sequence is abundant. At batch 256 with 128 tokens of context there's pretty much nothing to fix. FlashInfer generalised the idea into a kernel library built for serving and not for training, and reports "29-69% inter-token-latency reduction compared to compiler backends for LLM serving benchmark, 28-30% latency reduction for long-context inference". It won a best paper award at MLSys 2025.
Two further decode-specific facts shape these kernels. Grouped-query attention gives each KV head several query heads, so the kernel can load the KV once and issue a small matrix multiply instead of several separate vector ones. And PagedAttention scatters the KV across non-contiguous blocks, so the kernel has to walk a block table and can't stride through it like a flat array. With the kernel in place, the remaining large pieces are communication and scheduling, and the next model we meet is one that doesn't fit on a GPU at all.
07Expert-parallel MoE serving
A sparse mixture of experts is a model that doesn't fit on one GPU and doesn't want to, and serving it well is a communication problem with a load-balancing problem inside it. For this section we'll swap our 70B for DeepSeek-V3, the reference point: "671B total parameters with 37B activated for each token". Each MoE layer has "1 shared expert and 256 routed experts", of which "8 experts will be activated for each token". A small router network scores the experts for each token and picks the top 8, so the question for the fleet is where those 256 experts should live.
Tensor parallelism, the approach from section 02, would shard every expert across every GPU, which means every GPU does a slice of all 256 experts and the activations are all-reduced (summed across GPUs) after every matrix multiplication. Expert parallelism does the opposite: each GPU owns a few whole experts, and the tokens travel to them. For each MoE layer, every token's hidden state is dispatched to the GPUs holding its 8 experts, those GPUs compute, and the results are combined back. That takes two all-to-all exchanges, in which every GPU sends a different piece of data to every other GPU, per MoE layer and per step. So what do those exchanges cost?
The all-to-all, priced
DeepEP, a communication library for expert parallelism, benchmarks this at DeepSeek-V3's configuration: "8K tokens per batch, 7168 hidden dimensions, top 8 experts, FP8 dispatching, and BF16 combining". Those numbers are enough to size the traffic. Dispatch moves bytes at one byte each, so 470 MB. Combine moves the same count at two bytes, so 940 MB. DeepEP reports 726 GB/s dispatch and 740 GB/s combine over NVLink, against 90 and 81 GB/s over RDMA (network transfers that go straight between machines' memory). Dividing through, the intra-node case costs about 1.9 ms per MoE layer and the cross-node case about 16.8 ms. DeepEP notes these are logical bandwidths that include local traffic, so treat the ratio as the finding and neither absolute as exact.
That roughly 9x gap is why DeepSeek-V3's router constrains each token to "at most 4 nodes". Node-locality is a term in the routing function, and not a deployment detail added afterwards. Even with that, though, communication isn't the whole bill, because the router decides how much work each GPU gets.
Imbalance is the cost
Routing is learned, and learned routing isn't uniform: some experts become popular. LMSYS's large-scale expert-parallelism report states the consequence: "This imbalance forces the system to wait for the slowest GPU computation or communication ... As the number of GPUs (EP size) increases, the imbalance issue gets more severe."
Why does the busiest expert set the speed of everyone?
Each layer's results have to be combined before the next layer can start, so a step finishes when the busiest expert finishes. Mean load is irrelevant, and the maximum sets the clock. To make that concrete, the code below uses 256 experts, 8 per token and 8,192 tokens. A function load routes every token to its top-8 experts and counts how many tokens each expert receives. It runs three routers. A uniform one gives every expert equal affinity in expectation. A popularity-skewed one adds a fixed per-expert bonus, pop, so some experts are favoured. The third one applies DeepSeek-V3's auxiliary-loss-free fix, a per-expert bias b that's added to the score for routing only and nudged down by gamma whenever an expert is overloaded.
Try it Watch a skewed router create a straggler, then fix it with one bias vector
import numpy as np
E, K, T = 256, 8, 8192 # experts, experts per token, tokens
rng = np.random.default_rng(0)
def load(scores): # tokens per expert after top-K routing
top = np.argpartition(-scores, K, axis=1)[:, :K]
return np.bincount(top.ravel(), minlength=E)
def report(tag, c):
print(f"{tag:22s} mean {c.mean():6.1f} busiest {c.max():5d}"
f" imbalance {c.max()/c.mean():5.2f}x")
aff = rng.normal(0, 1, (T, E)) # router affinities
report("uniform router", load(aff))
pop = rng.normal(0, 0.6, E) # some experts are popular
report("popularity-skewed", load(aff + pop))
# DeepSeek-V3's auxiliary-loss-free fix: a per-expert bias, added to
# the score for ROUTING ONLY, nudged down when an expert is overloaded.
b, gamma = np.zeros(E), 0.05
for step in range(60):
c = load(aff + pop + b)
b -= gamma * np.sign(c - c.mean())
report("after bias correction", load(aff + pop + b))
8.75x imbalance. The busiest expert takes 2,241 tokens against a mean of 256, and every other GPU in the group waits for it. Sixty rounds of a per-expert bias bring it to 1.14x, below what a uniform router manages by chance. The bias touches routing only, so the gating values are untouched, and DeepSeek-V3 is explicit about that.Read the three lines against each other. Mean load is 256 tokens per expert in every case, since the same tokens are always routed. Even the uniform router is a bit uneven, with a busiest expert at 296, or 1.16x the mean. Next, the skewed router sends 2,241 tokens to its busiest expert, an 8.75x imbalance, and every other GPU in the group waits for that one. Sixty rounds of the bias update bring it down to 1.14x, below what the uniform router manages by chance. That bias touches routing only and leaves the gating values (the weights used to mix expert outputs) untouched, and DeepSeek-V3 is explicit about that.
Two production mitigations sit on top of that. DeepSeek deploys "redundant experts, which duplicates high-load experts", and SGLang's report finds that "SGLang with default expert imbalance is 20% slower than DeepSeek's profile, while the simulated perfect EPLB case narrows the gap to 6%". For scale, that same deployment ran on 12 nodes of 8 H100s and reported "52.3k input tokens per second and 22.3k output tokens per second per node for 2000-token input sequences", using the prefill/decode disaggregation from section 02 alongside expert parallelism. All of this machinery exists to serve more tokens per second, but section 01 warned that tokens per second isn't what the fleet is measured on, and the last piece of the chapter is the scheduler that acts on that.
08SLA-aware scheduling, and why throughput is the wrong target
Throughput rises steadily as we allow more concurrent requests, but goodput doesn't, so running at the top of the first curve puts you well past the top of the second. DistServe defines the target precisely: "per-GPU goodput, defined as the maximum request rate that can be served adhering to the SLO attainment goal (say, 90%) for each GPU provisioned". Tokens served too slowly to be useful don't count. That gap isn't small, and the arithmetic already on this page is enough to see it.
Next is a model and not a measurement, and it goes back to one H100 serving the 8B model in BF16. For each concurrency level N it imagines a cycle in which N prompts are prefilled and then all N requests decode together for 256 steps. A decode step takes the larger of two times, reading the weights from memory (W / BW) and the arithmetic (2 * P * N / F), the roofline idea from chapter 23. Prompt lengths are drawn from a lognormal distribution with a median near 900 tokens, and a request meets its SLO if its time to first token is at most 2.0 seconds and the ITL is at most 25 ms. Goodput is throughput times the share of requests that met both.
Try it Sweep concurrency and watch goodput peak while throughput is still climbing
import numpy as np
P, W, BW, F = 8e9, 16e9, 3.35e12, 4.0e14 # 8B in BF16, one H100
L_out = 256 # output tokens per request
TTFT_SLO, ITL_SLO = 2.0, 0.025 # the contract with the user
rng = np.random.default_rng(0)
L_in = rng.lognormal(np.log(900), 1.0, 4000) # prompt lengths
wait = (np.arange(4000) + .5) / 4000 # place in the cycle
print(" N thr tok/s ITL ms met SLO goodput tok/s")
for N in (4, 8, 16, 24, 32, 48, 64, 128, 256):
# one cycle = N prefills plus L_out decode steps at batch N
cycle = L_out * max(W / BW, 2 * P * N / F) \
+ N * 2 * P * L_in.mean() / F
thr = N * L_out / cycle # tokens/s
itl = cycle / L_out
ttft = wait * cycle + 2 * P * L_in / F
met = ((ttft <= TTFT_SLO) & (itl <= ITL_SLO)).mean()
print(f"{N:4d} {thr:10.0f} {itl*1e3:8.1f} {met:9.0%} {thr*met:14.0f}")
1741 tokens/s. Throughput is still climbing there and reaches 3736 at 128, where goodput is zero. Running at the throughput maximum serves 2.1x more tokens and zero useful ones. This is a model and not a measurement: the decode step is the larger of weights-over-bandwidth and compute, prefills spread evenly through the cycle, prompt lengths lognormal. Sweep yours to find it.Start with the throughput column, which only goes up until the compute limit at about 3,736 tokens per second. Now read the "met SLO" column beside it. Up to 8 concurrent requests everyone is served on time. By 16, ITL has grown to 8.4 ms and the prefill backlog pushes some first tokens past 2 seconds, so only 90% meet the contract. Goodput peaks at 24 concurrent requests with 1,741 tokens per second, while throughput is still climbing there and reaches 3,736 at 128, where goodput is zero. Running at the throughput maximum serves 2.1x more tokens and no useful ones. Your peak will probably sit somewhere else, so sweep your own numbers to find it. The chart below draws the same sweep so you can see the gap.
Once goodput is the target, the scheduler gets choices it didn't have before. Four systems show the range. FastServe attacks head-of-line blocking, where one long request holds up the short ones behind it, with "a novel skip-join Multi-Level Feedback Queue scheduler", reporting up to 31.4x throughput at the same average latency requirement. Llumnix reschedules requests across model instances at runtime and reports improving "tail latencies by an order of magnitude" and accelerating "high-priority requests by up to 1.5x". QLM manages the queue and not the batch, reporting "SLO attainment by 40-90% and throughput by 20-400%". Andes optimises perceived quality of experience directly, reporting up to 4.7x average QoE at fixed GPU count, or "61% GPU resources" saved at fixed QoE. Some of these policies are built in: vLLM ships a policy setting where "fcfs" means arrival order and "priority" means "requests are handled based on given priority (lower value means earlier handling)".
Cheapest of all the SLA mechanisms is admission control, which means refusing work you can't finish on time. vLLM's max_num_queued_tokens documentation gives the formula outright: set it to target_TTFT * prefill_throughput and "you reject requests when the prefill backlog would exceed the latency target". Over the limit, new requests get an HTTP 503. Refusing a request you can't serve on time is better than accepting it and missing, because the rejected client can retry elsewhere immediately and the accepted ones keep their contract. A queue with no bound converts one slow minute into an hour of broken promises.
Preemption is the other half. When the KV pool fills, the scheduler evicts a request and later recomputes its prefill, which means throughput is spent twice. vLLM exposes a watermark that keeps a fraction of blocks free specifically to "avoid frequent KV cache eviction and the resulting repeated preemption of requests". That closes the loop with the rest of the chapter, and the summary below collects it.
09Summary
- At fleet scale the questions are placement, precision and sharing. Page 31's single dial, batch size on one device, becomes decisions about where each phase runs, how wide each stored number is, and which jobs share which weights.
- Prefill and decode can run on separate GPU pools. Each pool is then sized and sharded for its own phase, and the cost is shipping the KV cache between them.
- The cache has a fixed size per token, . For the 70B model that's 320 KiB, so an 8,192-token prompt leaves 2.5 GiB behind.
- The break-even bandwidth is . It's the link speed at which moving a token's KV costs as much as recomputing it, and the prompt length cancels out of it. For the 70B it's 0.94 GB/s, so NVLink and InfiniBand are far above it and 25 GbE is not.
- Disaggregation isn't free throughput. It buys separate control over TTFT and ITL, and it isn't worth it on a slow link, with short prompts, on a small fleet, or when chunked prefill already solves the interference.
- Offload KV that will be read once, later, and never KV that's read every step. The same break-even settles it: PCIe's 64 GB/s is about 68 times above the break-even for fetching a cached prefix, while reading active KV over PCIe is a 52x slowdown.
- Many adapters share one base model cheaply in memory, because a rank-16 adapter is 27.3 MB. The step cost scales with the number of distinct adapters in the batch, and one high-rank adapter taxes the whole fleet, so cap the rank at training time.
- Block scaling is what makes four-bit weights work. One outlier ruins a per-tensor scale, while MXFP4 keeps it inside a block of 32, at 4.25 bits per weight including the scales.
- Decode needs a kernel that splits the work across the sequence, because with one query per request there's little parallelism left over batch and heads.
- In expert-parallel serving the busiest expert sets the step time, and cross-node all-to-all costs about 9x the intra-node case, so routing is made node-aware and loads are rebalanced.
- Goodput peaks earlier than throughput does. Past that point you serve more tokens and fewer useful ones, and that's why fleets use SLO-aware scheduling and admission control.
10Build this
Section 02's break-even bandwidth is three measurements away from being a number about your own hardware and not just a number on this page.
The formula has exactly three inputs. Two of them you can read off a config file, and the third is the one everybody guesses wrong. Measure all three, predict the transfer cost, then check the prediction against a real split.
- Compute from the model's
config.json: layers, KV heads, head dimension, dtype. Cross-check it against the number of tokens your engine says the KV pool holds, because a factor-of-two error here is easy and silent. - Measure by sending one request with a long prompt and no output, timing the first token, and dividing by that time. This gives your achieved prefill rate. Expect it to be well under the datasheet, and use yours everywhere below.
- Measure on the link that would connect the pools. Not the vendor figure, the one you get: a point-to-point send and receive of a few gigabytes, timed.
- Compute and the predicted transfer share . Write the number down before you run anything else.
- Now run vLLM's disaggregated prefill across the two GPUs and measure TTFT against a single-instance baseline at the same load.
fp8_e4m3 KV: halves, so the predicted share should halve too. If it does not, the transfer is not what is costing you.11What breaks
At fleet scale the failures are not crashes. They are a number that got worse somewhere you were not looking, for a reason that is nowhere in the logs.
- The KV transfer is serialised, not overlapped. Section 02's percentage assumes the send of layer overlaps the prefill of layer . If it does not, you pay the whole transfer as added TTFT, and disaggregation looks like a regression.
- The pool ratio is tuned for yesterday's traffic. Prompts get longer, the prefill pool saturates, and the decode pool idles while queueing grows. The symptom is rising TTFT with flat inter-token latency, which points straight at the split.
- KV quantization passes every eval you ran. Short-context benchmarks will not show it. The damage lands on long-context retrieval, so it ships, and then a customer with a 100,000-token document finds it for you.
- One hot expert is setting the step time. Throughput falls by the imbalance factor and no component reports an error, because every GPU is healthy and most of them are waiting. Log per-expert token counts or you cannot see it.
- A new router checkpoint invalidates the expert placement. Yesterday's redundant-expert plan was fitted to yesterday's routing distribution. Rebalancing has to be part of deployment, not a one-off.
- One customer's rank-256 adapter taxes the whole fleet. LoRA buffers are sized for the maximum rank, so everyone pays for the largest adapter admitted. Cap it at training time.
- The decode kernel silently fell back. An unusual head dimension, dtype or block size drops you onto a generic path without the split-K, and inter-token latency worsens by a factor you will attribute to anything else.
- Throughput improved and goodput did not. The most common outcome of a batching change. If you are not measuring SLO attainment alongside tokens per second, you cannot tell an improvement from a degradation.
- KV was offloaded to the wrong side of the line. Offloading cached prefixes is a large win. Offloading the cache that decode reads every step costs a factor of about 50, and both are enabled by flags with similar names.
12Where you meet this in the wild
The same techniques, in wildly different combinations, because the binding constraint is different in each.
Huge model, enormous traffic, published latency targets. Everything on this page is in play at once: disaggregated pools, FP8 or four-bit weights, expert parallelism, cross-request prefix caching, and goodput as the provisioning metric.
Every paper cited here was written for this workload.
Thousands of customers, each with a small adapter, most of them idle most of the time. The base model is shared, adapters are paged in and out, and the scarce resource is adapter bandwidth and not model memory.
Multi-LoRA is the product, so cap the rank fleet-wide.
Disaggregation buys little here, because prompts are usually short.
A 600B-class sparse model on a handful of nodes. Expert parallelism is not optional, the all-to-all is the bottleneck, and load balancing decides whether you get the throughput the model card implies.
Budget engineering time for expert placement as well as for the deployment.
A few hundred requests an hour behind a company firewall. Continuous batching and prefix caching are already enough, and the KV pool will never fill.
Almost none of this page applies. Page 31 is the whole answer, and adding a second pool here buys complexity and nothing else.
13Interview questions
BeginnerWhat is prefill/decode disaggregation, and what does it cost?
It runs the two phases of a request on separate GPU pools instead of sharing one. The motivation is that the phases want different machines: prefill is compute-bound and latency-sensitive, so it prefers wide tensor parallelism and small batches, while decode is memory-bandwidth-bound and prefers the largest batch the KV pool allows. A single pool must pick one configuration for both, and two pools do not. The cost is that prefill produces the KV cache and decode consumes it, so that cache has to cross an interconnect. Whether the cost is acceptable is arithmetic rather than opinion: the transfer time as a fraction of the prefill time is the KV bytes per token times the achieved FLOP rate, divided by twice the parameter count times the link bandwidth. On NVLink that fraction is well under one percent; on commodity Ethernet it is tens of percent.
BeginnerWhy is FP8 weight quantization roughly twice as fast rather than just smaller?
Because the tensor cores have a separate, faster path for it. An H100 datasheet lists 1,979 TFLOPS for BF16 and 3,958 for FP8, a factor of exactly two, and that ratio comes from the numeric format rather than from any other hardware difference. The memory saving is real too and matters more during decode, which is bandwidth-bound, but the compute doubling is what helps prefill. The two encodings are E4M3, with four exponent bits and three mantissa bits, and E5M2, which trades a mantissa bit for range. E4M3 is the usual choice for weights and activations because precision matters more than range once a scaling factor is applied, and E5M2 appears more often for gradients and occasionally for KV cache.
IntermediateWhy does MXFP4 work when plain INT4 with one scale does not?
Because of where the scaling factor lives. A single per-tensor scale has to cover the largest magnitude in the tensor, and weight distributions have outliers, so one large value forces a step size that rounds almost everything else to zero. MXFP4 as specified by OCP puts an E8M0 scale on every block of 32 elements, so an outlier only distorts its own block and the other blocks keep sensible scales. The cost is the scale storage, which works out to four bits per element plus eight bits per thirty-two, or 4.25 bits per weight. NVFP4 halves the block to 16 elements and uses an E4M3 scale, reaching 4.5 bits with finer adaptation, and NVIDIA reports around one percent or less accuracy degradation against FP8 on reasoning benchmarks. The general principle is that low-bit quantization is a question about granularity, not about bit width alone.
IntermediateYou want to serve 500 customer LoRA adapters on one base model. What dominates the cost?
Not storage. A rank-16 adapter on an 8B model with adapted attention projections is about 13.6M parameters, or 27 MB in BF16, so 500 of them are under 14 GB and sit comfortably beside a 16 GB base model. What dominates is bandwidth during decode, and specifically the number of distinct adapters in a batch rather than the batch size, because requests sharing an adapter read it once. At rank 16 with 32 distinct adapters the extra read is about five percent of the base weights; at rank 64 with 128 distinct it approaches ninety percent, and the adapters cost nearly as much as the model. The second constraint is that the LoRA path cannot be one GEMM, since each sequence needs its own matrices, which is what Punica's SGMV kernel and S-LoRA's unified paging exist to solve. Practically, cap the maximum rank fleet-wide, because serving buffers are sized for the largest adapter admitted.
IntermediateWhy does decode need a different attention kernel from prefill?
Because FlashAttention parallelises over batch, heads and blocks of queries, and at decode time there is exactly one query per request, so that third dimension disappears. Only batch times heads is left to fill the GPU, and the Flash-Decoding authors note that if the batch is smaller than the SM count, 108 on an A100, the kernel uses a small part of the device, with batch one using under one percent of it. The fix is split-K applied to the sequence: divide the keys and values into chunks, attend to each in parallel, store one extra log-sum-exp scalar per row per split, then rescale and combine in a cheap second pass. The win is largest exactly when the context is long and the batch is small, which is when parallelism over batch is scarcest, and the reported speedup reaches eight times for very long sequences.
DeepYou have 32 requests at 8k context on a 70B model and 64 GB of host RAM free. Should you offload the KV cache?
It depends entirely on whether that KV is being read every step, and the two answers are opposite. Active decoding KV is read in full on every token: 32 requests at 8,192 tokens and 320 KiB per token is 85.9 GB per step, which takes about 26 ms over H100 HBM at 3.35 TB/s and about 1.34 seconds over PCIe Gen5 at 64 GB/s. That is a factor of fifty on the inner loop and it destroys the product. Cached prefixes that nobody is currently reading are the opposite case, because the real comparison is fetching them against recomputing them. Fetching costs the KV bytes divided by the link bandwidth, recomputing costs twice the parameter count times the tokens divided by the achieved FLOP rate, and fetching wins whenever the link exceeds the same break-even bandwidth as before. For this model that break-even is under 1 GB/s, so PCIe is roughly seventy times faster than it needs to be. The rule is to offload KV that will be read once, later, and never KV that will be read on every step.
DeepYour expert-parallel MoE deployment is at a third of its expected throughput. How do you diagnose it?
Start by logging tokens per expert per step, because expert load imbalance is the default explanation and it is invisible in ordinary metrics. A step finishes when the busiest expert finishes, so the maximum load sets the clock while the mean looks fine, and every idle GPU reports as healthy. A modest popularity skew in the router produces imbalance factors approaching an order of magnitude, which is precisely the gap you are describing. Second, check whether tokens are crossing nodes: intra-node all-to-all over NVLink and cross-node over RDMA differ by roughly a factor of nine in DeepEP's own benchmarks, which is why DeepSeek-V3 constrains each token to at most four nodes. Third, compare against a profile with simulated perfect balance; the LMSYS report found default imbalance cost twenty percent against DeepSeek's profile while perfect balance narrowed the gap to six. Mitigations are per-expert routing bias, which DeepSeek applies to routing scores only so the gating values are undistorted, and duplicating high-load experts as redundant copies.
DeepYour server's throughput went up 40% after a change and users are complaining. Explain and fix.
Almost certainly the change raised concurrency, and throughput and goodput diverge past a point. Throughput rises monotonically with concurrency until the hardware saturates, but goodput, meaning the tokens delivered inside the latency contract, peaks much earlier and then falls to zero. In a simple model of an 8B on one H100 with a two-second TTFT target, goodput peaks around twenty-four concurrent requests while throughput keeps climbing to roughly twice that level at a concurrency where SLO attainment is zero. So the 40% is real and useless. The fix is to make goodput the reported metric, sweep concurrency to find its peak on your own traffic, and then defend that operating point with admission control rather than a longer queue. vLLM exposes this directly: cap queued prefill tokens at the target TTFT times the prefill throughput and reject beyond it, so clients get an immediate rejection they can retry rather than a slow response they cannot use. Keep a KV watermark as well, since preemption and recompute under cache pressure is the other way a throughput gain turns into a latency loss.
14Go deeper
--max-lora-rank is a fleet-wide decision.●Now write it yourself
Reading the derivation and being able to produce it are different skills. These are Deep-ML problems that exercise what this page covers — each one is checked against real test cases, not multiple choice.
Matched to this page from Deep-ML's catalogue of 1,380 problems. More at deep-ml.com, and Where to practise covers the other platforms and what each one trains.