Skip to content

Optimized baseline on TPU

Use this guide for any new llm-d deployment: it is the path every other well-lit path builds on. The router combines a prefix-cache affinity filter (keep requests on endpoints that likely hold their prefix, with a saturation override that spreads load when they get hot) and a token load scorer (prefer the endpoint with the least prefill token load). Chapter 20 explains the scoring; the quickstart is the short version of this page.

Prerequisites

  • A GKE cluster with TPU node pools for one of the guide's TPU configurations:

    ACCELERATOR_TYPE Model (MODEL) Layout Status
    tpu/v6 Qwen/Qwen3-32B 2 replicas x 8 chips (2x4, TP=8), 16k context community
    tpu/v7 Qwen/Qwen3.5-397B-A17B-FP8 2 replicas x 4 chips (2x2x1, DP=8 x TP=1, EP, fp8 KV, 262k context), no KV offload or MTP community
    tpu/v7-dynamic-slice Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8 one Kueue-admitted sub-slice per replica (TPU_SLICE_TOPOLOGY 2x2x1 or 2x2x2) community
    tpu/v5p Qwen/Qwen3-32B 2 replicas x 4 chips (2x2x1, TP=4) validated nightly (Spot)

    "Community" means maintained but not in the nightly end-to-end runs; the v6e nightly moved to v5p while v6e capacity is unavailable. - Boot disks of at least 200 GB (Qwen3-32B, 66 GB) or 1 TB (Qwen3.5-397B-A17B-FP8, 406 GB); see the quickstart prerequisites. - The repository clone, Gateway API Inference Extension CRDs, namespace and llm-d-hf-token Secret from the quickstart, steps 1 to 3, with this guide's names below. - For tpu/v7-dynamic-slice: capacity as 4x4x4 sub-blocks and the cluster and Kueue Topology-Aware Scheduling setup in llm-d's "TPU Dynamic Slicing on GKE" page.

Steps

1. Set the environment

export REPO_ROOT=$(realpath $(git rev-parse --show-toplevel))
export GUIDE_NAME=optimized-baseline
export NAMESPACE=llm-d-optimized-baseline
export MONITORING=false # options: false, true
export MONITORING_VALUES=
export ACCELERATOR_TYPE=tpu/v6 # options include tpu/v5p, tpu/v6, tpu/v7, tpu/v7-dynamic-slice
export MODEL_SERVER=vllm
export INFRA_PROVIDER=gke
export TPU_SLICE_TOPOLOGY=2x2x1 # options: 2x2x1, 2x2x2 (dynamic slicing only)
export MODEL=Qwen/Qwen3-32B # the served model for your accelerator (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"

On TPU7x, layer the TPU7x router values (4352-token block hashing, 262k context, affinity gate measured on that topology):

export ACCELERATOR_VALUES="-f ${REPO_ROOT}/guides/${GUIDE_NAME}/router/tpu-v7.values.yaml"

With MONITORING=true on GKE Managed Prometheus, also export MONITORING_VALUES="-f ${REPO_ROOT}/guides/recipes/router/features/monitoring-gke.values.yaml" (Observability).

Check: MODEL matches the table row for ACCELERATOR_TYPE; a mismatch makes the test requests in step 4 fail.

2. Deploy the router

Standalone Mode (the default; Envoy runs beside the EPP):

helm install ${GUIDE_NAME} \
  ${ROUTER_STANDALONE_CHART} \
  -f ${ROUTER_BASE_VALUES} \
  ${MONITORING_VALUES} \
  -f ${ROUTER_VALUES} \
  ${ACCELERATOR_VALUES:-} \
  -n ${NAMESPACE} --version ${ROUTER_CHART_VERSION}

Or Gateway Mode, after deploying a GKE Gateway named llm-d-inference-gateway (quickstart, step 7):

export GW_PROVIDER_NAME=gke
helm install ${GUIDE_NAME} \
  ${ROUTER_GATEWAY_CHART} \
  -f ${ROUTER_BASE_VALUES} \
  ${MONITORING_VALUES} \
  -f ${ROUTER_VALUES} \
  ${ACCELERATOR_VALUES:-} \
  --set provider.name=${GW_PROVIDER_NAME} \
  --set httpRoute.create=true \
  --set httpRoute.inferenceGatewayName=llm-d-inference-gateway \
  -n ${NAMESPACE} --version ${ROUTER_CHART_VERSION}

The filter's peakPrefillThroughput defaults to a value measured on Qwen3-32B on H100 at TP=2. On TPU it is miscalibrated until you measure your own with llm-d's calibration recipe (guides/recipes/router/calibration) and set it on the filter; the TPU7x values file carries a value measured for that topology.

Check: kubectl get pods -n ${NAMESPACE} shows the EPP pod Running.

3. Deploy the model servers

Static node pools:

kubectl apply -n ${NAMESPACE} \
  -k ${REPO_ROOT}/guides/${GUIDE_NAME}/modelserver/${ACCELERATOR_TYPE}/${MODEL_SERVER}/${INFRA_PROVIDER}/

Dynamic slicing on TPU7x (ACCELERATOR_TYPE=tpu/v7-dynamic-slice, MODEL=Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8):

