Skip to main content
How LLM serving worksLesson 8 of 9

Splitting a Model Across GPUs (TP, PP, EP)

A 70B model in 16-bit weights takes about 140 GB. One 80 GB GPU cannot hold it, let alone its KV cache. Follow the same model as it is copied, split by layer width, split by layer depth and spread by expert, and see what each choice sends between GPUs.

Layout1 GPU
Weights per GPU140 GB > 80 GB
Between GPUs—
KV cache roomnone
Node A · 4 GPUs on NVLinkNode B · 4 GPUs on NVLinkModel weights70B · FP16 ≈ 140 GBGatewayRequestsLeaderWorkerSet1 replica = 1 groupGPU 080 GBDoes not fitGPU 180 GBGPU 280 GBGPU 380 GBGPU 480 GBGPU 580 GBGPU 680 GBGPU 780 GB140 GB?
RequestResponse / reportWatchAppears in a later step

What you will learn

  • Data parallelism copies the model, it does not split it
  • Tensor parallelism splits every layer and talks after every layer
  • Why splitting frees room for the KV cache
  • Pipeline parallelism splits the layer stack across nodes
  • Expert parallelism spreads MoE experts and routes tokens all-to-all
  • One replica across nodes on Kubernetes, and why it fails as a unit

Four ways to split, compared​

KindWhat is splitTraffic between GPUsWhere it fits
Data parallel (DP)Nothing: full copiesNone while servingMore throughput when one copy fits
Tensor parallel (TP)The matrices inside every layerAll-reduce about twice per layer, every stepInside one node, over NVLink or similar
Pipeline parallel (PP)The layer stack, into stagesActivations at each stage boundary, point to pointAcross nodes, when one node is not enough
Expert parallel (EP)MoE experts, placed on different GPUsAll-to-all token routing every MoE layerMoE models, combined with DP or TP for attention

They combine. A large deployment can be TP inside each node, PP across nodes, and DP for many such replicas.

Try it yourself​

nvidia-smi topo -m # NV# = NVLink between GPUs, SYS/PHB = slower paths
vllm serve <model> --tensor-parallel-size 4 # e.g. vLLM: one node, 4 GPUs
vllm serve <model> --tensor-parallel-size 4 \
--pipeline-parallel-size 2 # 8 GPUs over 2 nodes (needs a multi-node runtime such as Ray)
vllm serve <moe-model> --tensor-parallel-size 8 --enable-expert-parallel # MoE experts spread over GPUs
kubectl get leaderworkerset -A # Groups and their size
kubectl get pods -L leaderworkerset.sigs.k8s.io/worker-index # 0 = leader, 1.. = workers

Check yourself

  1. Why should a tensor parallel (TP) group stay inside one node?
  2. A model needs two nodes per replica. The leader Pod starts on node A, but node B has no free GPUs. What prevents node A's GPUs from being held for nothing?
  3. Requests queue because the KV cache is full on a replica running with TP 2. Besides adding replicas, what can help?

Further reading: vLLM parallelism and scaling · LeaderWorkerSet · Megatron-LM paper · Kueue · How the KV Cache Fills Up · Splitting Prefill and Decode · Requesting GPUs by Criteria (DRA)