Home / AI & GenAI

AI & GenAIHow-toAdvanced

Serving a model too big for one GPU node with vLLM: tensor and pipeline parallelism across nodes with Ray

Run one vLLM server across two or more GPU nodes. Covers choosing tensor vs pipeline parallel sizes, building the Ray cluster, pinning NCCL to the right network, verifying it, and the failure modes you inherit.

Deepak Bhardwaj7 min read

Applies tovLLM 0.8+ (V1 engine) with Ray, NVIDIA GPU nodes with NVLink in-node and InfiniBand/RoCE or fast Ethernet between nodes, Kubernetes with LeaderWorkerSet optional; flags vary by version

When you actually need this

Use multi-node serving only when the model's weights plus a useful KV cache don't fit on one node, even after quantization. Before you build it, check these alternatives:

  • FP8 or INT4 weights on one 8-GPU node, which roughly halves or quarters the weight memory.
  • A smaller or distilled model that passes your evaluation set.
  • A managed endpoint for the one model that needs it.

A multi-node server is a single failure domain spread over more hardware. If one GPU, NIC or pod goes down, the whole server goes down. Plan your replicas and capacity around that.

Choose the parallel layout

Layout Traffic pattern Network need Good for
TP = GPUs per node, PP = number of nodes All-reduce inside the node; activations pass between nodes once per stage Moderate between nodes Default choice
TP across all GPUs on all nodes All-reduce across nodes on every layer InfiniBand/RoCE with GPUDirect RDMA Lowest latency, only on very fast fabrics
PP only Point-to-point between stages Low Nodes without NVLink; throughput over latency
Data parallel (separate servers) None between replicas None When the model fits on one node: always prefer this

The vLLM docs recommend tensor parallel size = GPUs per node and pipeline parallel size = number of nodes. For two 8-GPU nodes, that is --tensor-parallel-size 8 --pipeline-parallel-size 2.

Pipeline parallelism adds a stage-to-stage hop per forward pass, so single-request latency is a little worse. It keeps all-reduce traffic on NVLink, which matters far more than that hop.

Prerequisites on every node

All nodes must run the same environment, or Ray workers fail in confusing ways:

  • The same container image, which means the same vLLM, PyTorch, CUDA and NCCL versions.
  • The model weights at the same path on every node: a shared read-only volume, or an identical local copy.
  • Matching GPU models and driver versions.
  • Open ports between nodes for Ray (head port, default 6379) and NCCL (ephemeral TCP, plus RDMA if used).

Check the in-node fabric first:

nvidia-smi topo -m          # expect NV# links between GPUs, not PHB/SYS
ibv_devinfo | grep -E 'hca_id|state|link_layer'   # if using InfiniBand/RoCE

Build the Ray cluster

Set the network interfaces explicitly. Otherwise NCCL may pick a management NIC or a Docker bridge, and you get timeouts or very slow throughput.

# On every node (adjust interface names to your hosts)
export NCCL_SOCKET_IFNAME=ib0          # or the high-speed Ethernet interface
export GLOO_SOCKET_IFNAME=ib0
export NCCL_IB_HCA=mlx5                # only with InfiniBand/RoCE
export VLLM_HOST_IP=$(ip -4 addr show ib0 | awk '/inet /{print $2}' | cut -d/ -f1)

Head node:

ray start --head --port=6379 --node-ip-address="$VLLM_HOST_IP"

Each worker node:

ray start --address="<head-ip>:6379" --node-ip-address="$VLLM_HOST_IP"

Verify before you start vLLM:

ray status            # expect 16 GPUs for 2 x 8
ray list nodes        # every node ALIVE, with the expected IPs

vLLM also ships a helper script for this (multi-node-serving.sh with leader and worker roles) in its examples. Use it if you would rather not write your own entrypoint.

Start vLLM on the head node only

vllm serve /models/llama-3.1-405b-instruct-fp8 \
  --served-model-name llama-405b \
  --tensor-parallel-size 8 \
  --pipeline-parallel-size 2 \
  --distributed-executor-backend ray \
  --max-model-len 32768 \
  --gpu-memory-utilization 0.90 \
  --host 0.0.0.0 --port 8000