# One sub-slice of shape TPU_SLICE_TOPOLOGY per replica, admitted by Kueue
kubectl apply -n ${NAMESPACE} -f ${REPO_ROOT}/docs/infrastructure/providers/gke/dynamic-slicing/kueue-localqueue.yaml
kubectl apply -n ${NAMESPACE} \
  -k ${REPO_ROOT}/guides/${GUIDE_NAME}/modelserver/${ACCELERATOR_TYPE}/${MODEL_SERVER}/${TPU_SLICE_TOPOLOGY}/
TPU_SLICE_TOPOLOGY Chips Hosts (LWS size) TP
2x2x1 (default) 4 1 8
2x2x2 8 2 16

Each replica is a LeaderWorkerSet group; for 2x2x4 or 2x4x4, copy the 2x2x2 overlay and change the cloud.google.com/gke-tpu-slice-topology annotation, the cloud.google.com/gke-tpu-partition-<shape>-state node selector, the LWS size and --tensor-parallel-size (2 cores per chip). The dynamic-slice overlays are not in nightly end-to-end runs: a run needs a full 4x4x4 sub-block (16 tpu7x-standard-4t nodes).

Check: static pools: every model server pod Running and ready. Dynamic slicing: workloads are admitted once their Slice resources are ACTIVE:

kubectl get workloads -n ${NAMESPACE}
kubectl get slices -n ${NAMESPACE}
kubectl get pods -n ${NAMESPACE}

4. Send a test request

export IP=$(kubectl get service ${GUIDE_NAME}-epp -n ${NAMESPACE} -o jsonpath='{.spec.clusterIP}')
# Gateway Mode: export IP=$(kubectl get gateway llm-d-inference-gateway -n ${NAMESPACE} -o jsonpath='{.status.addresses[0].value}')
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 JSON completion returns. That proves the stack is up, not that routing works; step 5 does that.

5. Verify prefix-cache aware routing

Send 10 requests that share a prefix of about 2,000 tokens, then read each pod's counters through the API server proxy:

kubectl run prefix-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 100); do printf "The llm-d router keeps a conversation on the server that already caches its prefix. "; done)
    for i in $(seq 1 10); 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 pod in $(kubectl get pods -n ${NAMESPACE} -l llm-d.ai/guide=${GUIDE_NAME} -o jsonpath='{.items[*].metadata.name}'); do
  echo "== ${pod}"
  kubectl get --raw "/api/v1/namespaces/${NAMESPACE}/pods/${pod}:8000/proxy/metrics" \
    | grep -E '^(vllm:prefix_cache_(hits|queries)_total|vllm:request_success_total)' || true
done

Check: one pod reports most of the 10 requests in vllm:request_success_total, and its vllm:prefix_cache_hits_total is a large fraction of vllm:prefix_cache_queries_total. Requests spread evenly with hit rates near zero mean affinity is not taking effect.

6. Watch the path under load

The smoke test above produces no steady-state signal. Under sustained load, watch load balance and cache hit rate together, because the two objectives pull against each other:

Signal What it tells you
llm_d_epp_request_total, vllm:num_requests_running per pod The load scorer should keep them roughly even
vllm:prefix_cache_hits_total / vllm:prefix_cache_queries_total Affinity is helping only while this stays high
vllm:kv_cache_usage_perc, vllm:num_requests_waiting per pod These drive the saturation override
llm_d_epp_plugin_duration_seconds Rising scheduler latency with healthy pods points at the router
vllm:time_to_first_token_seconds, vllm:inter_token_latency_seconds The SLO signals the path protects

The queries are in Observability.

Check: per-pod load stays within a narrow band and the pool hit rate does not fall as load rises.

7. Clean up

kubectl delete -n ${NAMESPACE} -k ${REPO_ROOT}/guides/${GUIDE_NAME}/modelserver/${ACCELERATOR_TYPE}/${MODEL_SERVER}/${INFRA_PROVIDER}
# dynamic slicing instead:
# kubectl delete -n ${NAMESPACE} -k ${REPO_ROOT}/guides/${GUIDE_NAME}/modelserver/${ACCELERATOR_TYPE}/${MODEL_SERVER}/${TPU_SLICE_TOPOLOGY}
# kubectl delete -n ${NAMESPACE} -f ${REPO_ROOT}/docs/infrastructure/providers/gke/dynamic-slicing/kueue-localqueue.yaml --ignore-not-found=true
helm uninstall ${GUIDE_NAME} -n ${NAMESPACE}
kubectl delete namespace ${NAMESPACE}

Check: kubectl get all -n ${NAMESPACE} returns nothing.

Troubleshooting

Symptom Cause Fix
Some pods hot, others idle peakPrefillThroughput miscalibrated for your model and TPU, so the saturation override never gates in Measure it with the calibration recipe and set it on the filter
Low prefix hit rate, pods cold The prompt mix shares little prefix Nothing to fix in routing; compare hit rate with per-pod saturation
Low prefix hit rate, pods hot The override spreads so aggressively it defeats affinity Recalibrate peakPrefillThroughput
TTFT or ITL regress with balanced load and good hit rate Model servers are the bottleneck Check llm_d_epp_plugin_duration_seconds and queue depth before changing routing
Test requests fail with a model error MODEL does not match the overlay's served model Use the table's model for your ACCELERATOR_TYPE
Dynamic-slice pods never start Slice not ACTIVE, or Kueue setup incomplete kubectl get workloads,slices -n ${NAMESPACE}; finish the dynamic slicing setup
Pod Pending, evicted mid-download or node removed TPU shape mismatch, small boot disk, or autoscaler eviction See the quickstart troubleshooting table

References