How LLM serving worksLesson 9 of 9
Splitting Prefill and Decode (P/D Disaggregation)
Prefill (reading the prompt) is compute-heavy; decode (writing the answer) is memory-read-heavy. Mixing them on one accelerator makes them get in each other’s way. Prefill/decode disaggregation runs the two phases on different accelerators and hands the KV cache from prefill to decode so the answer can continue.
Serving modesingle
Answer pacesteady
First tokenfast
KV transfer pathnot needed
RequestResponse / reportAppears in a later step
What you will learn
- How the two phases interfere on one replica
- Each phase can be scaled on its own
- The KV cache transfer makes or breaks it
- With few concurrent requests it can be a net loss
What to check on Kubernetes
- On Kubernetes, prefill and decode run as separate workloads, and an endpoint picker (EPP) built on the Gateway API Inference Extension picks a prefill and a decode Pod per request. llm-d packages this setup: its EPP tells the two apart by the
llm-d.ai/rolelabel, and the decode side pulls the KV cache from the prefill Pod with NIXL. - Scale prefill and decode replicas separately. If TTFT grows on long-input workloads, add prefill replicas; if TPOT grows on long-output workloads, add decode replicas.
- Treat RDMA (InfiniBand, RoCE, EFA) as a prerequisite for production. NIXL can run over TCP, but much slower. Nodes need RDMA-capable NICs, and those devices must be attached to the Pods. Check the engine logs to confirm the KV transfer uses RDMA and has not fallen back to TCP.
- Before switching, measure TTFT and TPOT for single and disaggregated serving side by side at your real concurrency. If TTFT gets worse at low load, the case for splitting is weak.
Try it yourself
kubectl get pods -n <namespace> -L llm-d.ai/role # e.g. llm-d: prefill and decode Pods (step 3)
kubectl get deployments -n <namespace> # Replica count per side
kubectl get inferencepools -n <namespace> # Pool the EPP picks from (step 4)
curl -s http://<engine>:8000/metrics | grep -E 'vllm:(time_to_first_token_seconds|inter_token_latency_seconds)_sum' # e.g. vLLM: TTFT and TPOT side by side
Check yourself
Further reading: Gateway API Inference Extension · llm-d · NIXL