Pidoku

Multi-Node Inference

Module 9 Lesson 9.h 1h 15m Difficulty 4/5

Prerequisites 9.c, 9.f, 9.g, 14.d


Before you start: words you need#

WordPlain meaning
NodeOne physical server, usually with 8 GPUs joined by NVLink. Two nodes talk over the network (InfiniBand or RDMA Ethernet, 9.c).
InstanceOne running copy of the model that answers requests. A multi-node instance is one copy spread over several nodes.
RankOne process in the distributed job, usually driving one GPU (9.f).
RendezvousThe start-up moment when every rank finds the others and they agree who is who. If one rank is missing, everyone waits.
Gang schedulingPlacing all the pieces of a job at once, or none of them. Without it, half a job can sit on GPUs waiting forever for the other half.
LeaderWorkerSet (LWS)A Kubernetes add-on that runs a group of pods (one leader, several workers) as one unit: created, restarted and upgraded together.
HangA rank waiting forever in a collective because a partner died. The GPUs look busy and do nothing.
NVL72 / multi-node NVLinkA rack of 72 GPUs on 18 trays (separate nodes) joined by NVLink, not the network (9.c).

1. What is it?#

Running one model instance across more than one physical machine. Each node holds part of the model, and every token’s forward pass crosses the network at least once.

It is a step change in operational complexity: more failure modes, slower starts and upgrades, fabric problems that look like software problems. So the first question is always: can you avoid it?

When you cannot, the shape is well known: tensor parallelism inside each node, pipeline parallelism across nodes (9.g derives why), started by Ray or vLLM’s own multi-node launcher, and run on Kubernetes as an all-or-nothing group with LeaderWorkerSet.

Facts checked on 13 November 2026.


2. Why does it matter?#

  • Some models do not fit on one node. A frontier dense model in BF16, or a large MoE model with long contexts, can need more memory than eight GPUs have.
  • Many teams go multi-node when they did not have to. The cost (network configuration, failure handling, deployment coordination, debugging across machines) is large and permanent, and it often buys nothing that FP8 or a bigger GPU would not.
  • When it is needed, the details decide whether it works. A single misconfigured NIC, a missing timeout or a pod restarted on its own turns a working deployment into a slow or hung one.

3. Simple analogy#

One surgical team in one theatre, versus two teams in two buildings operating on the same patient over a phone line.

One team: coordination is trivial. Two teams: it is possible and occasionally necessary. But they must start at the same moment, every instruction waits for the phone line, and if one team stops answering, the other team stands still holding the scalpel. Everything that can go wrong now has twice the surface area.


4. Tiny example: can you avoid it?#

Llama-3.1-405B in BF16 is 810 GB of weights; an 8×H100 node has 640 GB. It looks like a two-node model. The program in section 6 checks the alternatives, keeping 10% of memory in reserve and asking for room for 64 sequences of 8k tokens:

option                        GPUs  weights/GPU  KV room  8k seqs  ITL @64
2 x 8 H100, BF16, TP8 x PP2     16      50.6 GB   342 GB       81   32.3 ms
1 x 8 H100, FP8 weights+KV       8      50.6 GB   171 GB       81   18.2 ms
1 x 8 H200, BF16                 8     101.2 GB   205 GB       49         -
1 x 8 H200, FP8 weights+KV       8      50.6 GB   610 GB      289   13.6 ms
1 x 8 B200, FP8 weights+KV       8      50.6 GB   891 GB      421    8.4 ms
  • FP8 on one H100 node holds as many sequences as the two-node BF16 layout, on half the GPUs, with lower inter-token latency (no pipeline stage to wait for).
  • H200 in BF16 fits the weights but only 49 long sequences. It would serve, at lower concurrency.
  • H200 or B200 with FP8 leaves room for hundreds of sequences.

Before going multi-node, exhaust these:

1. QUANTISE. FP8 weights halve the model, INT4 quarters it (13.b). Check quality on your own
   evaluation; FP8 is usually close to BF16 for large models (13.e).
