Serve across several TPU hosts with vLLM-TorchTPU¶
Use this guide when a model or layout needs more devices than one host has: v7x-16, v7x-32 or v6e-16, for example. vLLM-TorchTPU coordinates the hosts of a slice over its Inter-Chip Interconnect with one of two backends: native multiprocessing (mp, the default), where every host runs vllm serve, or Ray, where one driver schedules workers across a Ray cluster. Chapter 18 introduces both; Run vLLM-TorchTPU on GKE runs the mp backend as a JobSet.
Prerequisites¶
- A multi-host slice with vLLM-TorchTPU installed on every host (Serve a first model with vLLM-TorchTPU, steps 1 to 3, repeated per host), or the Docker image on every host for the Ray route.
- The internal IP of host 0. For TPU VMs:
gcloud compute tpus tpu-vm describe <VM_NAME> --zone=<VM_ZONE> --project=<YOUR_PROJECT>. - The layout's device count, \(DP \times TP \times PP \times PCP\), equal to the slice's devices (8 per v7x host, 1 per v6e chip).
Steps¶
1. Choose the backend and mode¶
| Backend | How it runs | Select with |
|---|---|---|
mp, mode A |
TP, PP or PCP spans hosts; vllm serve on every host, host 0 serves HTTP, the rest are headless |
--nnodes, --node-rank, --master-addr, --master-port, --headless |
mp, mode B |
DP wider than one host; each host serves its local DP ranks | --data-parallel-size-local, --data-parallel-start-rank, --data-parallel-address, --data-parallel-rpc-port |
ray |
A Ray cluster spans the hosts; one vllm serve driver on the head node schedules RayDistributedExecutor workers |
TPU_MULTIHOST_BACKEND=ray |
With mp, vllm-torchtpu runs a TCPStore rendezvous during VllmConfig initialization that fills in TORCH_TPU_SLICEBUILDER_ADDRESSES and TORCH_TPU_TOPOLOGY for the whole slice, so no Ray cluster is needed.
Check: TP, PP or PCP across hosts means mode A; DP across hosts with TP inside a host means mode B (the v7x DP=16 recipes).
2a. mp mode A: tensor, pipeline or context parallelism across hosts¶
On host 0:
vllm serve Qwen/Qwen3.5-397B-A17B \
--tensor-parallel-size 16 \
--enable-expert-parallel \
--nnodes 2 \
--node-rank 0 \
--master-addr <HOST_0_INTERNAL_IP> \
--master-port 29500 \
--port 8000
On every other host, with its own --node-rank from 1 to N-1:
vllm serve Qwen/Qwen3.5-397B-A17B \
--tensor-parallel-size 16 \
--enable-expert-parallel \
--nnodes 2 \
--node-rank 1 \
--master-addr <HOST_0_INTERNAL_IP> \
--master-port 29500 \
--headless
Check: host 0 logs Application startup complete and serves on port 8000; the headless hosts serve no HTTP.
2b. mp mode B: data parallelism across hosts¶
For DP=16 over two 8-device v7x hosts, each host serves 8 local DP ranks. On host 0:
vllm serve Qwen/Qwen3.5-397B-A17B \
--tensor-parallel-size 1 \
--data-parallel-size 16 \
--data-parallel-size-local 8 \
--data-parallel-start-rank 0 \
--data-parallel-address <HOST_0_INTERNAL_IP> \
--data-parallel-rpc-port 13345 \
--enable-expert-parallel \
--port 8000
On host 1:
vllm serve Qwen/Qwen3.5-397B-A17B \
--tensor-parallel-size 1 \
--data-parallel-size 16 \
--data-parallel-size-local 8 \
--data-parallel-start-rank 8 \
--data-parallel-address <HOST_0_INTERNAL_IP> \
--data-parallel-rpc-port 13345 \
--enable-expert-parallel \
--headless
To run a v7x multi-host recipe (GLM-5.2, DeepSeek-V4-Pro) this way, add these flags to the recipe's command on each host (vLLM-TorchTPU recipes for TPU v7x).
Check: host 0 serves on port 8000 once both hosts have started.
2c. Ray backend on Compute Engine¶
From your workstation, deploy a Ray cluster with the repository's script (replace the IPs):
git clone https://github.com/vllm-project/vllm-torchtpu.git
cd vllm-torchtpu/
./scripts/multihost/deploy_cluster.sh \
-s ./scripts/multihost/run_cluster.sh \
-d "vllm/vllm-torchtpu:latest" \
-t "<HF_TOKEN>" \
-H "<IP_0>" \
-i "<INTERNAL_IP_0>" \
-W "<IP_1>,<IP_2>"
-d is the image, -H the external IP of host 0, -i its internal IP, and -W the external IPs of the worker hosts. Then on worker 0, the head node:
gcloud compute tpus tpu-vm ssh <VM_NAME> \
--zone=<VM_ZONE> \
--project=<YOUR_PROJECT> \
--worker=0
sudo docker exec -it node /bin/bash
vllm serve "Qwen/Qwen3-8B" \
--tensor_parallel_size=16 \
--max-model-len=256 \
--max-num-batched-tokens=256 \
--async-scheduling
Kernel and model variables without the VLLM_ prefix reach the Ray actors only when listed in VLLM_RAY_EXTRA_ENV_VARS_TO_COPY; the DeepSeek-V4-Pro recipe shows the full list.
3. Verify¶
From another terminal on host 0 (inside the container for the Ray route):
curl http://localhost:8000/v1/completions \
-H "Content-Type: application/json" \
-d '{
"model": "Qwen/Qwen3-8B",
"prompt": "Hello, my name is",
"max_tokens": 20,
"temperature": 0
}'
Change "model" to the model you served. Check: a completion comes back, and tpu-info on each host shows HBM in use on all its chips.
4. Load weights without filling local disks¶
Hosts without large local disks can stream a checkpoint from Cloud Storage with --load-format runai_streamer, and --enable-ep-weight-filter makes each rank download only its own MoE expert shard. Cap each rank's host streamer buffers with --model-loader-extra-config, as the v7x recipes do (for example '{"memory_limit":4294967296,"concurrency":8}').
Check: host memory stays within limits during loading, and every host reaches startup.
Troubleshooting¶
| Symptom | Cause | Fix |
|---|---|---|
| Startup waits on the other hosts and never completes | A host not started, or a wrong host 0 address | Start vllm serve on every host; use host 0's internal IP in --master-addr or --data-parallel-address |
| Nothing answers on port 8000 of a host other than 0 | Only host 0 serves the OpenAI entrypoint; the others are headless | Send requests to host 0 |
| Mode B ranks do not line up | Each host must start at its first global DP rank | --data-parallel-start-rank 0 on host 0 and 8 on host 1 with 8 local ranks |
| Ray actors ignore MoE or kernel settings | Only VLLM_ variables are forwarded |
List them in VLLM_RAY_EXTRA_ENV_VARS_TO_COPY |
| Layout refused | Device count differs from the slice | Recount \(DP \times TP \times PP \times PCP\) in devices |
| On GKE, hosts land on separate slices | Two Jobs for one slice | One indexed Job per slice (Run vLLM-TorchTPU on GKE) |