Skip to content

Disaggregate prefill and decode in vLLM-TorchTPU

Use this guide when long prompts stall running decodes (TPOT spikes as prompts arrive), or when prefill and decode want different parallelism layouts, and you want separate prefill (kv_producer) and decode (kv_consumer) engine pools with the KV cache moved between them. vLLM-TorchTPU moves KV over TPU Sync (Raiden) through vLLM's KV connector interface, and can reshard it in flight between layouts. Chapter 17 explains why decode stalls behind prefill, chapter 18 places disaggregation in the engine, and chapter 20 runs it behind llm-d's router.

Connector class name

The examples in the vLLM-TorchTPU Disaggregated Serving user guide use TpuRaidenConnector in module vllm_torchtpu.distributed.kv_transfer.raiden.raiden_connector. The source defines the class as TPURaidenConnector(TPUConnector) in vllm_torchtpu/distributed/kv_transfer/tpu_connector.py, and the raiden package has no raiden_connector module. The Raiden scripts in examples/disagg/, the vLLM-TorchTPU disaggregated profiling guide and chapter 20 use "kv_connector": "TPURaidenConnector" with "kv_connector_module_path": "vllm_torchtpu.distributed.kv_transfer.tpu_connector", and so do the commands below.

Prerequisites

  • vLLM-TorchTPU on every host that runs an engine, and a clone of https://github.com/vllm-project/vllm-torchtpu.git for examples/disagg/.
  • For the single-host quickstart: one 8-device host (tpu7x-8).
  • For multi-host Raiden: hosts for the prefill and decode pools, a host reachable by all of them for the controller, and the model's layouts for each pool (Choose a parallelism layout).

Steps

1. Know the four parts

An architecture with a numbered request path. On the left, a gray Client box; to its right, an amber Proxy box marked :8000. On the right, two blue dashed pools, one above the other. The upper pool is labelled Prefill pool, kv_producer, :8400, and shows eight device squares in two rows of four, labelled TP=4, PCP=2. The lower pool is labelled Decode pool, kv_consumer, :9400, and shows eight device squares in four pairs, labelled TP=2, DP=4. At the far right, an amber Raiden controller box marked :50055. Step 1: an arrow labelled request runs from Client to Proxy. Step 2: an arrow labelled max_tokens=1 runs from Proxy up and right into the Prefill pool. Step 3: an arrow labelled kv_transfer_params runs from the Prefill pool back to Proxy. Step 4: an arrow labelled request + kv_transfer_params runs from Proxy down and right into the Decode pool. Step 5: a thick purple arrow labelled KV blocks, resharded runs straight down from the Prefill pool to the Decode pool. Step 6: arrows labelled tokens run from the Decode pool back to Proxy and from Proxy back to Client. Dashed arrows with heads at both ends join the Raiden controller to each pool. A legend at the bottom left reads: Request path, a solid arrow; KV transfer, a thick purple arrow; Control path, a dashed arrow with heads at both ends.

The proxy talks to each pool once per request, and the request's KV never passes through it: it moves straight from prefill to decode over Raiden and is resharded from the prefill layout to the decode layout on the way. The controller carries no KV: it registers the pools and coordinates transfer and resharding metadata.

  1. Proxy (examples/disagg/toy_proxy_server.py): takes client requests, sends a max_tokens=1 prefill request to a prefill instance, then forwards the request with the KV transfer parameters to a decode instance and streams the tokens back.
  2. Prefill pool (kv_role="kv_producer"): computes the prompt's KV and returns the KV transfer parameters (kv_transfer_params) in its response to the proxy; the KV blocks go to decode, not through the proxy.
  3. Decode pool (kv_role="kv_consumer"): receives the request with those parameters, loads the KV blocks into its HBM cache, resharding if the meshes differ, and generates tokens.
  4. Raiden controller (examples/disagg/run_raiden_controller.py): coordinates KV transfer metadata and pool registration; no KV passes through it.