2. QUANTISE THE KV CACHE. FP8 KV halves the per-token cost (13.h).
3. USE A BIGGER-MEMORY GPU. H200 141 GB; B200 180 GB usable in an 8-GPU HGX/DGX node
   (192 GB on the package); B300 288 GB (7.c).
4. USE A SMALLER MODEL. Is the 405B really better than a 70B for your task? Measure it.
5. LOWER max_model_len or concurrency if the workload allows.

Only if all of these fail: go multi-node.

5. Technical explanation#

The canonical layout#

flowchart LR
  subgraph N0["Node 0: layers 0–62"]
    direction TB
    A0["8 GPUs, TP = 8<br/>2 all-reduces per layer<br/>over NVLink"]
  end
  subgraph N1["Node 1: layers 63–125"]
    direction TB
    A1["8 GPUs, TP = 8<br/>2 all-reduces per layer<br/>over NVLink"]
  end
  A0 -->|"one activation send per step<br/>InfiniBand / RDMA, ~1 MB"| A1
  A1 -.->|"next token"| A0

  class A0,A1 compute
  • TP = GPUs per node keeps the 2 all-reduces per layer on NVLink.
  • PP = number of nodes crosses the network once per stage boundary, with a small message that tolerates latency.

Why not TP = 16? 9.g example 3. A flat ring across nodes is hopeless. A hierarchical all-reduce makes it workable on paper, but it replicates KV heads (half the KV capacity for an 8-KV-head model) and puts 252 network round trips on every token’s critical path.

Why not PP = 16? Bubbles and latency. Each token passes all 16 stages in turn, and keeping 16 stages busy needs at least 16 micro-batches in flight (14.d).

MoE models add a third option: expert parallelism across nodes with wide all-to-alls (DeepSeek-style “wide EP”, 14.h), usually with prefill and decode disaggregated (14.j). The network then carries every MoE layer’s token dispatch, so 400–800 Gb/s RDMA per GPU and the low-latency all-to-all kernels in 14.e become essential.

The rack is the new node: NVL72#

On GB200 and GB300 NVL72, 72 GPUs on 18 trays share one NVLink domain (9.c). Each tray is a separate Linux host, so the job is “multi-node” for launching and scheduling, but the GPUs talk over NVLink at 900 GB/s each way, not over the network. Wide TP or EP inside the rack then uses NVLink costs. On Kubernetes, NVIDIA’s DRA driver groups the trays into a ComputeDomain, which sets up the cross-node memory sharing (IMEX) that multi-node NVLink needs. Everything below about launch, failure and upgrades still applies.

What breaks when you go multi-node#

Networking#

REQUIRED
  ✓ RDMA: InfiniBand or properly configured RoCE (lossless, or with congestion control, 9.c)
  ✓ GPUDirect RDMA working: the NIC reads GPU memory directly (9.e)
  ✓ NCCL pointed at the right NICs (NCCL_IB_HCA) and bootstrap interface (NCCL_SOCKET_IFNAME)
  ✓ The same MTU everywhere (RoCE usually: 9000-byte Ethernet jumbo frames, 4096-byte RDMA MTU)
  ✓ In containers: the RDMA devices, IPC_LOCK, and a large /dev/shm

VERIFY BEFORE DEPLOYING
  ib_write_bw between every node pair          (perftest)
  all_reduce_perf across nodes                 (nccl-tests, 9.f)
  NCCL_DEBUG=INFO shows NET/IB/.../GDRDMA, not NET/Socket

A single misconfigured node makes the whole instance slow, and the symptom is “everything is slower”, not “node 3 is broken”. Test pairwise. vLLM’s documentation gives the same check: [send] via NET/IB/GDRDMA is good, [send] via NET/Socket means plain TCP.

Launch and coordination#

Every rank must start, find the others, and initialise NCCL together.

Shell
# vLLM's own launcher (multiprocessing backend), two nodes of 8 GPUs
vllm serve <model> --tensor-parallel-size 8 --pipeline-parallel-size 2 \
  --nnodes 2 --node-rank 0 --master-addr <head-ip>              # on node 0
