Why do prefill and decode have opposite hardware bottlenecks, and how does disaggregated serving help?
Written by the mlprep team · Updated
From a GPU hardware perspective, why are the prefill and decode phases of LLM inference fundamentally different? And why are large-scale serving systems increasingly disaggregating prefill and decode onto separate GPU pools?
Arithmetic intensity: the roofline difference#
Every matrix multiplication in a transformer loads model weights from GPU HBM (High Bandwidth Memory) into SRAM/registers and performs multiply-add operations on Tensor Cores. Whether an operation is compute-bound or memory-bandwidth-bound depends on its arithmetic intensity (FLOPs per byte transferred).
For an H100 (FP16/BF16), the ridge point is roughly ~295 FLOPs/byte (~989 TFLOPs / 3.35 TB/s).
- Prefill phase (Compute-bound): A single 2,000-token prompt processes all 2,000 tokens in parallel against the same loaded weights. Arithmetic intensity is high (well above the ridge point), so Tensor Cores are saturated. Latency scales with prompt length and compute capacity.
- Decode phase (Memory-bandwidth-bound): Each decode step processes only 1 token per active request. For batch size
B = 1, you stream tens of gigabytes of weights from HBM just to multiply by a single vector (arithmetic intensity ≈ 1–2 FLOPs/byte). Tensor Cores sit >95% idle waiting on HBM bandwidth.
Prefill: [B × L_prompt, d] × [d, d] → high reuse of weights → Compute-bound
Decode: [B × 1, d] × [d, d] → low reuse until B ≈ 200+ → Memory-bandwidth-bound
Why colocating prefill and decode hurts both SLAs#
When prefill and decode share the same GPU instances:
- Prefill-decode interference: A burst of long prompts stalls active decode batches (spiking TPOT), while prioritizing decode starves incoming prompts (spiking TTFT).
- Conflicting parallelism needs: Prefill benefits from lower tensor parallelism (fewer all-reduce syncs, maximizing throughput per GPU), whereas large-batch decode often needs higher tensor parallelism or larger HBM pools to hold massive KV caches.
- Conflicting hardware profiles: Prefill wants peak FLOPs; decode wants peak HBM capacity and memory bandwidth.
How disaggregated serving works (DistServe / Splitwise / Dynamo)#
Disaggregated serving splits the fleet into two specialized pools:
- Prefill instances: Optimized for compute and TTFT. They process the prompt, generate the first token, and produce the initial KV cache.
- Decode instances: Optimized for HBM bandwidth, large batch sizes, and steady TPOT. They receive the KV cache and stream remaining tokens.
Between them sits a high-speed KV transfer layer (NVLink within a node, or RDMA / InfiniBand across nodes) that streams the KV cache layer-by-layer (often overlapped with prefill computation) from the prefill node to the decode node.
Transferring gigabytes of KV cache over the network sounds expensive. When does KV transfer overhead outweigh the benefits of disaggregation, and how do engineers minimize that transfer cost?
Doing the back-of-the-envelope math#
Take Llama-3 70B (80 layers, GQA with 8 KV heads, d_head = 128, FP16 = 2 bytes):
- KV cache per token:
2 × 80 × 8 × 128 × 2 bytes = 327 KB/token. - For a 4,096-token prompt:
~1.34 GBof KV cache.
Transfer time depends entirely on the interconnect:
- Over NVLink (900 GB/s): ~1.5 ms — essentially negligible.
- Over 400 Gbps InfiniBand / RDMA (~50 GB/s): ~27 ms — small compared to a 200–400ms prefill.
- Over standard 25 Gbps Ethernet (~3 GB/s): ~450 ms — unacceptable; disaggregation loses here.
How production systems minimize transfer overhead#
- Layer-wise pipelined transfer: As soon as layer
ifinishes computing its K and V tensors during prefill, asynchronously initiate RDMA transfer of layeri's KV cache while the GPU computes layeri+1. Most transfer latency hides behind prefill compute. - GQA / MLA and FP8 KV cache quantization: Architectures like Grouped-Query Attention (GQA) and DeepSeek's Multi-head Latent Attention (MLA) shrink KV cache size by 4×–10×; quantizing KV cache to FP8 halves transfer volume again.
- Workload-aware routing: Only disaggregate when prompts are long enough and traffic is high enough to justify dedicated pools. For short prompts or low-traffic deployments, colocated serving with chunked prefill is simpler and cheaper.
Senior/staff considerations#
- Disaggregation unlocks independent autoscaling: if your workload shifts toward RAG (long prompts, short answers), scale up prefill GPUs without overprovisioning decode GPUs. If it shifts toward reasoning/CoT (short prompts, 8k-token outputs), scale decode GPUs.
- Monitor goodput (requests/sec meeting both TTFT and TPOT SLAs simultaneously), not raw tokens/sec. Disaggregation often wins on goodput even when raw total tokens/sec looks similar.
Interview red flags#
- Saying decode is slow because "attention is O(n²)" without distinguishing that a single decode step with KV cache is O(n) and primarily memory-bandwidth-bound.
- Proposing disaggregated serving without checking interconnect bandwidth (RDMA/NVLink vs. commodity TCP/Ethernet).
- Ignoring the operational complexity of KV routing, load balancing between pools, and handling decode-pool backpressure.
The key takeaway unlocks after you reveal an expert answer.
Key Takeaway
Prefill is compute-bound (high arithmetic intensity across all prompt tokens), while decode is memory-bandwidth-bound (streaming model weights and KV cache for one token per request). Disaggregated serving separates them onto specialized GPU pools connected by fast NVLink/RDMA interconnects, eliminating TTFT/TPOT interference and enabling independent scaling when interconnect bandwidth supports KV transfer.
Follow-up Questions to Test Yourself
Interviewers often pivot here once you cover the core concept.
- How does the optimal prefill-to-decode GPU ratio change between a RAG summarization service and a chain-of-thought reasoning model?
- When is colocated serving with chunked prefill preferable to disaggregated serving?
- How does prefix caching work in a disaggregated architecture — where should cached prefixes live?
How confident do you feel explaining this?
Track your understanding or flag it to revisit before your next loop.
Related Questions
How do you measure and optimize TTFT, TPOT, and goodput under production SLA constraints?
How does continuous batching work and why does static batching waste GPU utilization?
How does prefix caching (RadixAttention) speed up multi-turn and agentic LLM workloads?
How would you design an LLM serving system for millions of users?