Skip to content

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.

An architecture with a numbered request path. Top left, a gray Client box. Top right, an amber dashed container titled Router holding two amber boxes, Pick decode, fewest active requests, and Pick prefill, prefix affinity, token load, joined by an arrow labelled then. Step 1: an arrow labelled request runs from Client to Pick decode. Below, a blue dashed container titled Decode pod holds an amber box, Routing sidecar, :8000, on the left and a blue box, vLLM engine, :8200, on the right. Step 2: an arrow labelled request + prefill pod address leaves the bottom of the Router container between the two picks and runs down into the Routing sidecar. Below that, a blue dashed container titled Prefill pod holds a blue box, vLLM engine, :8000. Step 3: an arrow labelled max_tokens=1 runs down from the Routing sidecar to the prefill vLLM engine. Step 4: an arrow labelled kv_transfer_params runs back up to the Routing sidecar. Step 5: an arrow labelled request + kv_transfer_params runs from the Routing sidecar to the decode vLLM engine. Step 6: a thick purple arrow labelled KV blocks, TPU KV connector runs from the prefill vLLM engine right and up into the decode vLLM engine. A legend at the bottom left: Request path, a solid arrow; KV transfer, a thick purple arrow.

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=gke on every TPU row):

    ACCELERATOR_TYPE Model Layout KV connector Status
    tpu/v6 Qwen/Qwen3-32B 1P + 1D, 8 chips each (2x4), 16k context TorchTPU TPUConnector (ZMQ + host shared-memory staging) community
    tpu/v7 Qwen/Qwen3.5-397B-A17B-FP8 1P + 1D, 4 chips each (2x2x1); prefill PCP=8, decode DP=8, both TP=1 with EP TPURaidenConnector, 64 GiB prefill host tier community
    tpu/v7-dynamic-slice Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8 1P + 1D, one 2x2x1 sub-slice each, TP=8 TPUConnectorHMA community
    tpu/v5p Qwen/Qwen3-32B 1P + 1D, 4 chips each (2x2x1, TP=4) TPUConnector from tpu_inference validated nightly
  • TPU7x pods request 850Gi memory (request equals limit) for the 64 GiB pinned host tier plus runtime; tpu7x-standard-4t has about 919Gi allocatable. Boot disks as in the quickstart.

  • The LeaderWorkerSet controller v0.11.1 or newer with the DisaggregatedSet API 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, wrapping TPURaidenOffloadingConnector (64 GiB host tier, first, higher priority) and TPURaidenConnector as kv_producer; decode runs TPURaidenConnector as kv_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=4352 and --prefix-cache-retention-interval=0 on both, and PYTHONHASHSEED=0 on every engine. Tool calling uses --tool-call-parser=qwen3_coder --reasoning-parser=qwen3 (hermes with qwen3 for 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)

References