vllm serve <model> --tensor-parallel-size 8 --pipeline-parallel-size 2 \
  --nnodes 2 --node-rank 1 --master-addr <head-ip> --headless   # on node 1

# Ray: vLLM's default backend for multi-node
ray start --head                       # node 0
ray start --address=<head-ip>:6379     # node 1
vllm serve <model> --tensor-parallel-size 8 --pipeline-parallel-size 2 \
  --distributed-executor-backend ray

# PyTorch programs in general
torchrun --nnodes=2 --nproc_per_node=8 --rdzv_backend=c10d \
         --rdzv_endpoint=<head-ip>:29500 serve.py

vLLM also ships examples/ray_serving/run_cluster.sh to start the Ray containers on each node (19.a).

Start-up coordination is the most common source of multi-node failures. A rank that does not start, starts late, or cannot reach the rendezvous address hangs the whole job.

Failure handling#

SINGLE NODE:  a GPU fails → the process crashes → restart the process
MULTI-NODE:   a GPU fails → that rank dies → every other rank HANGS in its next collective
              → after a timeout, the whole group must be torn down and restarted
              → every node reloads its shard of the model: minutes

There is no NCCL_TIMEOUT variable (9.f). Hang protection comes from the framework: in PyTorch, the timeout of init_process_group (10 minutes by default for NCCL) bounds a stuck collective, and TORCH_NCCL_ASYNC_ERROR_HANDLING (on by default) turns the failure into a crash. NCCL now offers ncclCommAbort and ncclCommShrink, but serving stacks still mostly restart the whole group (23.e).

A practical supervision recipe:

1. A deliberate collective timeout, so a hang becomes a crash.
2. A supervisor that restarts ALL ranks when ANY fails (LeaderWorkerSet, Ray, or your own).
3. Readiness gating, so no traffic arrives until every rank has loaded and warmed up.
4. A cap and backoff on restarts, so a broken node does not cause an endless restart loop.
5. Alerts on restart frequency, per node.

Deployment#

Rolling a multi-node instance means:
  draining in-flight requests (minutes for long generations)
  stopping all ranks
  starting all ranks with the new version
  loading the model on every node (minutes)
  warming up (CUDA graphs, compilation)
  → typically 10–20 minutes during which that instance does not serve

Mitigation: run at least two multi-node instances and roll them one at a time, which doubles your minimum footprint. That is why multi-node has a high minimum cost: for availability you need at least two of the most expensive thing you run.


6. Under the hood#

The Kubernetes shape#

YAML
# LeaderWorkerSet v1.0 (Oct 2026): one leader pod + workers, managed as one group
apiVersion: leaderworkerset.x-k8s.io/v1
kind: LeaderWorkerSet
metadata:
  name: llama-405b
spec:
  replicas: 2 # two multi-node instances
  leaderWorkerTemplate:
    size: 2 # pods per instance: one per node
    restartPolicy: RecreateGroupOnPodRestart # the default: one pod fails → recreate the group
    maxGroupRestarts: 5 # v1.0: give up instead of looping forever
    restartBackoff: { baseSeconds: 10, capSeconds: 300 }
    leaderTemplate:
      spec:
        containers:
          - name: vllm-leader
            command: ["sh", "-c"]
            args:
              - vllm serve meta-llama/Llama-3.1-405B-Instruct --port 8080
                --tensor-parallel-size 8 --pipeline-parallel-size $(LWS_GROUP_SIZE)
                --nnodes $(LWS_GROUP_SIZE) --node-rank $(LWS_WORKER_INDEX)
                --master-addr $(LWS_LEADER_ADDRESS)
            resources:
              limits:
                nvidia.com/gpu: 8
                rdma/hca_shared_devices_a: 1 # name set by your RDMA device plugin
    workerTemplate:
      spec:
        containers:
          - name: vllm-worker
            # same command plus --headless; same limits

LWS injects LWS_LEADER_ADDRESS, LWS_GROUP_SIZE and LWS_WORKER_INDEX into every pod, so each rank knows where the rendezvous is and who it is. This is the pattern in vLLM’s LWS guide (19.e). Not shown: a memory-backed /dev/shm volume, which multi-GPU engines need.

