Navigation
🌐 Distributed GPU Systems· 12 min read

Communication Cost Analysis

Predicting communication time from message size and GPU count — the latency-bandwidth model, when startup cost dominates, and overlap strategies.

distributedcommunication-costlatencybandwidthoverlapalpha-beta

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:

T=α+NBT = \alpha + \frac{N}{B}
  • α (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 NN divided by bandwidth BB

Two Regimes

RegimeWhenDominatesOptimization
Latency-boundSmall messages (N<α×BN < \alpha \times B)Startup cost αReduce message count (batching, fusion)
Bandwidth-boundLarge messages (N>α×BN > \alpha \times B)Data volume N/BUse bandwidth-optimal algorithms (ring)

Crossover point for NVLink (α=5μs\alpha = 5μs, B=450 GB/sB = 450 \text{ GB/s}):

Ncrossover=α×B=5×10−6×450×109=2.25 MBN_{\text{crossover}} = \alpha \times B = 5 \times 10^{-6} \times 450 \times 10^9 = 2.25 \text{ MB}

Below 2.25 MB: latency-bound (use tree). Above: bandwidth-bound (use ring).


2. Cost Per Collective

For PP GPUs, message size NN bytes, per-link bandwidth BB:

CollectiveLatency componentBandwidth componentTotal
AllReduce (ring)2(P−1)α2(P-1)\alpha2N(P−1)PB\frac{2N(P-1)}{PB}2(P−1)α+2N(P−1)PB2(P-1)\alpha + \frac{2N(P-1)}{PB}
AllGather (ring)(P−1)α(P-1)\alphaN(P−1)PB\frac{N(P-1)}{PB}(P−1)α+N(P−1)PB(P-1)\alpha + \frac{N(P-1)}{PB}
ReduceScatter (ring)(P−1)α(P-1)\alphaN(P−1)PB\frac{N(P-1)}{PB}Same as AllGather
All-to-All(P−1)α(P-1)\alphaN(P−1)PB\frac{N(P-1)}{PB}Same as AllGather
Broadcast (tree)log⁡2P×α\log_2 P \times \alphaNlog⁡2PB\frac{N \log_2 P}{B}log⁡2P(α+NB)\log_2 P(\alpha + \frac{N}{B})

For Large N (Bandwidth-Dominated)

When N≫α×B×PN \gg \alpha \times B \times P, the bandwidth terms dominate and simplify:

TAllReduce≈2NB(for large P)T_{\text{AllReduce}} \approx \frac{2N}{B} \qquad \text{(for large P)}

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: N=7×109×2=14N = 7 \times 10^9 \times 2 = 14 GB. 8 GPUs on NVLink (B=450B = 450 GB/s per direction):

TAllReduce=2×7×5μs+2×14×109×78×450×109=70μs+54.4ms=54.5msT_{\text{AllReduce}} = 2 \times 7 \times 5\mu s + \frac{2 \times 14 \times 10^9 \times 7}{8 \times 450 \times 10^9} = 70\mu s + 54.4ms = 54.5ms

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): 70B/80×2=1.7570B / 80 \times 2 = 1.75 GB.

TAllGather=7×5μs+1.75×109×78×450×109=35μs+3.4ms=3.4msT_{\text{AllGather}} = 7 \times 5\mu s + \frac{1.75 \times 10^9 \times 7}{8 \times 450 \times 10^9} = 35\mu s + 3.4ms = 3.4ms

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.

TAll-to-All=31×5μs+58.7×106×3132×450×109=155μs+0.13ms=0.28msT_{\text{All-to-All}} = 31 \times 5\mu s + \frac{58.7 \times 10^6 \times 31}{32 \times 450 \times 10^9} = 155\mu s + 0.13ms = 0.28ms

Fast — but this happens twice per MoE layer (dispatch + combine), and there are many MoE layers. At 61 layers: 61×2×0.28=34ms61 \times 2 \times 0.28 = 34ms 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:

PathBandwidthLatencyTechnology
Intra-node (same server)450-900 GB/s~5 μsNVLink 4.0/5.0
Inter-node (across servers)25-50 GB/s~1-5 μsInfiniBand 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:

η=TcomputeTcompute+Tcomm_exposed\eta = \frac{T_{\text{compute}}}{T_{\text{compute}} + T_{\text{comm\_exposed}}}

Where Tcomm_exposedT_{\text{comm\_exposed}} is the communication time not overlapped with compute.

ScenarioComputeComm (total)OverlapExposed commEfficiency
DDP, large batch100 ms50 ms90%5 ms95%
DDP, small batch20 ms50 ms40%30 ms40%
FSDP, good prefetch100 ms30 ms80%6 ms94%
TP across InfiniBand100 ms200 ms0%200 ms33%

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

References