Two connectors exist: the Raiden connector (TPURaidenConnector), with the controller and heterogeneous resharding (for example prefill at TP=4, PCP=2 into decode at TP=2, DP=4, the layouts of steps 4 and 5), and TPUConnector, a lightweight host TCP side-channel connector for functional testing and local disaggregation.

2. Try it on one host

MODEL="Qwen/Qwen3-0.6B" \
INPUT_LEN=512 \
OUTPUT_LEN=128 \
NUM_PROMPTS=200 \
bash examples/disagg/run_disagg_single_host.sh

The script pins separate /dev/vfio/<N> devices to a prefill and a decode vllm serve process, starts the proxy on port 8000, and runs vllm bench serve against it.

Check: the benchmark completes and prints its summary. The script writes logs to LOG_DIR (default $HOME/logs): prefill_0.txt, decode_0.txt and benchmark_0.txt, and prints them when it exits.

3. Start the Raiden controller (multi-host)

Run it on a host every engine can reach. The script takes one argument, --port, which is required; the steps below use 50055:

python examples/disagg/run_raiden_controller.py \
  --port 50055

4. Start the prefill instance

export TPU_USE_RAIDEN_KV_CACHE_MANAGER=1
export TPU_RAIDEN_CONTROLLER_ADDRESS="<CONTROLLER_IP>:50055"
export TPU_RAIDEN_JOB_NAME="prefill"
export TPU_RAIDEN_ENGINE_ID="0"
export TPU_RAIDEN_QWEN35_ADMISSION=1

vllm serve Qwen/Qwen3.5-35B-A3B-FP8 \
  --port 8400 \
  --tensor-parallel-size 4 \
  --prefill-context-parallel-size 2 \
  --enable-expert-parallel \
  --kv-cache-dtype fp8 \
  --block-size 256 \
  --attention-backend CUSTOM \
  --kv-transfer-config '{
    "kv_connector": "TPURaidenConnector",
    "kv_connector_module_path": "vllm_torchtpu.distributed.kv_transfer.tpu_connector",
    "kv_role": "kv_producer"
  }'

5. Start the decode instance

export TPU_USE_RAIDEN_KV_CACHE_MANAGER=1
export TPU_RAIDEN_CONTROLLER_ADDRESS="<CONTROLLER_IP>:50055"
export TPU_RAIDEN_JOB_NAME="decode"
export TPU_RAIDEN_ENGINE_ID="0"
export TPU_RAIDEN_QWEN35_ADMISSION=1

vllm serve Qwen/Qwen3.5-35B-A3B-FP8 \
  --port 9400 \
  --tensor-parallel-size 2 \
  --data-parallel-size 4 \
  --enable-expert-parallel \
  --kv-cache-dtype fp8 \
  --block-size 256 \
  --attention-backend CUSTOM \
  --kv-transfer-config '{
    "kv_connector": "TPURaidenConnector",
    "kv_connector_module_path": "vllm_torchtpu.distributed.kv_transfer.tpu_connector",
    "kv_role": "kv_consumer"
  }'

The two pools use different layouts (TP=4, PCP=2 for prefill, TP=2, DP=4 for decode), each 8 devices; Raiden reshards the KV between them. Both sides pass the same --kv-cache-dtype fp8, --block-size 256 and --attention-backend CUSTOM.

Check: both instances log Application startup complete.

6. Start the proxy

python examples/disagg/toy_proxy_server.py \
  --host 0.0.0.0 \
  --port 8000 \
  --prefiller-hosts <PREFILL_HOST_IP> \
  --prefiller-ports 8400 \
  --decoder-hosts <DECODE_HOST_IP> \
  --decoder-ports 9400

Check: a request to the proxy on port 8000 (for example python code/ch18_vllm/client.py smoke --model Qwen/Qwen3.5-35B-A3B-FP8) returns an answer, and both instances' logs show the request. A slow KV transfer shows up as TTFT, not as time per output token.

7. Decide what decode does when it runs out of KV