RecreateGroupOnPodRestart encodes the all-or-nothing rule: if one pod dies, the whole group is recreated. With None, Kubernetes restarts only the failed pod, and the survivors hang waiting for it. maxGroupRestarts and restartBackoff (new in LWS v1.0.0, 16 October 2026) stop a bad node from causing endless restarts.

The RDMA resource name depends on how your cluster exposes NICs: NVIDIA’s Network Operator, an SR-IOV plugin or the RDMA shared-device plugin all name it differently. Check with your platform team (21.c).

Gang scheduling#

All pods of an instance must be placed at the same time, or you get partial placements: one pod holding 8 GPUs, waiting forever for a second node that is not free. Options:

  • Kueue or Volcano, both of which LWS integrates with;
  • native Kubernetes gang scheduling (the Workload and PodGroup APIs), beta since Kubernetes v1.37 but still off by default, behind the GenericWorkload feature gate;
  • topology-aware placement, so both nodes sit under the same leaf switch or in the same NVL72 rack (21.e).

The fit-check program#

The program behind section 4. It uses the same cost model as 9.g: weight reads from HBM plus two-shot all-reduces inside each node, and one InfiniBand send between stages.

Go
// fitcheck.go: does Llama-3.1-405B really need two nodes?
package main

import "fmt"

const (
	params = 405e9
	layers = 126.0
	hidden = 16384.0
	kvTok  = 2 * layers * 8 * 128 // K and V elements per token (8 KV heads, dim 128)
	seqLen = 8192.0               // tokens per sequence
	batch  = 64.0                 // sequences in flight for the latency estimate
)

type option struct {
	name           string
	nodes, perNode float64
	memGB, hbmTBs  float64 // per GPU
	nvlinkGBs      float64 // per GPU, one direction
	wBytes, kvB    float64 // bytes per weight, bytes per KV element
}

func main() {
	opts := []option{
		{"2 x 8 H100, BF16, TP8 x PP2", 2, 8, 80, 3.35, 450, 2, 2},
		{"1 x 8 H100, FP8 weights+KV", 1, 8, 80, 3.35, 450, 1, 1},
		{"1 x 8 H200, BF16", 1, 8, 141, 4.8, 450, 2, 2},
		{"1 x 8 H200, FP8 weights+KV", 1, 8, 141, 4.8, 450, 1, 1},
		{"1 x 8 B200, FP8 weights+KV", 1, 8, 180, 8.0, 900, 1, 1},
	}
	fmt.Println("option                        GPUs  weights/GPU  KV room  8k seqs  ITL @64")
	for _, o := range opts {
		gpus := o.nodes * o.perNode
		w := params * o.wBytes / gpus // bytes per GPU
		room := gpus*o.memGB*1e9*0.9 - params*o.wBytes
		seqs := room / (kvTok * o.kvB * seqLen)
		itl := "  -"
		if seqs >= batch {
			// each stage: read its weights, plus 2 all-reduces per layer it owns (two-shot, 9.f)
			msg := batch / o.nodes * hidden * 2 // BF16 activations per micro-batch
			ar := 2*2e-6 + 2*(o.perNode-1)/o.perNode*msg/(o.nvlinkGBs*1e9)
			stage := w/(o.hbmTBs*1e12) + 2*layers/o.nodes*ar
			send := (o.nodes - 1) * (5e-6 + msg/50e9) // InfiniBand hop between stages
			itl = fmt.Sprintf("%5.1f ms", (o.nodes*stage+send)*1e3)
		}
		fmt.Printf("%-29s %4.0f %9.1f GB %5.0f GB %8.0f %9s\n", o.name, gpus, w/1e9, room/1e9, seqs, itl)
	}
}

Output:

option                        GPUs  weights/GPU  KV room  8k seqs  ITL @64
2 x 8 H100, BF16, TP8 x PP2     16      50.6 GB   342 GB       81   32.3 ms
1 x 8 H100, FP8 weights+KV       8      50.6 GB   171 GB       81   18.2 ms
1 x 8 H200, BF16                 8     101.2 GB   205 GB       49         -
1 x 8 H200, FP8 weights+KV       8      50.6 GB   610 GB      289   13.6 ms
1 x 8 B200, FP8 weights+KV       8      50.6 GB   891 GB      421    8.4 ms

