★ The most common way to split a dense model across GPUs. Understand the layout and you understand why it needs NVLink.
Before you start: words you need#
| Word | Plain meaning |
|---|---|
| Shard | One GPU’s piece of a weight matrix. |
| Column split / row split | Cutting a matrix into vertical strips (each GPU gets some output columns) or horizontal strips (each GPU gets some input rows). |
| Partial sum | A result that is only part of the answer; adding every GPU’s partial sum gives the real one. |
| All-reduce | A collective (9.f) after which every GPU holds the sum of every GPU’s input. The step that adds the partial sums together. |
| Rank | One GPU’s process inside a parallel group: rank 0, rank 1, … |
| KV heads | Attention stores keys and values per head (12.e). Grouped-query models have few KV heads — often 8. |
1. What is it?#
Tensor parallelism (TP) splits every weight matrix across GPUs, so every GPU computes part of every layer for every token.
One GPU: TP=2:
y = x @ W GPU 0: y0 = x @ W[:, :h/2] (left half of the columns)
W is (d, h) GPU 1: y1 = x @ W[:, h/2:] (right half of the columns)
then combineEvery GPU sees every token and holds a slice of every weight. Pipeline parallelism (14.d) splits by layer instead, and data parallelism (14.b) copies instead of splitting.
Facts checked on 12 November 2026.
Diagram — One layer, sharded across two GPUs#
flowchart TB
X["Layer input x<br/>the same on every GPU"] --> G0
X --> G1
subgraph G0["GPU 0"]
A0["Half the attention heads<br/>half of the MLP"]
end
subgraph G1["GPU 1"]
A1["Other half of the heads<br/>other half of the MLP"]
end
G0 --> AR(("all-reduce<br/>sum"))
G1 --> AR
AR --> Y["Full layer output on every GPU"]
Y -.->|"two all-reduces per layer, every step"| X
class A0,A1 compute
class AR warn
class X,Y neutral2. Why does it exist?#
PROBLEM A 70B model in BF16 is 140 GB — it does not fit on an 80 GB H100.
Even if it did, 140 GB / 3.35 TB/s = 42 ms per token — too slow for chat.
WHY Memory capacity and memory bandwidth are both per-GPU resources.
FIX Split the weights across N GPUs. Each holds 1/N and reads 1/N of the
bytes per token, so the model fits and decode is up to N× faster.
TRADE-OFFS
✓ latency improves almost N×
✓ capacity: the weights and the KV cache are both split
✗ an all-reduce after every attention block and every MLP block
✗ scaling efficiency 70–90% per doubling, falling as N grows
✗ needs a fast link (NVLink) to be worth it
✗ every GPU in the group must be healthy; one failure stops the group3. Simple analogy#
Four accountants splitting one ledger by column.
Each takes a quarter of the columns. Each handles every transaction, but only their columns — four times faster, if they can combine their partial totals quickly.
Combining is the all-reduce. In the same room (NVLink), it takes a moment. In different buildings (PCIe or the network), combining dominates and four accountants are slower than one.
4. Tiny example#
Take an MLP with input size 2 and hidden size 4, y = (x · A) · B, split across 2 GPUs. Ignore the
activation for a moment.
x = [1, 2]
A (2×4) = [1 0 2 1] B (4×2) = [1 0]
[0 1 1 0] [0 1]
[1 1]
[2 0]
Single GPU: h = x·A = [1, 2, 4, 1] y = h·B = [1+0+4+2, 0+2+4+0] = [7, 6]
TP=2: split A by COLUMN, B by ROW
GPU 0: A[:, 0:2] = [1 0; 0 1] → h0 = [1, 2] B[0:2, :] = [1 0; 0 1] → y0 = [1, 2]
GPU 1: A[:, 2:4] = [2 1; 1 0] → h1 = [4, 1] B[2:4, :] = [1 1; 2 0] → y1 = [6, 4]
all-reduce: y = y0 + y1 = [7, 6] ✓ identicalEach GPU used only its own slices and the shared input x. The only communication was one sum at
the end. That is the entire trick; the rest of this lesson applies it to a real transformer.
5. Technical explanation#
The MLP: column, then row#
Megatron-style TP arranges each block so that exactly one all-reduce is needed.
MLP: y = down( silu(gate(x)) * up(x) )
gate: (d, d_ff) split by COLUMN → each GPU gets (d, d_ff/N)
up: (d, d_ff) split by COLUMN → each GPU gets (d, d_ff/N)
down: (d_ff, d) split by ROW → each GPU gets (d_ff/N, d)
Per GPU i:
gate_i = x @ W_gate[:, slice i] — no communication
up_i = x @ W_up[:, slice i] — no communication
h_i = silu(gate_i) * up_i — element-wise, local
y_i = h_i @ W_down[slice i, :] — a PARTIAL sum of the output
y = all-reduce(y_i) ← one all-reduce for the whole MLPWhy column-then-row works: splitting the first matrix by column gives each GPU a slice of the hidden vector it can push through the activation locally (an element-wise function needs no other GPU’s data). Splitting the second by row turns each GPU’s output into a partial sum, and adding partial sums is exactly what an all-reduce does. Split both by column and you would need an extra gather in the middle.
Attention: split by head#
W_q, W_k, W_v: split by COLUMN = by HEAD → GPU i gets heads [i·h/N, (i+1)·h/N)
W_o: split by ROW
Per GPU:
q, k, v for its own heads — no communication
attention over its own heads — no communication; its KV cache holds only those heads
o_i = attn_out_i @ W_o[its rows, :] — partial sum
out = all-reduce(o_i) ← one all-reduce for attentionHeads are independent, so attention splits cleanly and the KV cache splits with it — which is why TP also multiplies KV capacity.
The KV-head rule. Grouped-query attention (12.g) has fewer KV heads than query heads — often 8. TP=8 gives each GPU one KV head. TP=16 has nothing to split, so the engine replicates KV heads: each GPU stores a copy, and the KV-capacity gain disappears. Multi-head latent attention (MLA, DeepSeek-style) is the extreme case: it caches one compressed latent per token, which cannot be split by head at all. That is why MLA models are served with attention data parallelism (14.b) rather than attention TP.
The full layer#
Per transformer layer:
RMSNorm (every GPU computes it — cheap)
attention, split by head → all-reduce (message: tokens × d × bytes)
residual add (local)
RMSNorm
MLP, column/row split → all-reduce (message: tokens × d × bytes)
residual add (local)
→ 2 all-reduces per layer. An 80-layer model does 160 per forward pass (per decode step).Embedding and output head#
Embedding: split by vocabulary (each GPU holds V/N rows), or simply replicated — it is small.
LM head: split by vocabulary — each GPU computes logits for V/N tokens.
Sampling: gathering all logits is expensive (V is 100k–260k), so good engines
sample distributedly — each GPU finds its local best candidates, then a tiny
collective picks the winner.The communication cost#
The ring all-reduce moves 2 × (N−1)/N × message bytes per GPU (9.f derives it; 9.g gives the
full cost model). For a 70B model (d = 8192) at TP=8, decode batch 32, BF16:
message per all-reduce = 32 tokens × 8192 × 2 bytes = 512 KB
bytes moved per GPU = 2 × 7/8 × 512 KB = 896 KB
× 160 all-reduces = 143 MB per step
NVLink 4 (Hopper, ~450 GB/s per direction): 143 MB / 450 GB/s ≈ 0.32 ms
PCIe Gen5 (~50 GB/s): 143 MB / 50 GB/s ≈ 2.9 ms
Weight read per GPU per step: 17.5 GB / 3.35 TB/s ≈ 5.2 ms
NVLink overhead: ~6% ✓ PCIe overhead: ~55% ✗That calculation is the whole argument for NVLink. Blackwell’s NVLink 5 doubles the per-GPU bandwidth again (~900 GB/s per direction).
Latency, not only bandwidth. Each all-reduce also has a fixed start-up cost of several microseconds on NVLink, tens over PCIe or the network:
NVLink: 160 × ~7 µs ≈ 1.1 ms per step
PCIe: 160 × ~30 µs ≈ 4.8 ms per stepAt small batch, the fixed latency dominates. That is why engines ship their own custom all-reduce kernels for small messages (one-shot and two-shot algorithms over NVLink peer memory), and why NCCL uses NVLink SHARP (NVLS) on NVSwitch systems, where the switch itself adds the numbers and each GPU sends its data once.
Making the all-reduce cheaper or hiding it#
Three techniques in current engines:
- Fuse the all-reduce with the next operation. The all-reduce result goes straight into the residual add and RMSNorm in one kernel (FlashInfer’s and TensorRT-LLM’s fused all-reduce + norm), saving a round trip through memory.
- Sequence parallelism for prefill. Replace each all-reduce with a reduce-scatter and an all-gather, and run the norms on 1/N of the tokens each. Same bytes, less duplicated work — useful for long prompts.
- Overlap. Split the batch so one half communicates while the other computes. Engines have experimented with compiler passes that do this automatically; vLLM removed its sequence- parallelism and async-TP compiler passes in v0.32.0, so check what your engine version does today rather than assuming.
6. Under the hood — a TP=4 deployment#
4 processes, one per GPU, in lockstep:
rank 0: the scheduler lives with (or talks to) this rank
ranks 0–3: execute the same model code on their own shards
Every step:
1. the scheduler decides the batch
2. batch metadata is broadcast to all ranks
3. every rank runs the same kernels on its shard
4. 160 all-reduces, every rank taking part
5. the sampled tokens go back to the scheduler
If any rank stalls or crashes, every rank waits forever.
NCCL has no built-in fault tolerance: a dead rank means a dead group.Lockstep has operational consequences: you cannot drain or upgrade one GPU of a TP group, and one GPU fault stops the group. Set collective timeouts and supervise the group as one unit.
7. Performance implications#
Illustrative numbers for a 70B dense model on H100s with NVLink, decode batch 32:
TP Weights/GPU ITL (theory) ITL (measured, typical) Throughput Efficiency vs TP=2
1 140 GB — out of memory — —
2 70 GB 21 ms ~26 ms ~1,230 tok/s —
4 35 GB 10.5 ms ~14 ms ~2,290 tok/s ~93%
8 17.5 GB 5.2 ms ~8.5 ms ~3,760 tok/s ~82%
16 8.8 GB 2.6 ms ~6.2 ms ~5,160 tok/s ~56% ← degradingEfficiency falls because the per-all-reduce latency stays fixed while each GPU’s share of the work keeps shrinking. Past TP=8 you pay more in communication than you gain in bandwidth — and for GQA models with 8 KV heads, TP=16 also replicates the KV cache.
Practical guidance: TP ≤ 8, inside one NVLink domain. Larger models combine TP=8 with pipeline parallelism across servers (14.d), or — for MoE models — switch to attention DP plus expert parallelism (14.e, 14.h), which is how 72-GPU NVL72 racks are used.
8. Production implications#
- The TP degree must divide the number of KV heads, or the engine replicates them. Eight KV heads support TP ∈ {1, 2, 4, 8}.
- Keep TP groups inside one NVLink domain. Check
nvidia-smi topo -m. - Use the engine’s custom all-reduce and NVLS where available; check the start-up logs to see which path was chosen.
- Set collective timeouts so a hung rank fails fast instead of holding GPUs forever.
- Supervise the whole group. If one rank dies, restart them all.
- Check that sampling is distributed. Gathering full logits every step costs 16 MB per GPU at V = 128k and batch 64.
9. Common mistakes#
- TP across PCIe. 50%+ overhead. Check the topology.
- A TP degree that doesn’t divide the KV head count. Silent memory waste.
- TP on an MLA model. The latent KV cache gets replicated on every rank; use attention DP.
- TP=16 or higher on a dense model. Efficiency collapses; use TP=8 × PP, or DP.
- No collective timeouts. A hung rank hangs forever.
- Forgetting the fixed latency. At small batch, all-reduce latency, not bandwidth, dominates.
10. Hands-on exercise#
A. Derive the layout. Repeat section 4 for TP=2 with the activation included (silu on h).
Show it still needs exactly one all-reduce, and that column-then-column would need two collectives.
B. Measure scaling. Run a model at TP=1, 2, 4, 8 (as far as your hardware allows). Measure ITL and throughput; compute efficiency; compare with section 7.
C. Measure the all-reduce. Use nccl-tests (all_reduce_perf) for messages from 4 KB to
64 MB. Plot bandwidth and latency. Where does the latency-bound regime end?
D. Predict the overhead. With your measured numbers, predict the communication overhead for your model at TP=4 and TP=8, at batch 1 and batch 64, and compare with the measured difference.
11. Interview questions#
- Explain the column/row split for the MLP and why it needs only one all-reduce.
- How is attention split under TP, and what happens to the KV cache?
- How many all-reduces per decode step for an 80-layer model?
- Compute the communication overhead at TP=8 on NVLink versus PCIe.
- Why does TP efficiency fall past TP=8?
- Why are MLA models served with attention DP rather than attention TP?
- What are the operational consequences of lockstep execution?
12. Further reading#
Checked on 12 November 2026.
- [ESTABLISHED] Shoeybi et al., “Megatron-LM” (2019) — the column/row layout
- [ESTABLISHED] Pope et al., “Efficiently Scaling Transformer Inference” (2022)
- [ESTABLISHED] Korthikanti et al., “Reducing Activation Recomputation in Large Transformer Models” (2022) — sequence parallelism
- [REFERENCE] NCCL documentation and nccl-tests
- [REFERENCE] vLLM v0.32.0 release notes — removal of the sequence-parallel and async-TP compiler passes (checked on 11 November 2026)