Before you start: words you need#
| Word | Plain meaning |
|---|---|
| Stage | One GPU (or one TP group) holding a contiguous run of the model’s layers. A pipeline of 4 stages has 4 such groups in a row. |
| Activation | The vector a layer hands to the next layer: one row of d_model numbers per token. This is what travels between stages. |
| Microbatch | A slice of the work that moves through the pipeline as one unit. While stage 2 works on microbatch 1, stage 1 can start microbatch 2. |
| Bubble | Time a stage sits idle because the work it needs has not arrived yet, or because nothing is left to do. |
| Point-to-point send | One GPU sends a tensor to exactly one other GPU (send/recv), unlike a collective where every GPU takes part (9.f). |
| Scale-up domain | GPUs joined by NVLink: 8 in an HGX server, 72 in an NVL72 rack (9.c, 7.d). |
| TTFT / ITL | Time to first token; inter-token latency, the gap between generated tokens (2.c). |
1. What is it?#
Pipeline parallelism (PP) splits a model by layers. GPU 0 holds layers 0–19, GPU 1 holds 20–39, and so on. Each token’s activations flow from one stage to the next, like a car down an assembly line.
flowchart LR IN["Tokens"] --> S0["Stage 0<br/>layers 0-19<br/>+ embedding"] S0 -->|"activations<br/>tokens x d_model"| S1["Stage 1<br/>layers 20-39"] S1 -->|"activations"| S2["Stage 2<br/>layers 40-59"] S2 -->|"activations"| S3["Stage 3<br/>layers 60-79<br/>+ LM head"] S3 --> OUT["Logits, next token"] class S0,S1,S2,S3 compute class IN,OUT neutral
Tensor parallelism (14.c) gives every GPU a slice of every layer; pipeline parallelism gives every GPU all of some layers. That one difference decides everything else in this lesson:
- PP sends one small tensor per stage boundary. TP runs two all-reduces per layer.
- PP does not make one token faster: the token still visits every layer, one stage after another. TP does.
- PP keeps every GPU busy only when several batches are in flight at once.
Facts checked on 12 November 2026.
2. Why does it exist?#
PROBLEM The model does not fit in one scale-up domain (one 8-GPU server), and
TP across servers is too slow: all-reduces over InfiniBand or Ethernet
take roughly 10x longer than over NVLink (14.c, 9.g).
WHY TP needs 160 collectives per decode step for an 80-layer model.
PP needs one point-to-point send per stage boundary.
FIX TP inside each server, PP between servers.
TRADE-OFFS
✓ ~90x less traffic than TP (section 6), and it is point-to-point
✓ works over ordinary RDMA networks; the classic multi-node layout
✓ weights AND KV cache are split: each stage stores KV only for its own layers
✗ bubbles: stages idle unless enough work is in flight
✗ no per-token latency gain; slightly worse, because of the hops
✗ the slowest stage sets the pace, so stages must be balanced
✗ more moving parts: several batches in flight, harder preemption and recoveryWhere PP matters in 2026:
- Very large models on 8-GPU servers. Kimi K3 (2.8T parameters) needs about 1.4 TB even at 4 bits per weight, more than one 8×H200 server (1.1 TB of HBM) holds. Without an NVL72 rack, the standard layout is TP=8 per server and PP across 2–4 servers. On an NVL72, expert parallelism over NVLink usually wins instead (14.e, 14.h).
- Very long prompts. Chunked pipeline parallelism (section 5) does cut time to first token for one huge prompt, because chunks of that prompt fill the pipeline.
- Clusters without fast interconnect. PCIe-only servers or cheaper Ethernet fabrics, where TP across servers is hopeless.
3. Simple analogy#
An assembly line versus one worker building a whole car.
On a line, each worker does one stage. A single car takes as long as it always did (it still passes every station), but once the line is full, a finished car rolls off every few minutes.
If only one car is on the line, three of the four workers stand idle. That idle time is the bubble. A line pays off only when it is full, which for a server means many requests at once.
4. Tiny example: bubbles with four stages#
Four stages, one batch, no microbatching. Each box is one stage processing the batch:
time → t1 t2 t3 t4
GPU 0: [B] idle idle idle
GPU 1: idle [B] idle idle
GPU 2: idle idle [B] idle
GPU 3: idle idle idle [B]
useful work: 4 boxes out of 16 → 25% utilisation, 75% bubbleCut the batch into 8 microbatches and the stages overlap:
GPU 0: [1][2][3][4][5][6][7][8]
GPU 1: [1][2][3][4][5][6][7][8]
GPU 2: [1][2][3][4][5][6][7][8]
GPU 3: [1][2][3][4][5][6][7][8]
bubble = (p − 1) / (m + p − 1) = 3 / 11 = 27%The rule: you need many more microbatches than stages (m ≫ p).
5. Technical explanation#
Training-style bubbles versus serving-style pipelines#
The formula above comes from training (GPipe), where one big batch is cut up and then the pipeline drains. An inference server is different: it never drains. New requests keep arriving, so the engine keeps several independent batches in flight, one per stage:
step → 1 2 3 4 5 6
stage 0: B1 B2 B3 B4 B1' B2' B1' = batch 1's next decode step
stage 1: B1 B2 B3 B4 B1'
stage 2: B1 B2 B3 B4
stage 3: B1 B2 B3vLLM does this: with --pipeline-parallel-size P, the scheduler keeps up to P batches in flight
and the sequences are split between them. In steady state there is no bubble, if:
- there are enough running sequences to fill P batches of a useful size, and
- every stage takes the same time per step.
Both conditions fail in real traffic. At low concurrency, P small batches each read all the weights for very few tokens (14.m explains why that is expensive). And a batch that finishes or admits a long prefill changes its step time, so the stages drift out of step.
Per-token latency#
A decode step for one sequence passes through all P stages in turn:
ITL ≈ (sum of stage compute times) + (P − 1) × (send latency)The compute sum is the same as one big GPU would need, so PP never lowers ITL. It only spreads the weights. Each hop adds a few to tens of microseconds over RDMA, which is small next to a 20–40 ms step. If you need lower ITL, use TP inside the server or a faster GPU.
Balancing the stages#
The pipeline runs at the speed of its slowest stage. Equal layer counts are not equal work:
- the first stage also runs the embedding lookup (cheap);
- the last stage also runs the final norm, the LM head (
d_model × vocab, often 1–2 GB of weights) and sampling; - MoE models often have a few dense layers at the start (
first_k_dense_replacein DeepSeek, Kimi and GLM configs), which cost differently from MoE layers; - hybrid models (Kimi K3, Qwen3.6) mix linear-attention and full-attention layers (12.g).
vLLM lets you set the split by hand with the VLLM_PP_LAYER_PARTITION environment variable
(for example "21,21,21,17"); otherwise it splits evenly. Measure per-stage time and move layers
off the slow stage.
The KV cache under PP#
Each stage keeps KV only for its own layers, for every sequence in flight. So PP grows total KV capacity just like TP does, and, unlike TP, it has no “KV-head” limit (14.c): an MLA model with one latent per token splits cleanly by layer. That is one reason PP is attractive for MLA models on servers without NVL72.
Chunked pipeline parallelism for long prompts#
A 1M-token prefill on one TP group takes minutes. TP across nodes does not help much (the all-reduces cross the network). Chunked pipeline parallelism cuts the prompt into chunks (chunked prefill, 12.k) and sends the chunks down the pipeline one after another, so the stages work on different chunks of the same request at once.
Later chunks are slower, because each attends to a longer prefix. SGLang’s version predicts that
cost and shrinks later chunks so every stage finishes in about the same time (“dynamic
chunking”, --enable-dynamic-chunking). Its published results, on H20 servers (SGLang blog,
January 2026, project’s own benchmark):
Qwen3-235B-A22B-FP8, PP1×TP4 → PP8×TP4: TTFT ~55.5 s → ~10.5 s on an ultra-long prompt
DeepSeek-V3.1, PP1×TP8 → PP4×TP8: TTFT ~48.5 s → ~15.5 s; 82.8% scaling efficiency
DeepSeek-V3.1 prefill throughput, PP4×TP8: 3.31x TP8, versus 2.54x for TP32This is the one case where PP lowers latency: there are enough chunks to fill the pipeline even though there is only one request.
Interaction with the scheduler#
With several batches in flight:
- the scheduler must plan batch k+1 while batch k is still inside the pipeline (async scheduling, 17.d, is the same idea);
- a finished sequence’s KV can be freed only after its last step leaves the last stage;
- preempting a sequence that is mid-pipeline must wait for it to come out.
That bookkeeping is why PP has historically had more engine bugs and fewer optimisations than TP. Check your engine’s release notes for PP-specific restrictions (some speculative decoding methods and some attention backends support PP later than TP).
6. Under the hood#
The program computes the bubble table, the effect of an unbalanced last stage, and how many bytes PP and TP move per decode step.
// pp.go — pipeline parallelism: bubbles, stage imbalance, and the bytes on the wire.
package main
import "fmt"
func main() {
// 1. Bubble fraction when one batch is cut into m microbatches over p stages.
fmt.Println("Bubble fraction (p-1)/(m+p-1):")
fmt.Printf("%-6s", "m \\ p")
stages := []int{2, 4, 8}
for _, p := range stages {
fmt.Printf("%8d", p)
}
fmt.Println()
for _, m := range []int{1, 4, 8, 32, 128} {
fmt.Printf("%-6d", m)
for _, p := range stages {
fmt.Printf("%7.0f%%", 100*float64(p-1)/float64(m+p-1))
}
fmt.Println()
}
// 2. Stage imbalance: the pipeline runs at the speed of its slowest stage.
fmt.Println("\nStage imbalance, PP=4, 80 layers + LM head worth ~3 layers on the last stage:")
for _, split := range [][]int{{20, 20, 20, 20}, {21, 21, 21, 17}} {
times := make([]float64, len(split))
var total, slowest float64
for i, layers := range split {
times[i] = float64(layers)
if i == len(split)-1 {
times[i] += 3 // LM head
}
total += times[i]
if times[i] > slowest {
slowest = times[i]
}
}
eff := total / (slowest * float64(len(split)))
fmt.Printf(" layers %v stage times %v efficiency %.0f%%\n", split, times, 100*eff)
}
// 3. Bytes between stages vs tensor-parallel all-reduces, one decode step.
const d, bytes, layers = 8192.0, 2.0, 80.0
fmt.Println("\nTraffic per decode step, 70B-class model (d=8192, BF16, 80 layers):")
for _, batch := range []float64{1, 32, 256} {
act := batch * d * bytes // one activation tensor
pp := 3 * act // PP=4: three stage boundaries
tp := 2 * layers * 2 * 7 / 8 * act // TP=8 ring all-reduce, 2 per layer
fmt.Printf(" batch %3.0f: PP=4 sends %7.1f KB TP=8 moves %8.1f KB per GPU (%.0fx)\n",
batch, pp/1024, tp/1024, tp/pp)
}
}Output:
Bubble fraction (p-1)/(m+p-1):
m \ p 2 4 8
1 50% 75% 88%
4 20% 43% 64%
8 11% 27% 47%
32 3% 9% 18%
128 1% 2% 5%
Stage imbalance, PP=4, 80 layers + LM head worth ~3 layers on the last stage:
layers [20 20 20 20] stage times [20 20 20 23] efficiency 90%
layers [21 21 21 17] stage times [21 21 21 20] efficiency 99%
Traffic per decode step, 70B-class model (d=8192, BF16, 80 layers):
batch 1: PP=4 sends 48.0 KB TP=8 moves 4480.0 KB per GPU (93x)
batch 32: PP=4 sends 1536.0 KB TP=8 moves 143360.0 KB per GPU (93x)
batch 256: PP=4 sends 12288.0 KB TP=8 moves 1146880.0 KB per GPU (93x)How to read it:
- Bubbles fall only when there is much more work than stages. PP=8 with 8 microbatches still wastes 47%.
- Balancing is cheap and worth it: moving three layers off the last stage recovers about 10%.
- Traffic: the ratio is constant (93x) because both grow linearly with the batch. At batch 32, PP sends 1.5 MB per step; over a 400 Gb/s link (about 45 GB/s achieved) that is about 34 µs. TP’s 140 MB per GPU would take about 3 ms per step over the same link, plus 160 start-up latencies. That is why TP stays inside the server and PP crosses servers.
The canonical multi-node layout#
2 servers × 8 H200 (141 GB), a 1T-parameter MoE at FP8 (~1 TB of weights)
Server 0: GPUs 0-7, first half of the layers, TP=8 over NVLink
Server 1: GPUs 0-7, second half of the layers, TP=8 over NVLink
Between: PP=2, one activation send per step over InfiniBand / RoCE
weights per GPU ≈ 1 TB / 16 ≈ 63 GB, leaving ~70 GB per GPU for KV and activations# vLLM, two nodes (Ray or the multiprocessing launcher; see 9.h and 19.a)
vllm serve <model> --tensor-parallel-size 8 --pipeline-parallel-size 27. Performance implications#
Typical shape of the numbers, for a large model that needs two 8-GPU servers:
Configuration ITL Throughput at high load Throughput at low load
TP=16 across servers poor poor poor (all-reduce over the network)
TP=8 × PP=2 ≈ one server good bubbles: ~half wasted
PP=16 (TP=1) worst fine if very busy very poor- Throughput with PP scales well (80–90% per added stage) at high concurrency with balanced stages, and badly at low concurrency.
- ITL is set by the total compute per step plus the hops; PP=2 adds a little.
- TTFT for a normal prompt gets slightly worse (more hops); for a huge prompt with chunked pipelining it gets much better.
- Compared with NVL72: on a 72-GPU NVLink rack, the same model usually runs faster with attention data parallelism plus wide expert parallelism (14.e), because everything stays on NVLink. PP is the tool for when you do not have that rack.
8. Production implications#
- Use PP across servers, not inside one. Inside an NVLink domain, TP (or EP for MoE) is better.
- Try to avoid it first. FP8 or FP4 weights (13.e, 13.g) may make the model fit in one server and remove PP entirely, which is a big operational simplification.
- PP needs traffic. Size PP deployments for high concurrency; at night-time load, half the GPUs may be idle bubbles.
- Balance the stages. Profile per-stage step time; give the last stage fewer layers.
- Treat the whole pipeline as one unit. One server failing stops the replica; both servers must load, warm up and upgrade together (9.h, 23.e). Kubernetes LeaderWorkerSet or Dynamo’s Grove schedule them as a gang (21.c, 21.j).
- Place stages close. Put the servers of one pipeline under the same leaf switch or rail (9.d).
- For long-prompt products, test chunked pipeline parallelism: it can cut TTFT on 128k–1M prompts several-fold.
9. Common mistakes#
- Using PP inside one server. TP has lower latency and no bubbles there.
- Expecting PP to lower ITL. A token still visits every layer.
- Running PP at low concurrency. Bubbles eat most of the GPUs.
- Splitting layers evenly. The last stage carries the LM head and runs slow.
- Too many stages. Each stage adds a hop and raises the concurrency needed; PP of 2–4 is typical for inference.
- Not trying quantization first. One server at FP8 beats two servers at BF16 in almost every way.
- Using PP on an NVL72 rack for an MoE model by habit; wide EP over NVLink usually wins there.
10. Hands-on exercise#
- Run
pp.go. Add P=16 to the bubble table. How many microbatches keep the bubble under 10%? - Change the stage-imbalance model so the first stage also carries 3 dense MoE-prelude layers worth 1.5 normal layers each. Find the best split for 80 layers on PP=4.
- With two GPU servers (or two groups of GPUs with
NCCL_P2P_DISABLE=1to fake a slow link), serve one model with TP=8 and with TP=4 × PP=2. Measure ITL and throughput at concurrency 4, 32 and 256. - Compute the per-step PP traffic for DeepSeek-V4-Pro (
hidden_size7168) at batch 128 and PP=4. How long does it take on a 400 Gb/s link? - Read the SGLang chunked pipeline post. Why do later chunks take longer, and how does dynamic chunking compensate?
11. Interview questions#
- How does pipeline parallelism differ from tensor parallelism in what each GPU holds and what it sends?
- Give the bubble formula and compute it for PP=4 with 8 microbatches.
- Why does an inference server not see training-style bubbles in steady state, and when does it see them anyway?
- Why does PP not reduce inter-token latency?
- Why is the last stage usually the slowest, and how do you fix it?
- When does PP reduce time to first token?
- Why is TP-inside, PP-across the classic multi-node layout, and when does an NVL72 change that?
12. Further reading#
Checked on 12 November 2026.
- [ESTABLISHED] Huang et al., “GPipe” (2018) — the bubble analysis
- [ESTABLISHED] Narayanan et al., “Efficient Large-Scale Language Model Training on GPU Clusters Using Megatron-LM” (2021) — TP inside, PP across
- [ESTABLISHED] Pope et al., “Efficiently Scaling Transformer Inference” (2022)
- [REFERENCE] SGLang — pipeline parallelism for long context
- [ESTABLISHED] LMSYS — Chunked pipeline parallelism for million-token prefill (January 2026) — project’s own benchmark
- [REFERENCE] vLLM — parallelism and scaling