7. Performance implications#

  • The pipeline costs latency, not throughput. With TP = 8 × PP = 2 each token passes both nodes in turn: 32 ms against 18 ms for one FP8 node in the table. Throughput can match, if enough micro-batches keep both stages busy (14.d).
  • Cross-node communication per step is tiny in the canonical layout: one ~1 MB send per boundary. If profiling shows lots of network traffic, check that the TP group did not end up spanning nodes.
  • Stragglers set the pace. The slowest node, NIC or GPU paces every step of the instance. One GPU throttling on temperature slows the other fifteen.
  • Cold start is longer. Every node loads its shard, from storage that all nodes hit at once (19.e, 20.g). The instance is ready only when the slowest node is.
  • On NVL72 racks the numbers change. NVLink across trays makes wide TP and EP viable, so the “TP inside, PP across” rule applies at rack boundaries instead of node boundaries.

8. Production implications#

  • Avoid multi-node if you can. Quantise, use bigger-memory GPUs, or use a smaller model.
  • If you must: TP inside nodes (or racks), PP across. Cross-node TP only after measuring it.
  • Verify RDMA and GPUDirect before deploying, pairwise between all nodes, and again after any hardware or driver change.
  • Set a collective timeout and supervise all-or-nothing, with a restart cap and backoff.
  • Run at least two instances for availability during upgrades and failures.
  • Use gang scheduling and topology-aware placement. Partial placements waste GPUs.
  • Test the failure path. Kill one rank and check that the group restarts cleanly within your timeout, and that the router stops sending it traffic in the meantime.
  • Monitor per-node health. One degraded node slows the whole instance, and the symptom looks global.

9. Common mistakes#

  1. Going multi-node without trying FP8 or a bigger GPU.
  2. Tensor parallelism across nodes by accident, for example TP = 16 because “we have 16 GPUs”.
  3. Relying on NCCL_TIMEOUT. It does not exist; a failure becomes an indefinite hang.
  4. Restarting one pod instead of the group. The remaining ranks hang.
  5. No gang scheduling. Partial placements hold GPUs and never serve.
  6. Not verifying GPUDirect RDMA. NCCL silently falls back to slower paths or plain TCP.
  7. Running one instance. No availability during upgrades.
  8. Assuming the fabric is fine because one pair of nodes works. Test all pairs.

10. Hands-on exercise#

A. The avoidance check. Change fitcheck.go for a model you think needs multi-node (try a large MoE model, using its total parameters for memory). Which single-node options fit at your context length and concurrency?

B. Verify the fabric. If you have multi-node access: run ib_write_bw between every node pair, then all_reduce_perf across nodes. Is any pair slower? Confirm GDRDMA with NCCL_DEBUG=INFO.

C. Measure both layouts. Run TP = 8 × PP = 2 and TP = 16 with vLLM. Measure ITL and throughput at two concurrencies. Compare with 9.g’s predictions.

D. Test the failure path. Kill one rank of a multi-node job. Measure how long until the group notices, how long until it restarts, and how long until it serves again. Is your timeout right?

E. Cold start. Measure multi-node cold start end to end. Which node is slowest, and why? Is model loading parallel across nodes?


11. Interview questions#

  1. What should you try before going multi-node?
  2. What is the canonical multi-node layout, and why?
  3. What happens when one rank of a multi-node job fails, and how do you recover?
  4. Why do you need at least two multi-node instances in production?
  5. What is gang scheduling, and why does multi-node inference need it?
  6. How would you verify a multi-node fabric before deploying?
  7. Why might a single-node FP8 deployment beat a two-node BF16 one?
  8. How does an NVL72 rack change the multi-node picture?

12. Further reading#

Checked on 13 November 2026.

↑↓ navigate↵ openesc close

100% drag to pan · scroll or pinch to zoom · double-click to zoom in