Education › Inference › Stage 5: Parallelism & GPU networking

When one GPU isn't enough

Tensor, pipeline, data and expert parallelism: what each splits, what it costs, and when to use it.

Advanced ~35 min read Module 9 of 15

Some models do not fit on one GPU, and some workloads need more throughput than one GPU can give. The answer is parallelism, but there are four different ways to split the work, and each trades memory, latency, throughput and communication differently. This lesson explains tensor, pipeline, data and expert parallelism, shows the sizing arithmetic that tells you when you need them, and gives you a rule of thumb for combining them across GPUs and nodes.

After this module you can
  • Decide when a model needs more than one GPU from its size and your context needs
  • Explain what tensor, pipeline, data and expert parallelism each split
  • Predict the communication each strategy needs and where it should run
  • Combine strategies for multi-GPU and multi-node deployments
  • Avoid the common mistake of adding parallelism that adds latency without benefit

When one GPU isn't enough

Start with memory. A model needs its weights plus enough KV cache for useful concurrency plus working space. A 70-billion-parameter model in FP16 is about 140 GB of weights: it cannot fit on one 80 GB GPU at all, and two would leave little room for cache, so four is the practical minimum. In FP8 the same model is about 70 GB, which technically fits on one 80 GB card but leaves almost no cache, so two GPUs is still the sensible floor. A model of around 405 billion parameters is roughly 405 GB in FP8 and 810 GB in FP16: one eight-GPU node in FP8, two nodes in FP16.

The second reason is throughput: a model fits on one GPU, but you need more requests per second than one GPU serves within your latency target. That calls for copies, not splitting, and it is a different strategy entirely.

The four strategies

StrategySplitsCommunicationBest for
Tensor (TP)Each layer's weight matrices across GPUsAll-reduce inside every layerFitting a model; lower latency per token; within one node
Pipeline (PP)Groups of layers into stages on different GPUsActivations passed stage to stageSpanning nodes over slower links
Data (DP)Nothing: full replicasNone between replicasMore throughput when the model fits
Expert (EP)Experts of a mixture-of-experts modelAll-to-all token routing per MoE layerLarge MoE models

Tensor parallelism cuts each big matrix into slices, one per GPU; each GPU computes its slice and the partial results are combined with an all-reduce, typically twice per transformer layer. Every GPU holds a fraction of the weights and of the KV cache, and because work per token is split, per-token latency can drop. The price is constant, latency-sensitive communication, which is why TP belongs on NVLink inside a node, usually at 2, 4 or 8.

TENSOR PARALLEL: INSIDE ONE NODEPIPELINE PARALLEL: ACROSS NODESall-reduce every layeractivations once/stepGPU 0half of each layerGPU 1half of each layerNode Alayers 1-40Node Blayers 41-80
Tensor parallelism splits every layer across GPUs and all-reduces inside each layer; pipeline parallelism gives each GPU whole layers and only passes activations between stages.

Pipeline parallelism puts the first layers on one GPU, the next on another, and so on. Only activations cross between stages, once per stage, so it tolerates slower links and is the usual way to span nodes. It does not make a single token faster; each extra stage adds a hop. Throughput depends on keeping every stage busy with different micro-batches; idle stages are called bubbles.

Data parallelism simply runs more copies behind a load balancer. Expert parallelism places the experts of a mixture-of-experts model on different GPUs and sends each token to the GPUs holding its chosen experts, an all-to-all exchange per MoE layer that needs a fast fabric and good load balancing across experts.

Combining them

  • Fits on one GPU with room for cache: no splitting. Add replicas (DP) for throughput.
  • Needs several GPUs, fits in one node: TP across that node's NVLink-connected GPUs, then replicate the whole TP group for throughput.
  • Needs more than one node: TP inside each node, PP across nodes (for example TP 8, PP 2 on two eight-GPU nodes).
  • Large MoE model: EP for the expert layers, often with DP or TP for the attention layers; engines expose this as a combination of flags.
  • Very long contexts: context or sequence parallelism splits the sequence itself across GPUs, an advanced option some engines provide.
The same choices expressed as engine flags
bash
# one node, 4 GPUs, model split four ways
vllm serve "$MODEL_ID" --tensor-parallel-size 4

