Pidoku

Why Distribute (and When Not To)

Module 14 Lesson 14.a 1h Difficulty 3/5

Prerequisites 2.f, 4.e, 12.f, 9.c


Before you start: words you need#

WordPlain meaning
ReplicaOne complete, independent copy of a model that can serve requests on its own. It may use one GPU or several.
ParallelismA way of splitting the work of one replica across several GPUs. This module covers five kinds.
Scale-up domainGPUs joined by a very fast link such as NVLink (9.c): 8 GPUs in an HGX server, 72 in a GB200/GB300 NVL72 rack. Splitting a model inside one is cheap; across them is expensive.
Decode floorThe shortest possible time per generated token for one user: the bytes read per token ÷ memory bandwidth (2.e, 4.e).
ITLInter-token latency: the time between two generated tokens (2.c).

1. What is it?#

Distributed inference means using more than one GPU for one replica of a model. There are exactly three good reasons to do it, and one very common bad one:

GOOD REASON 1 — CAPACITY:  the weights (plus room for the KV cache) don't fit on one GPU.
GOOD REASON 2 — LATENCY:   one GPU's memory bandwidth gives an ITL slower than the target.
GOOD REASON 3 — KV SPACE:  you need more memory for concurrent sequences or long contexts.

BAD REASON   — "more GPUs must be faster." Often false. Lesson 14.m shows why.

If you only need to serve more users, you do not need distributed inference at all: you need more replicas, each as small as possible.

Facts checked on 12 November 2026.


2. Why does it exist?#

Models outgrew single GPUs. In 2026 a typical frontier open model is a mixture-of-experts (MoE) model with 600 billion to over 2 trillion parameters (lesson 14.g). Even at 8 bits per parameter that is 0.6–2 TB of weights, while the largest single GPUs hold 141–288 GB. So the biggest models must be split.

The three good reasons lead to different strategies, and choosing the wrong one wastes money:

REASON                     STRATEGY                         WHY
Model doesn't fit          tensor (TP), pipeline (PP)       splits the weights
                           or expert (EP) parallelism
Latency too high           TP                               more total bandwidth per token
Need more KV capacity      TP, context parallelism (CP),    spreads the KV cache
                           or KV offloading (14.k)
Need more throughput       DATA PARALLELISM = replicas      no communication at all

If you only need throughput, do not use tensor parallelism. Copying the model onto more GPUs gives linear scaling with zero communication. TP gives less-than-linear scaling and adds communication. Engineers reach for TP by reflex; usually they wanted replicas.


3. Simple analogy#

Moving a piano.

If the piano fits in your van, one van is best. Two vans do not make the delivery faster; they make it more expensive.

If the piano doesn’t fit, you need two vans and a plan for coordinating them — and now you pay for the coordination.

If you have ten pianos, ten vans each carrying one is perfect: no coordination at all. That is data parallelism, and it is the best kind whenever it applies.


4. Tiny example#

Before any formula, count GPUs by hand for a 70-billion-parameter dense model stored in BF16 (2 bytes per parameter) on H100 GPUs (80 GB, 3.35 TB/s):

Weights:            70e9 × 2 bytes = 140 GB
Usable per GPU:     80 GB − 4 GB (runtime) − 10 GB (minimum KV cache) = 66 GB
To FIT:             140 / 66 = 2.1  → at least 3 GPUs → 4 (TP sizes are powers of two)

Decode floor on 1 GPU (if it fitted):  140 GB / 3.35 TB/s ≈ 42 ms per token
ITL target:                            30 ms
To be FAST enough:                     at least 2 GPUs, each reading half the weights

Answer: 4 GPUs (capacity is the binding reason, not latency).

Now change one thing: store the weights in FP8 (1 byte per parameter). The weights become 70 GB, two H100s fit them, and on one H200 (141 GB, 4.8 TB/s) the model fits and meets 30 ms. Quantization (Module 13) is often the cheapest alternative to adding GPUs.


5. Technical explanation#

The decision procedure#

STEP 1  Does one replica fit on one GPU, with room for the KV cache?
          weights + overhead + KV(target concurrency) ≤ GPU memory
        YES → does it meet the latency target on one GPU?
              (decode floor = bytes read per token / bandwidth)
              YES → USE ONE GPU. Add replicas for throughput. Done.
              NO  → step 2
        NO  → step 2

STEP 2  GPUs needed to FIT:      n_fit = weights / (memory − overhead − min KV)
STEP 3  GPUs needed for LATENCY: n_lat = bytes read per token / (bandwidth × efficiency × ITL)
STEP 4  n = max(n_fit, n_lat), rounded up to a supported size (usually a power of two that
        divides the number of KV heads — 14.c)
STEP 5  Check the interconnect. Are these n GPUs in one scale-up domain (NVLink)? If not,
        prefer a smaller TP degree plus more replicas, or quantize.
STEP 6  Scale THROUGHPUT with replicas of this n-GPU unit.