With kv_load_failure_policy="fail" (the upstream vLLM default), a decode instance aborts running requests that are evicted under KV capacity pressure, instead of recomputing their prompts locally. An aborted request ends with finish_reason "error", stop_reason "kv_cache_preempted", and a kv_transfer_error with status_name "model.KVCachePreempt" in kv_transfer_params. vllm:num_preemptions, vllm:request_num_preemptions and vllm:request_success{finished_reason="error"} record it.

To recompute instead while keeping kv_load_failure_policy="fail", or to abort even under "recompute", set it on the decode instance:

--additional-config '{"abort_on_preemption": false}'
--additional-config '{"abort_on_preemption": true}'

Check: under load, vllm:num_preemptions on the decode pool stays near zero; if it does not, the decode pool needs more KV capacity (more replicas or devices, fp8 KV).

Raiden environment variables

Variable Default Effect
TPU_USE_RAIDEN_KV_CACHE_MANAGER 0 Raiden-compatible KV block layout and manager
TPU_RAIDEN_CONTROLLER_ADDRESS "" host:port of the controller
TPU_RAIDEN_JOB_NAME "" Role registered with the controller (prefill or decode)
TPU_RAIDEN_ENGINE_ID "0" Engine replica ID within the role
TPU_RAIDEN_TRANSFER_PARALLELISM 8 Concurrent DMA transfer streams per worker
TPU_RAIDEN_RESHARD_IMPL "controller" Resharding implementation when the layouts differ: controller (the external Raiden controller) or store (experimental; the reshard service runs inside each engine's rank-0 worker)
TPU_KV_RESHARD_TRANSPORT "zmq" Transport for host-side resharding (zmq or tcp)

The disaggregated profiling guide's GKE example sets TPU_RAIDEN_RESHARD_IMPL=store, the experimental value from the table, and TPU_KV_RESHARD_TRANSPORT=raiden, a value the table does not list; it describes them as the "Raiden3 store-based KV cache manager", experimental, and documents the setup as of vLLM-TorchTPU commit 7bb6a4a. Follow the table unless you reproduce that example.

Reference launchers and manifests

Script or manifest What it does
examples/disagg/launch_qwen35_disagg_multihost.sh Qwen3.5 disaggregation, ROLE=prefill\|decode\|all
examples/disagg/launch_dsv4_disagg_multihost.sh DeepSeek-V4 multi-host disaggregation
examples/disagg/run_qwen35_raiden_pcp8_dp8_live_pair.sh Resharding from prefill PCP=8 to decode DP=8
.buildkite/kubernetes/manifests/workloads/qwen3.5-397b-1p1d.yaml GKE JobSet, Qwen3.5-397B-A17B 1P1D
.buildkite/kubernetes/manifests/workloads/kimi-k3-1p1d-4dp8tp.yaml GKE JobSet, Kimi-K3 1P1D

To profile a disaggregated request across both pools, see Profile vLLM-TorchTPU serving, section "Disaggregated serving".

Troubleshooting

Symptom Cause Fix
Connector fails to load at startup TpuRaidenConnector or the raiden.raiden_connector module from the user guide's examples TPURaidenConnector in vllm_torchtpu.distributed.kv_transfer.tpu_connector
Engines cannot reach the controller Wrong or unreachable TPU_RAIDEN_CONTROLLER_ADDRESS The controller's host:port (port 50055 in step 3), the same on both pools
Decode requests end with stop_reason "kv_cache_preempted" Decode pool out of KV under kv_load_failure_policy="fail" More decode capacity, fp8 KV, or abort_on_preemption: false to recompute
TTFT high, TPOT fine KV transfer or prefill pool is the bottleneck Profile both pools; add prefill capacity; check TPU_RAIDEN_TRANSFER_PARALLELISM
The single-host script exits with an error A server crashed or did not answer /health within the script's 1,200 s wait Read prefill_0.txt and decode_0.txt in LOG_DIR

References