Only the head node serves HTTP. The worker nodes host Ray actors that hold their share of the layers.

Warning

Turn on NCCL_DEBUG=INFO for the first start and read which transport NCCL chose. Lines that mention NET/Socket when you expected NET/IB mean inter-node traffic is going over TCP. The server still works, but at a fraction of the throughput. Turn the variable off afterwards, because it is noisy.

NCCL_DEBUG=INFO vllm serve ... 2>&1 | grep -E 'NET/|Using network|NCCL INFO Channel' | head

Verify it works

curl -s localhost:8000/v1/models | jq '.data[].id'
curl -s localhost:8000/v1/chat/completions -H "Content-Type: application/json" \
  -d '{"model":"llama-405b","messages":[{"role":"user","content":"Reply with OK"}],"max_tokens":5}'

Then benchmark with your real prompt and output lengths, and compare the result with a single-node baseline of a quantized variant:

vllm bench serve --model llama-405b --base-url http://localhost:8000 \
  --dataset-name random --random-input-len 2000 --random-output-len 300 \
  --num-prompts 300 --max-concurrency 32

On older releases, the benchmark is benchmarks/benchmark_serving.py in the vLLM repo, not vllm bench serve.

Watch these metrics on the head node's /metrics:

Metric Meaning on multi-node
vllm:time_to_first_token_seconds Rises sharply if inter-node links are slow (prefill crosses stages)
vllm:num_requests_waiting Queueing; with PP, too few concurrent requests leaves stages idle
vllm:kv_cache_usage_perc (older: vllm:gpu_cache_usage_perc) KV pressure; names vary by version

Pipeline stages only stay busy when several requests are in flight. A multi-node PP server looks slow in single-request tests and much better at realistic concurrency, so test at realistic concurrency.

Running it on Kubernetes

Use a group-aware controller so leader and workers are scheduled, restarted and scaled as one unit. LeaderWorkerSet (LWS) is the pattern the vLLM docs show. The essentials:

  • size: 2 (one leader and one worker per group); each pod requests nvidia.com/gpu: 8.
  • The leader runs ray start --head and then vllm serve; the worker runs ray start --address=$(LWS_LEADER_ADDRESS):6379 --block.
  • Use restartPolicy: RecreateGroupOnPodRestart, so a failed worker recreates the whole group instead of leaving a half-alive server.
  • Add a readiness probe on the leader's /health and a long startup probe, because loading hundreds of GB of weights takes many minutes.
  • Give it a /dev/shm volume (emptyDir with medium: Memory) and, for RDMA, the device plugin resources your fabric needs.

Caution

Don't put a multi-node group on spot or preemptible nodes without spare capacity. Losing any one node kills the whole server and the cold start is long. Keep at least N+1 groups for production, or a smaller fallback model behind the same gateway route.

Failure modes you inherit

Symptom Cause Fix
Hangs at start-up, then NCCL timeout Wrong interface, firewall, or one node on a different image Set NCCL_SOCKET_IFNAME/GLOO_SOCKET_IFNAME, check ports, compare image digests
ray status shows fewer GPUs Worker joined with the wrong IP or no GPU visibility Check --node-ip-address and the GPU device plugin
Low throughput, high TTFT NCCL fell back to sockets Check NCCL_DEBUG=INFO for NET/IB
Whole server dies when one pod restarts Expected: one failure domain Group restart policy, N+1 groups
Placement group creation hangs Not enough free GPUs in the Ray cluster Remove stale Ray actors, or restart the Ray cluster

Prevent it next time

  • Record a known-good baseline (tokens/s and TTFT at fixed concurrency) and rerun it after every image, driver or fabric change.
  • Pin image digests, not tags, so all nodes are guaranteed identical.
  • Alert on group restarts and on NCCL transport fallbacks found in logs.
  • Review every quarter whether a quantized single-node deployment now passes your evaluation. It is cheaper and simpler to run.