For an MoE model, step 2 uses all parameters (they must all be stored) but step 3 uses only the active parameters (only those are read per token). That is why MoE models need many GPUs for capacity but are fast per token.

The calculator#

Go
// gpus: how many GPUs does one copy of a model need — to fit, and to be fast enough?
package main

import (
	"fmt"
	"math"
)

type gpu struct {
	name  string
	memGB float64 // HBM capacity
	bwTBs float64 // HBM bandwidth, TB/s
}

type model struct {
	name     string
	paramsB  float64 // total parameters, billions (all must be stored)
	activeB  float64 // parameters read per token, billions (= paramsB for dense models)
	bytesPer float64 // bytes per parameter: 2 = BF16, 1 = FP8, 0.5 = FP4
}

// powerOfTwo rounds up to 1, 2, 4, 8, ... — the sizes tensor parallelism normally uses.
func powerOfTwo(n float64) int {
	p := 1
	for float64(p) < n {
		p *= 2
	}
	return p
}

func main() {
	const (
		overheadGB = 4.0  // runtime, activations, CUDA graphs
		minKVGB    = 10.0 // KV cache you want left over, at minimum
		itlTarget  = 0.030
		efficiency = 0.7 // fraction of peak bandwidth a real decode step reaches
	)
	gpus := []gpu{{"H100 80GB", 80, 3.35}, {"H200 141GB", 141, 4.8}, {"B200 180GB", 180, 8.0}}
	models := []model{
		{"8B dense, BF16", 8, 8, 2},
		{"70B dense, BF16", 70, 70, 2},
		{"70B dense, FP8", 70, 70, 1},
		{"405B dense, FP8", 405, 405, 1},
		{"671B MoE (37B active), FP8", 671, 37, 1},
	}
	fmt.Printf("%-28s %-11s %8s %7s %7s %6s\n", "model", "gpu", "weights", "n_fit", "n_lat", "n")
	for _, m := range models {
		weightsGB := m.paramsB * m.bytesPer
		readGB := m.activeB * m.bytesPer // bytes read per decode step (batch 1)
		for _, g := range gpus {
			nFit := weightsGB / (g.memGB - overheadGB - minKVGB)
			nLat := readGB / (g.bwTBs * 1000 * efficiency * itlTarget)
			n := powerOfTwo(math.Max(math.Ceil(nFit), math.Ceil(nLat)))
			fmt.Printf("%-28s %-11s %6.0fGB %7.2f %7.2f %6d\n", m.name, g.name, weightsGB, nFit, nLat, n)
		}
	}
}

Output:

model                        gpu          weights   n_fit   n_lat      n
8B dense, BF16               H100 80GB       16GB    0.24    0.23      1
8B dense, BF16               H200 141GB      16GB    0.13    0.16      1
8B dense, BF16               B200 180GB      16GB    0.10    0.10      1
70B dense, BF16              H100 80GB      140GB    2.12    1.99      4
70B dense, BF16              H200 141GB     140GB    1.10    1.39      2
70B dense, BF16              B200 180GB     140GB    0.84    0.83      1
70B dense, FP8               H100 80GB       70GB    1.06    1.00      2
70B dense, FP8               H200 141GB      70GB    0.55    0.69      1
70B dense, FP8               B200 180GB      70GB    0.42    0.42      1
405B dense, FP8              H100 80GB      405GB    6.14    5.76      8
405B dense, FP8              H200 141GB     405GB    3.19    4.02      8
405B dense, FP8              B200 180GB     405GB    2.44    2.41      4
671B MoE (37B active), FP8   H100 80GB      671GB   10.17    0.53     16
671B MoE (37B active), FP8   H200 141GB     671GB    5.28    0.37      8
671B MoE (37B active), FP8   B200 180GB     671GB    4.04    0.22      8

What to read off it:

  • An 8B model never needs distribution. Scale it with replicas.
  • Newer GPUs remove whole tiers of parallelism. A 70B BF16 model needs 4 H100s, 2 H200s or 1 B200. FP8 takes another step off.
  • The 671B MoE row is capacity-bound, not latency-bound. n_lat is below 1 everywhere: it needs 8–16 GPUs only to hold the experts. Spreading those experts across GPUs is expert parallelism (14.e); large deployments spread them across a whole NVL72 rack (14.h).
  • The calculator ignores the KV cache for many users. Lesson 12.q adds it; it usually raises the count.

The five forms of parallelism#

DATA PARALLELISM (DP)                                          14.b
  Copy the whole model N times. Each request goes to one copy.
  Communication: none.   Scales: throughput.   Doesn't help: latency or fit.

TENSOR PARALLELISM (TP)                                        14.c
  Split every weight matrix across GPUs. Every GPU works on every token.
  Communication: two all-reduces per layer (9.f).   Scales: latency and capacity.

PIPELINE PARALLELISM (PP)                                      14.d
  Split by layers: GPU 0 holds layers 0–39, GPU 1 holds 40–79.
  Communication: one activation hand-off per stage.   Scales: capacity, across nodes.
  Costs: doesn't reduce per-token latency; pipeline bubbles.

