P/D disaggregation on TPU¶
Use this guide when prefill and decode need to scale separately: long prompts with short outputs, or strict TPOT targets that prefill bursts keep breaking. Prefill pods compute the prompt's KV cache, decode pods pull it over a TPU KV connector and generate. Both pools sit in one InferencePool, and the llm-d router (proxy and EPP) schedules each request twice: prefill by prefix affinity and token load, decode by fewest active requests. Chapter 20 explains when the split pays; Disaggregate prefill and decode covers the same connectors without llm-d.
The router schedules each request twice but sends it only to the decode pod; that pod's sidecar first sends the prompt to the prefill pod with max_tokens=1, then hands the returned kv_transfer_params to its engine, which pulls the KV straight from the prefill pod. Tokens stream back through the sidecar and the router.
Prerequisites¶
-
GKE TPU node pools for one configuration (
INFRA_PROVIDER=gkeon every TPU row):ACCELERATOR_TYPEModel Layout KV connector Status tpu/v6Qwen/Qwen3-32B1P + 1D, 8 chips each ( 2x4), 16k contextTorchTPU TPUConnector(ZMQ + host shared-memory staging)community tpu/v7Qwen/Qwen3.5-397B-A17B-FP81P + 1D, 4 chips each ( 2x2x1); prefill PCP=8, decode DP=8, both TP=1 with EPTPURaidenConnector, 64 GiB prefill host tiercommunity tpu/v7-dynamic-sliceQwen/Qwen3-Coder-480B-A35B-Instruct-FP81P + 1D, one 2x2x1sub-slice each, TP=8TPUConnectorHMAcommunity tpu/v5pQwen/Qwen3-32B1P + 1D, 4 chips each ( 2x2x1, TP=4)TPUConnectorfromtpu_inferencevalidated nightly -
TPU7x pods request
850Gimemory (request equals limit) for the 64 GiB pinned host tier plus runtime;tpu7x-standard-4thas about 919Gi allocatable. Boot disks as in the quickstart. - The LeaderWorkerSet controller
v0.11.1or newer with theDisaggregatedSetAPI enabled. For dynamic sub-slices, install it through the GKE dynamic slicing cluster preparation instead. - The repository, CRDs, namespace and Secret from the quickstart, steps 1 to 3.
Steps¶
1. Install LeaderWorkerSet with DisaggregatedSet¶
export LWS_VERSION=<v0.11.1 or newer>
# helm upgrade never updates CRDs, so apply the chart's CRDs first
helm pull oci://registry.k8s.io/lws/charts/lws --version=${LWS_VERSION} --untar
kubectl apply --server-side --force-conflicts -f lws/crds
helm upgrade --install lws oci://registry.k8s.io/lws/charts/lws \
--version=${LWS_VERSION} \
--namespace lws-system --create-namespace \
--set enableDisaggregatedSet=true \
--wait --timeout 300s
Check: the helm command returns after --wait, and kubectl get pods -n lws-system shows the controller Running.
2. Set the environment and deploy the router¶
export REPO_ROOT=$(realpath $(git rev-parse --show-toplevel))
export GUIDE_NAME=pd-disaggregation
export NAMESPACE=llm-d-pd-disaggregation
export MONITORING=false
export MONITORING_VALUES=
export ACCELERATOR_VALUES=
export ACCELERATOR_TYPE=tpu/v7 # tpu/v5p, tpu/v6, tpu/v7, tpu/v7-dynamic-slice
export MODEL_SERVER=vllm
export INFRA_PROVIDER=gke
export MODEL=Qwen/Qwen3.5-397B-A17B-FP8 # per the table above
source ${REPO_ROOT}/guides/env.sh
export ROUTER_BASE_VALUES="${REPO_ROOT}/guides/recipes/router/base.values.yaml"
export ROUTER_VALUES="${REPO_ROOT}/guides/${GUIDE_NAME}/router/${GUIDE_NAME}.values.yaml"
# TPU7x only: 4352-token prefill blocks, 262k context, affinity gate measured on this topology
export ACCELERATOR_VALUES="-f ${REPO_ROOT}/guides/${GUIDE_NAME}/router/tpu-v7.values.yaml"
helm install ${GUIDE_NAME} \
${ROUTER_STANDALONE_CHART} \
-f ${ROUTER_BASE_VALUES} \
${MONITORING_VALUES} \
-f ${ROUTER_VALUES} \
${ACCELERATOR_VALUES} \
-n ${NAMESPACE} --version ${ROUTER_CHART_VERSION}
The router values disaggregate every request (always-disagg-pd-decider) with a prefill and a decode profile that select pods by their llm-d.ai/role label. The shipped peakPrefillThroughput of 33821 was calibrated for gpt-oss-120b on H200 through NIXL; measure your own before performance work.
Check: the EPP pod is Running.
3. Deploy prefill and decode¶
kubectl apply -n ${NAMESPACE} \
-k ${REPO_ROOT}/guides/${GUIDE_NAME}/modelserver/${ACCELERATOR_TYPE}/${MODEL_SERVER}/${INFRA_PROVIDER}/
For tpu/v7-dynamic-slice, first apply the Kueue LocalQueue: kubectl apply -n ${NAMESPACE} -f ${REPO_ROOT}/docs/infrastructure/providers/gke/dynamic-slicing/kueue-localqueue.yaml. Its roles keep groupIdentity: Ordinal and carry the kueue.x-k8s.io/queue-name label so Kueue admits them.
What the TPU overlays set:
- v6e:
TPU_KV_SHM_POOL_GB=8, because the default 128 GB staging pool does not fit the 100Gi/dev/shm. - TPU7x: prefill runs
TPUMultiConnector, wrappingTPURaidenOffloadingConnector(64 GiB host tier, first, higher priority) andTPURaidenConnectoraskv_producer; decode runsTPURaidenConnectoraskv_consumer. TPU Sync reshards the KV from 8 prefill shards onto 8 decode engines over the TPU interconnect. Prefix caching is on for both roles; for this hybrid model that takes--mamba-cache-mode=align,TPU_VLLM_ENABLE_UNIFIED_BLOCK_POOL=1,--block-size=4352and--prefix-cache-retention-interval=0on both, andPYTHONHASHSEED=0on every engine. Tool calling uses--tool-call-parser=qwen3_coder --reasoning-parser=qwen3(hermeswithqwen3for Qwen3-32B on v5p and v6e). - Both: prefill and decode are the two roles of one
DisaggregatedSet; decode puts the routing sidecar on port 8000 in front of the engine on 8200.
Check: kubectl get leaderworkerset -n ${NAMESPACE} shows both roles ready, and pods carry llm-d.ai/role=prefill or decode. For dynamic slices, kubectl get slices -n ${NAMESPACE} shows ACTIVE.
4. Send a test request¶
export IP=$(kubectl get service ${GUIDE_NAME}-epp -n ${NAMESPACE} -o jsonpath='{.spec.clusterIP}')
kubectl run curl-test --rm -i --restart=Never \
--image=${CURL_TEST_IMAGE} \
--namespace="${NAMESPACE}" \
--env="IP=${IP}" \
--env="MODEL=${MODEL}" \
-- /bin/sh -c 'curl -sS -X POST "http://${IP}/v1/completions" -H "Content-Type: application/json" -d "{\"model\": \"${MODEL}\", \"prompt\": \"How are you today?\"}"'
Check: a completion returns. The decode sidecar can serve a request alone, so this does not prove the split; step 5 does.
5. Verify that requests are split¶
kubectl run pd-test --rm -i --restart=Never \
--image=${CURL_TEST_IMAGE} \
--namespace="${NAMESPACE}" \
--env="IP=${IP}" \
--env="MODEL=${MODEL}" \
-- /bin/sh -c 'P=$(for i in $(seq 1 60); do printf "The prefill pod computes the KV cache and the decode pod pulls it to generate tokens. "; done)
for i in $(seq 1 5); do
curl -sS -o /dev/null -w "request ${i}: HTTP %{http_code}\n" -X POST "http://${IP}/v1/completions" \
-H "Content-Type: application/json" \
-d "{\"model\": \"${MODEL}\", \"prompt\": \"${P} Question ${i}: what is llm-d?\", \"max_tokens\": 16}"
done'
for role in prefill decode; do
port=8000; [ "${role}" = decode ] && port=8200
for pod in $(kubectl get pods -n ${NAMESPACE} -l llm-d.ai/guide=${GUIDE_NAME},llm-d.ai/role=${role} -o jsonpath='{.items[*].metadata.name}'); do
echo "== ${role}: ${pod}"
kubectl get --raw "/api/v1/namespaces/${NAMESPACE}/pods/${pod}:${port}/proxy/metrics" \
| grep -E '^vllm:(request_success_total|prompt_tokens_total|external_prefix_cache_hits_total)' || true
done
done
On v6e, prompts shorter than one KV block are recomputed on decode rather than transferred; if decode shows no external hits, repeat with a prompt of several thousand tokens.
Check: prefill's vllm:request_success_total counts the requests, and decode's vllm:external_prefix_cache_hits_total grows by roughly each prompt's length. With MONITORING=true, the router's decisions show under decision_type="prefill-decode":
kubectl get --raw "/api/v1/namespaces/${NAMESPACE}/services/${GUIDE_NAME}-epp:9090/proxy/metrics" \
| grep -E '^llm_d_epp_disagg_decision_total' || true
6. Scale and operate¶
Raise replicas on a DisaggregatedSet role for another xPyD ratio (on TPU7x each pod takes its TPU Sync engine ID from its own name, so 2P2D needs no other change), or slices for complete copies of the topology. TPU node pools are fixed-size, so a rollout that needs a spare node leaves the new pod Pending until the old group is deleted; see Rollouts for the P/D-safe procedure and drain settings.
Watch the two pools as a pair: prefill vllm:num_requests_running{pod=~".*prefill.*"} (saturation inflates TTFT), decode vllm:kv_cache_usage_perc{pod=~".*decode.*"} (above about 0.9 decode preempts), the llm_d_epp_disagg_decision_total ratio, and TTFT against ITL. Queries Q14 and Q40 in Observability cover the P/D signals.
Check: after scaling, the new pods appear under their role label and step 5 still shows external hits on every decode pod.
7. Clean up¶
kubectl delete -n ${NAMESPACE} -k ${REPO_ROOT}/guides/${GUIDE_NAME}/modelserver/${ACCELERATOR_TYPE}/${MODEL_SERVER}/${INFRA_PROVIDER}
helm uninstall ${GUIDE_NAME} -n ${NAMESPACE}
kubectl delete namespace ${NAMESPACE}
Deleting the set cascades to its LeaderWorkerSets, pods and Services. For dynamic sub-slices, delete the overlay before removing node pools so Kueue releases its Slice resources.
Check: kubectl get disaggregatedset,leaderworkerset -n ${NAMESPACE} returns nothing.
Troubleshooting¶
| Symptom | Cause | Fix |
|---|---|---|
| Prefill pods count no requests | The router is not disaggregating | Pods carry llm-d.ai/role; LeaderWorkerSets ready; EPP logs |
| Prefill counts requests, decode has no external hits | KV transfer failing, decode recomputes | Decode logs for connector errors; on v6e use a longer prompt |
| v6e pod fails to allocate the staging pool | Default 128 GB pool exceeds /dev/shm |
Keep TPU_KV_SHM_POOL_GB=8 |
| TTFT regresses, decode healthy | Prefill saturated or transfer stalling | Prefill utilization with TTFT; idle prefill and high TTFT points at the connector |
| ITL regresses, prefill healthy | Decode out of KV | More decode replicas or TP |
| Both pools idle, latency high | Routing | Decision ratio and llm_d_epp_scheduler_e2e_duration_seconds |
New pod Pending during a rollout |
Fixed-size TPU pools, no spare node | Let the old group go first, or add capacity |
| Connector fails to load | TpuRaidenConnector, as written in the examples of the vLLM-TorchTPU Disaggregated Serving user guide |
The class is TPURaidenConnector in vllm_torchtpu.distributed.kv_transfer.tpu_connector (chapter 20) |