# two nodes of 8 GPUs: TP inside each node, PP across nodes
vllm serve "$MODEL_ID" --tensor-parallel-size 8 --pipeline-parallel-size 2

# TensorRT-LLM equivalents
trtllm-serve "$MODEL_ID" --tp_size 8 --pp_size 2
Watch out

More parallelism is not automatically better. TP 8 on a model that fits comfortably on 2 GPUs spends most of its time communicating; four TP-2 replicas usually deliver far more throughput from the same eight GPUs. Use the smallest split that fits your model and cache, then replicate.

Choosing with numbers

A reliable procedure: compute weight memory at your precision; decide the KV cache you need from your concurrency and context targets (the KV-cache lesson's formula); add about 10% for overhead; divide by usable memory per GPU and round up to a power of two for TP. If that exceeds one node, add pipeline stages across nodes. Then benchmark the candidate layouts, for example TP 4 with two replicas versus TP 8 with one, on your workload, and pick the higher goodput per GPU.

Remember what each choice does to the KV cache: TP splits it across GPUs too, so a TP 4 group holds four times the cache of one GPU minus the weights, which is often why moving from TP 2 to TP 4 increases concurrency more than you expect.

Hands-on practice

Plan, then measure, a multi-GPU layout

  1. Pick a model too large for one of your target GPUs and compute its weight memory in FP16 and FP8.
  2. Choose concurrency and context targets and compute the KV cache needed; add 10% overhead and work out the minimum TP size.
  3. On a multi-GPU instance, serve a smaller model at TP 1, TP 2 and TP 4 (if available) and record per-token latency at concurrency 1.
  4. At a fixed total of four GPUs, compare one TP 4 server with two TP 2 servers behind a simple load balancer at high concurrency; record total throughput.
  5. Explain the results using communication cost and KV-cache capacity.
  6. Write a recommendation for your original large model: TP, PP, DP sizes and why.
Cheat sheet

When one GPU isn't enough — at a glance

Main things to focus on

  • Split only when memory (weights + cache) or latency demands it; otherwise replicate.
  • TP splits layers, all-reduces every layer, belongs on NVLink inside a node.
  • PP splits layers into stages, tolerates slow links, adds per-hop latency.
  • DP is replicas: throughput without communication.
  • EP spreads MoE experts with all-to-all routing.
  • Smallest TP that fits, then replicate; benchmark layouts by goodput per GPU.

Sizing

weights = params x bytes70B FP16 ~ 140 GB; FP8 ~ 70 GB
need = weights + KV(target) + 10%Total memory for the deployment
TP = next power of 2 >= need / usable_per_GPUMinimum tensor-parallel size
PP = nodes needed when TP exceeds one nodePipeline stages across nodes

Flags

vllm: --tensor-parallel-size NTP
vllm: --pipeline-parallel-size NPP
vllm: --data-parallel-size NDP inside one engine
trtllm-serve: --tp_size --pp_size --ep_sizeTensorRT-LLM equivalents

Communication

TP: all-reduce, ~2 per layerLatency-critical, needs NVLink
PP: send/recv of activations per stageTolerates inter-node links
EP: all-to-all per MoE layerBandwidth-heavy, load-balance experts
DP: none between replicasOnly a load balancer

Decision rules

fits on 1 GPU with cache room -> DP onlyReplicate for throughput
fits in 1 node -> TP within node, then DPSmallest TP that fits
spans nodes -> TP in node x PP across nodese.g. TP 8, PP 2
MoE -> EP for experts (+ DP/TP for attention)Fast fabric needed

Common pitfalls

  • TP across nodes over slow links, so every layer waits on the network.
  • Huge TP for a small model, wasting GPUs on communication.
  • Forgetting KV cache when deciding the minimum GPU count.
  • Expecting pipeline parallelism to cut per-token latency.
  • Choosing a layout without benchmarking alternatives on the same GPU budget.
Quiz

Check your understanding

5 questions · 4 to pass · answers are explained as you go. Your best score is saved on this device only.

Progress and quiz scores are saved in this browser only. Back up or restore on the hub.

Was this lesson useful? Tell me what to improve →