Communication Cost Analysis
Predicting communication time from message size and GPU count — the latency-bandwidth model, when startup cost dominates, and overlap strategies.
The difference between “distributed training that scales” and “distributed training that wastes GPUs” is almost always communication cost. This chapter gives you the formulas to predict whether adding more GPUs will help — before you spend the compute.
1. The α-β Model
Every communication operation has two cost components:
- α (alpha): startup latency — fixed cost per message regardless of size (~5-10 μs for NVLink, ~1-5 μs for InfiniBand)
- N/B: transfer time — message size divided by bandwidth
Two Regimes
| Regime | When | Dominates | Optimization |
|---|---|---|---|
| Latency-bound | Small messages () | Startup cost α | Reduce message count (batching, fusion) |
| Bandwidth-bound | Large messages () | Data volume N/B | Use bandwidth-optimal algorithms (ring) |
Crossover point for NVLink (, ):
Below 2.25 MB: latency-bound (use tree). Above: bandwidth-bound (use ring).
2. Cost Per Collective
For GPUs, message size bytes, per-link bandwidth :
| Collective | Latency component | Bandwidth component | Total |
|---|---|---|---|
| AllReduce (ring) | |||
| AllGather (ring) | |||
| ReduceScatter (ring) | Same as AllGather | ||
| All-to-All | Same as AllGather | ||
| Broadcast (tree) |
For Large N (Bandwidth-Dominated)
When , the bandwidth terms dominate and simplify:
This is the key result: AllReduce time is approximately constant regardless of how many GPUs you use (for large messages). This is why data-parallel training can scale to thousands of GPUs.
3. Worked Examples
Example 1: Gradient Sync in DDP
7B model, BF16 gradients: GB. 8 GPUs on NVLink ( GB/s per direction):
With gradient bucketing (start AllReduce during backward): effective overhead ≈ last bucket only ≈ 5-10 ms.
Example 2: FSDP Parameter Gather
70B model sharded across 8 GPUs. Before each layer, AllGather the parameters. Per-layer parameters (one of 80 layers): GB.
Per layer: 3.4ms communication. If the layer’s compute takes 10ms, communication is 25% overhead — acceptable with overlap.
Example 3: MoE All-to-All
DeepSeek-V3: 256 experts across 32 GPUs. Each GPU sends different tokens to each other. Token batch: 4096 tokens × 7168 hidden × 2 bytes = 58.7 MB per GPU.
Fast — but this happens twice per MoE layer (dispatch + combine), and there are many MoE layers. At 61 layers: total All-to-All per forward pass.
4. Intra-Node vs Inter-Node
Communication cost depends dramatically on whether GPUs are in the same node:
| Path | Bandwidth | Latency | Technology |
|---|---|---|---|
| Intra-node (same server) | 450-900 GB/s | ~5 μs | NVLink 4.0/5.0 |
| Inter-node (across servers) | 25-50 GB/s | ~1-5 μs | InfiniBand NDR |
The bandwidth gap: NVLink is 10-36× faster than InfiniBand. This is why:
- Tensor Parallelism (high communication) → must be intra-node (NVLink)
- Data Parallelism (moderate communication) → can be inter-node (InfiniBand)
- Pipeline Parallelism (low communication) → inter-node is fine
Example: AllReduce Intra vs Inter
14 GB gradient AllReduce:
- Intra-node (8 GPUs, NVLink 450 GB/s): ~55 ms
- Inter-node (8 nodes × 8 GPUs, IB 50 GB/s): ~560 ms for inter-node part
This 10× gap is why parallelism strategy must match the network topology.
5. Communication-Computation Overlap
The goal: hide communication behind computation so it’s “free.”
Gradient Bucketing (DDP)
Backward: [Layer 32 grad] [Layer 31 grad] [Layer 30 grad] ...
AllReduce: [Bucket 8 AR] [Bucket 7 AR] ...
Overlap fraction = min(backward_time, allreduce_time) / allreduce_time. If backward takes 100ms and AllReduce takes 50ms, overlap is 100% — AllReduce is completely hidden.
FSDP Prefetching
Forward: [AllGather L0] [Compute L0] [AllGather L1] [Compute L1] ...
Optimal: [AG L0][Compute L0 + AG L1][Compute L1 + AG L2] ...
Prefetch the next layer’s parameters while computing the current layer. FSDP does this with forward_prefetch=True.
Pipeline Overlap
In pipeline parallelism, one stage sends activations to the next while the current stage starts the next micro-batch:
Stage 0: [F_mb0] [F_mb1] [F_mb2] ...
Stage 1: [recv] [F_mb0] [F_mb1] ...
↑ hidden behind Stage 0's next micro-batch
6. Predicting Scaling Efficiency
Scaling efficiency = ideal time / actual time:
Where is the communication time not overlapped with compute.
| Scenario | Compute | Comm (total) | Overlap | Exposed comm | Efficiency |
|---|---|---|---|---|---|
| DDP, large batch | 100 ms | 50 ms | 90% | 5 ms | 95% |
| DDP, small batch | 20 ms | 50 ms | 40% | 30 ms | 40% |
| FSDP, good prefetch | 100 ms | 30 ms | 80% | 6 ms | 94% |
| TP across InfiniBand | 100 ms | 200 ms | 0% | 200 ms | 33% |
Key insight: Efficiency depends on the ratio of compute to exposed communication. Large batches help (more compute to hide behind). Bad topology kills efficiency (TP on InfiniBand).
Self-Check
- Apply the α-β model to calculate AllReduce time for given N, P, B
- Explain the crossover between latency-bound and bandwidth-bound regimes
- Calculate gradient sync time for a 7B model across 8 GPUs
- Explain why NVLink vs InfiniBand determines parallelism strategy placement
- Calculate scaling efficiency given compute time and communication overlap
- Explain three overlap techniques: gradient bucketing, FSDP prefetch, pipeline overlap