EXPERT PARALLELISM (EP)                                        14.e
  For MoE models: different experts on different GPUs.
  Communication: all-to-all (tokens to their experts and back).   Scales: MoE capacity.

CONTEXT / SEQUENCE PARALLELISM (CP)                            14.f
  Split one long sequence — its prefill work or its KV cache — across GPUs.
  Scales: very long contexts.

They compose. A 2026 deployment of a large MoE model on one GB300 NVL72 rack might use attention data-parallel 72 × expert-parallel 72 inside the rack; a dense model might use TP=8 inside a server × PP=2 across servers × 6 replicas = 96 GPUs. A separate axis — running prefill and decode on different GPU pools — is disaggregation (14.j).


6. Under the hood#

Every form of parallelism replaces “reading memory” with “talking to other GPUs”. Whether that is a good trade depends on the link:

link                         per-GPU bandwidth (one direction, approx.)
HBM on the GPU itself        3.35 – 8 TB/s (H100 → B200), ~22 TB/s (Rubin)
NVLink 5 (Blackwell)         0.9 TB/s
PCIe Gen5 x16                ~0.064 TB/s
800 Gb/s RDMA NIC            ~0.1 TB/s

Inside an NVLink domain, the link is within an order of magnitude of HBM, so splitting a layer across GPUs is cheap. Over PCIe or the network it is 30–100x slower than HBM, so only splits that send little data per token (pipeline stages, replicas, KV hand-offs) work there. Lessons 9.c and 9.g give the exact cost formulas; 9.e covers moving KV caches.


7. Performance implications#

Strategy        Latency         Throughput      Efficiency     Communication
1 GPU           baseline        baseline        100%           none
DP × N          same            N×              ~100%          none
TP=N (NVLink)   ~N× better      ~0.85N×         ~85%           all-reduce per layer
TP=N (PCIe)     ~2× better      ~0.4N×          ~40%           all-reduce per layer
PP=N            same or worse   ~0.7N×          ~70%           activations per stage
EP=N (NVLink)   depends on      high at large   good if        all-to-all per MoE layer
                batch size      batch           balanced

Read the TP rows carefully. With NVLink, TP=4 gives roughly 3.4x the throughput of one GPU and up to 4x lower latency — a good trade. Over PCIe, TP=4 gives about 1.6x the throughput for four times the GPUs — a terrible trade. The interconnect decides whether TP is a good idea.


8. Production implications#

  • Default to the smallest unit that fits and meets latency, then add replicas.
  • Check the topology before choosing a degree. nvidia-smi topo -m shows which GPUs share NVLink; keep TP groups inside one NVLink domain.
  • Try quantization before parallelism. FP8 halves the weights and often turns a multi-node deployment into a single-node one; FP4 on Blackwell halves them again (13.e, 13.g).
  • The TP degree must divide the number of KV heads, or the engine replicates KV heads and wastes memory (14.c).
  • Multi-node is a step change in operational complexity (9.h): more failure modes, gang scheduling, slower links. Avoid it unless the model really needs it.
  • For the largest MoE models, the rack is the unit. An NVL72 rack (7.d) lets expert parallelism run over NVLink instead of the network; that is why 2026 MoE results are reported per rack.

9. Common mistakes#

  1. Using TP when you wanted DP. The most common error. If you need throughput, add replicas.
  2. Choosing TP=8 because the server has 8 GPUs. Choose from the requirements, then check the topology.
  3. Ignoring the interconnect. TP over PCIe is often worse than no TP.
  4. Sizing an MoE model by its active parameters. Active parameters set the speed; total parameters set the memory.
  5. Going multi-node before trying quantization or a newer GPU.
  6. Assuming linear scaling. TP scaling is 70–90% per doubling at best.

10. Hands-on exercise#

A. Run the procedure. Add the GPUs you have access to and two models you might deploy to the calculator. Compare its answer with your engine’s default settings.

B. Add the KV cache. Extend the calculator with a concurrency target and the KV bytes per token from 12.f. How many GPUs does the 70B model need for 64 concurrent 8k-token conversations?

C. DP vs TP. With 4 GPUs and a model that fits on one, compare (i) TP=4 on one replica and (ii) 4 replicas. Measure total throughput and per-request latency under the same load. Which wins each metric?

D. Topology. Run nvidia-smi topo -m. Which GPU groups share NVLink? Design your TP groups accordingly. If you have PCIe-only GPUs, measure TP=2 across them.


11. Interview questions#

  1. What are the three legitimate reasons to use more than one GPU for one model?
  2. Why is data parallelism preferred when you only need throughput?
  3. Walk through choosing the GPU count for a 70B model with a 30 ms ITL target on H100s. What changes on a B200?
  4. Why does an MoE model’s GPU count depend on total parameters but its speed on active ones?
  5. When is quantization a better answer than parallelism?
  6. Why does the interconnect decide whether TP is worthwhile?

12. Further reading#

Checked on 12 November 2026.

↑↓ navigate↵ openesc close

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