Before you start: words you need#
| Word | Plain meaning |
|---|---|
| Data parallelism (DP) | Running several complete copies (replicas) of a model and sending each request to one of them. “Data” because the requests are split, not the model. |
| Load balancer / router | The component that decides which replica gets each request (20.f, 21.g). |
| Prefix cache | Saved KV cache for prompt beginnings seen before, so they need not be recomputed (12.m). Each replica has its own. |
| Attention DP | A 2026 pattern for mixture-of-experts models: the attention part runs data-parallel while the experts are split across GPUs. Introduced in section 5, taught fully in 14.e and 14.h. |
1. What is it?#
Run N complete copies of the model on N GPUs (or N groups of GPUs). Each request goes to one replica. Replicas never talk to each other.
flowchart TB
LB["Load balancer / router"] --> R0 & R1 & R2 & R3
subgraph R0["Replica 0 — GPU 0"]
W0["full weights<br/>own KV cache<br/>own scheduler"]
end
subgraph R1["Replica 1 — GPU 1"]
W1["full weights<br/>own KV cache<br/>own scheduler"]
end
subgraph R2["Replica 2 — GPU 2"]
W2["full weights<br/>own KV cache<br/>own scheduler"]
end
subgraph R3["Replica 3 — GPU 3"]
W3["full weights<br/>own KV cache<br/>own scheduler"]
end
class LB queue
class W0,W1,W2,W3 computeIt is the simplest and most efficient form of parallelism, and for throughput it is almost always the right answer.
2. Why does it exist?#
Most inference workloads need throughput — more users served — not lower latency for one request, and independent requests split perfectly across copies:
1 replica: 1,000 tokens/sec
4 replicas: 4,000 tokens/sec (linear)There is no all-reduce, no synchronisation, no pipeline bubble. Scaling efficiency is ~100%. Compare tensor parallelism at TP=4: about 3.4x the throughput, with communication on every layer (14.c).
3. Simple analogy#
Four checkout lanes versus four cashiers sharing one till.
Four independent lanes serve four customers at once with no coordination. Four cashiers working on one customer’s shopping finish that customer faster, but spend time coordinating and serve only one customer at a time.
Data parallelism is four lanes. Tensor parallelism is four cashiers on one transaction.
4. Tiny example#
The do-it-yourself version is four engines and a load balancer:
# 4 independent replicas, one GPU each
CUDA_VISIBLE_DEVICES=0 vllm serve <model> --port 8000 &
CUDA_VISIBLE_DEVICES=1 vllm serve <model> --port 8001 &
CUDA_VISIBLE_DEVICES=2 vllm serve <model> --port 8002 &
CUDA_VISIBLE_DEVICES=3 vllm serve <model> --port 8003 &
# then put a router in front (Kubernetes Service, Envoy, or a KV-aware router — 21.h)Engines also do it natively, with one API endpoint that spreads requests across internal replicas:
vllm serve <model> --data-parallel-size 4 # vLLM
python -m sglang.launch_server --model-path <model> --dp-size 4 # SGLangThat is the whole implementation. Tensor parallelism, by contrast, needs NCCL set-up, weight sharding and collectives inside every layer.
5. Technical explanation#
What each replica owns#
Full model weights duplicated N times — the cost of DP
Its own KV cache pool independent
Its own scheduler and queue independent
Its own CUDA graphs independentThe cost is memory duplication. N replicas hold N copies of the weights. For an 8B model in BF16 that is 16 GB per replica — cheap. For a 70B BF16 model it is 140 GB per replica, which is why each replica of it is itself a small TP group.
The unit of replication#
You replicate whatever unit fits and meets latency (14.a):
8B model: replicate 1 GPU → DP across single GPUs
70B BF16: replicate a TP=2 unit → e.g. DP=4 × TP=2 = 8 H200s
405B FP8: replicate a TP=8 server → DP=N × TP=8DP × TP is how most dense-model deployments are built: TP inside a server over NVLink for fit
and latency, DP across servers for throughput.
Attention DP: data parallelism inside an MoE replica#
Large mixture-of-experts models (14.g) changed the picture in 2025–2026. Their expert weights are huge but their attention weights are small. Splitting attention with TP across, say, 32 GPUs would duplicate the KV cache’s KV heads or force tiny shards. So engines run:
ATTENTION: data-parallel — each GPU runs attention for ITS OWN requests, with its own KV cache
EXPERTS: expert-parallel — each GPU holds a slice of the experts; tokens travel to them (14.e)Each GPU is a small “replica” for attention while all GPUs together form one replica for the
experts. vLLM and SGLang both run DeepSeek-, Kimi- and GLM-class models this way (--enable-dp-attention
in SGLang; --data-parallel-size with --enable-expert-parallel in vLLM). Lesson 14.h shows the
full layout.
Routing matters more than with TP#
With DP, the router decides how well everything works:
Round robin → poor; requests vary 1,000x in cost (20.f)
Least-loaded → good (by queue depth or KV usage, not connection count)
Prefix-aware → best whenever prompts share beginnings (21.h)Each replica has its own prefix cache. If 8 replicas sit behind round-robin, a conversation’s next turn lands on the replica holding its prefix only 1 time in 8. Prefix-aware routing gets close to every time. For chat and agent traffic this is often the largest single factor in a DP deployment’s efficiency, which is why KV-aware routers (llm-d, Dynamo, 21.j) exist.
What DP does not give you#
✗ Lower latency for one request — it runs on one replica at that replica's speed.
✗ The ability to run a model that doesn't fit — each replica needs the whole model.
✗ A bigger KV pool for one request — a request can only use its own replica's memory.6. Under the hood — the memory economics#
An 8B dense model (KV ≈ 128 KB per token, 12.f) on 80 GB GPUs, 4,096-token sequences (≈ 0.54 GB of KV each):
Configuration GPUs Weights KV memory Max concurrent sequences
1 × (1 GPU) 1 16 GB ~60 GB ~111
DP=4 4 64 GB (4 copies) ~240 GB ~444
TP=4 (1 replica) 4 16 GB (4 GB/GPU) ~300 GB ~555TP=4 holds more total KV than DP=4, because the weights are not duplicated. If KV capacity for very long sequences is your limit, TP (or context parallelism, 14.f) can win.
But TP=4 has one queue and one scheduler, so one huge request affects everyone; with DP=4, three replicas are unaffected. Isolation is a real benefit of DP.
7. Performance implications#
Throughput Per-request latency Efficiency
1 GPU 1.0x baseline 100%
DP=4 4.0x same ~100%
TP=4 (NVLink) ~3.4x up to 4x better ~85%
DP=2 × TP=2 ~3.6x up to 2x better ~90%DP=2 × TP=2 is often the sweet spot when you need some latency improvement and good scaling:
small TP degrees scale most efficiently, and DP on top scales almost perfectly.
8. Production implications#
- Scale throughput with DP. It is free efficiency.
- Use the smallest TP degree that meets fit and latency, then add DP.
- Invest in the router. It decides your prefix hit rate and your load balance (21.g, 21.h).
- DP isolates failures. One replica crashing loses 1/N of capacity; one GPU in a TP group takes down the whole group.
- DP makes rollouts easy. Upgrade replicas one at a time; a TP group must change together.
- Watch the duplication cost for large models — it is what pushes you toward TP, EP, or quantization.
9. Common mistakes#
- Using TP when DP would do. The most common distributed-inference error.
- Round-robin across replicas with prefix caching on. You built a cache and then guaranteed misses.
- Assuming DP scaling is automatic. It is linear only if the router balances real load, not request counts.
- Forgetting that each replica has its own KV pool. DP cannot give one request 100 GB of KV.
- Not using the isolation. DP lets you canary one replica, drain one, and isolate noisy tenants.
10. Hands-on exercise#
A. Measure DP scaling. Run 1, 2 and 4 replicas of a small model behind a load balancer and measure total throughput. Is it linear? If not, what limited it — the balancer, the client, the network?
B. DP vs TP. With 4 GPUs, compare DP=4 and TP=4 on total throughput, p50 and p99 latency, and total KV capacity.
C. The routing effect. With 4 replicas and prefix caching on, replay a multi-turn chat trace with round-robin and then with session-affinity routing. Compare prefix hit rate and throughput.
D. Composition. With 8 GPUs and a model that fits on one, compare DP=8×TP=1, DP=4×TP=2, DP=2×TP=4 and DP=1×TP=8. Plot throughput against p95 latency. Where is the sweet spot for a 30 ms ITL target?
E. Blast radius. Kill one replica in DP=4, then one GPU in TP=4. Compare the impact.
11. Interview questions#
- What is data parallelism, and what does it cost in communication and memory?
- Why is DP preferred over TP for throughput?
- What does DP not give you?
- Why does TP=4 hold more total KV than DP=4?
- Why does routing quality matter so much with DP?
- What is attention DP, and why do large MoE models use it?
- With 8 GPUs and a model that fits on one, how would you configure it, and why?
12. Further reading#
Checked on 12 November 2026.
- [ESTABLISHED] Pope et al., “Efficiently Scaling Transformer Inference” (2022)
- [REFERENCE] vLLM — data parallel deployment
- [REFERENCE] SGLang — server arguments (
--dp-size,--enable-dp-attention) - [ESTABLISHED] LMSYS — DeepSeek with PD disaggregation and large-scale expert parallelism — attention DP plus expert parallelism in practice