Chapter 38
Communication Models, Collectives, and Topology
On this page
- The alpha-beta model
- Collective semantics
- Ring all-reduce
- The adjoint determines communication in backward
- Trees and hierarchical collectives
- Bandwidth accounting
- Topology and process groups
- Communication and computation overlap
- GPUDirect, RDMA, and registration
- Collective correctness and deadlocks
- Design Exercises
- Worked Solutions
Distributed performance is governed by the bytes, synchronization steps, link paths, and overlap opportunities on the critical path. FLOPs alone cannot explain a job that waits on communication.
The alpha-beta model¶
For a message of n bytes, a first-order point-to-point time model is:
alpha is fixed latency, including launch, protocol, and synchronization. beta is sustainable bandwidth for the path and message regime. The model separates two common failures:
- many tiny operations pay latency repeatedly;
- large operations saturate bandwidth or a shared bottleneck.
Real systems add contention, topology hops, protocol thresholds, device synchronization, reduction compute, and software overhead. The alpha-beta model is still useful because it predicts whether to fuse messages, reduce bytes, change the algorithm, or overlap work.
Measure effective values by message size, source/destination placement, concurrency, and direction. Nameplate link bandwidth is not application bandwidth. A path may traverse a GPU fabric, PCIe switch, host bridge, NIC, top-of-rack switch, and oversubscribed spine.
Collective semantics¶
The core collectives have different ownership contracts:
| Collective | Input ownership | Output ownership | Typical ML use |
|---|---|---|---|
| Broadcast | One rank owns full input | Every rank receives full tensor | Parameters, metadata |
| All-reduce | Every rank owns full contribution | Every rank receives reduced tensor | Replicated gradients |
| Reduce-scatter | Every rank owns full contribution | Each rank receives one reduced shard | Sharded gradients |
| All-gather | Each rank owns one shard | Every rank receives the concatenation | Sharded parameters/activations |
| All-to-all | Each rank owns destination partitions | Each rank receives its incoming partitions | Expert token dispatch |
| Send/receive | One source and destination per operation | Destination receives message | Pipeline activations |
A collective is both data movement and a participation contract. Every rank in the communicator must issue compatible operations in compatible order. Shape, dtype, count, root, and sequence disagreements can hang or corrupt the job.
Ring all-reduce¶
For p ranks and a tensor of N bytes per rank, a ring all-reduce is commonly decomposed into a reduce-scatter and an all-gather. Each rank sends approximately the following volume and receives the same volume; it is not their sum:
2 (p - 1) N / p bytes
There are approximately 2 (p - 1) serialized steps. A simplified time is:
The ring approaches two tensor volumes per rank for large p, making it bandwidth-efficient for large messages. Its latency term grows with rank count, so a tree or other algorithm can be better for small messages. Implementations choose protocols and algorithms by topology and size; do not assume one ring for every collective.
The adjoint determines communication in backward¶
Treat a collective as a linear map between rank-indexed vector spaces and use the ordinary sum of per-rank inner products. For all-gather, every output rank receives all input shards. If output rank r contributes gradient shard g[r,j], input owner j needs sum_r g[r,j]: the adjoint is sum reduce-scatter. Conversely, the adjoint of sum reduce-scatter is all-gather. The adjoint of sum all-reduce is sum all-reduce.
These statements assume each output replica is a distinct argument in the global loss. If a tensor is logically replicated and each rank redundantly computes the same loss, the program must avoid counting that loss once per replica. Tensor-parallel frameworks often implement an identity-forward/reduce-backward mapping at the input boundary and a reduce-forward/identity-backward mapping at the output boundary to encode that logical ownership. Applying the mathematical adjoint of a raw all-reduce blindly to a redundantly replicated loss introduces an extra factor of the group size.
The NCCL collective contracts specify data movement and rank ordering. They do not automatically define the autograd semantics of an arbitrary framework wrapper. Record whether each reduction is a sum or mean and whether each replica represents independent loss contributions.
Trees and hierarchical collectives¶
A balanced tree reduces the number of latency steps to order log p, but link utilization and total bytes depend on the tree and topology. It often helps small or medium messages where startup dominates.
Hierarchical collectives first reduce or gather within a high-bandwidth domain, then communicate representatives across slower links, then distribute locally. Common domains are accelerator fabric within a node, NIC rails across nodes, or islands inside a rack.
The hierarchy must match contention. If every local rank sends independently through one NIC, aggregate injection bandwidth, not GPU links, limits the operation. If ranks are mapped inconsistently across nodes, the logical ring can cross slow links more often than expected.
Bandwidth accounting¶
Distinguish:
- algorithm bandwidth: useful tensor bytes divided by elapsed time;
- bus bandwidth: an adjusted measure reflecting bytes carried by the collective algorithm;
- link bandwidth: measured bytes on a physical edge;
- injection bandwidth: aggregate traffic a node or NIC can enter into the network;
- bisection bandwidth: capacity between large partitions of the cluster.
These numbers answer different questions. A collective can report respectable per-rank bandwidth while oversubscribing a shared uplink and slowing other groups. Compare the definition used by the benchmark with the application traffic pattern.
Topology and process groups¶
Build a topology inventory before selecting degrees:
- GPUs per high-bandwidth fabric domain;
- PCIe root and CPU socket affinity;
- NIC count, rail mapping, and GPU-to-NIC locality;
- intra-rack and inter-rack oversubscription;
- shared storage and control-plane paths;
- failure boundaries for host, switch, rack, and zone.
Map frequent, latency-sensitive collectives to the fastest domain. Tensor-parallel groups commonly stay within a node or fabric island. Data-parallel groups can span nodes because their larger gradient collectives have more overlap opportunity. Expert and context groups require separate analysis because they move activations and may be sensitive to token imbalance.
Process-group construction is part of correctness. Generate groups from a deterministic rank coordinate system, print membership, and test that every rank derives the same groups. Overlapping groups are legal, but concurrent collectives need a globally consistent launch order or independent synchronization.
Communication and computation overlap¶
Overlap removes communication from the critical path only when:
- a dependency-free compute interval exists;
- communication and compute use resources that can progress concurrently;
- network traffic does not starve the compute kernel's memory path;
- buffers remain alive and are not reused early;
- the launch order avoids communicator serialization.
Measure exposed communication, not total communication duration. If a 4 ms all-reduce overlaps 3 ms of backward compute, only roughly 1 ms is exposed, assuming no slowdown from contention. Timeline comparison must also check whether overlapped compute became slower.
Chunking creates earlier overlap but increases latency and launch overhead. Large buckets improve bandwidth but start later. The optimum follows layer order, bandwidth curve, compute gaps, and communicator scheduling.
GPUDirect, RDMA, and registration¶
Direct device networking avoids staging every transfer through host memory. It still depends on correct PCIe/NIC topology, memory registration, queue resources, and transport configuration. Registration caches and persistent buffers reduce setup cost; unbounded registration can exhaust resources.
Host control remains relevant. CPU oversubscription, interrupt placement, NUMA mismatch, container limits, or a blocked progress thread can lower collective performance even when GPU and network hardware are healthy.
Collective correctness and deadlocks¶
Common causes of hangs include:
- one rank takes a different branch and skips a collective;
- communicators issue overlapping collectives in inconsistent order;
- tensor sizes differ because of ragged inputs or a local error;
- a prior CUDA fault prevents a rank from reaching the collective;
- one rank is blocked in input, checkpoint, or host synchronization;
- a failed link or process leaves peers waiting.
Use sequence numbers, communicator IDs, tensor metadata, and call stacks in diagnostics. Timeouts limit damage but do not identify the first divergence. Capture the last successfully completed and first pending collective on every rank.
Design Exercises¶
- Derive ring all-reduce bytes and explain when a tree can be faster.
- Compare all-reduce with reduce-scatter plus all-gather by ownership and use.
- How would you map tensor- and data-parallel groups onto a multi-node topology?
- What evidence proves communication-compute overlap is useful?
- Diagnose a collective whose duration is high only on some iterations.
- Why can a bandwidth benchmark disagree with application communication performance?
Worked Solutions¶
1. A startup-dominated counterexample¶
For eight ranks and a 1 MiB payload, a ring sends 2*7/8 MiB = 1.75 MiB per rank. At 50 GB/s usable bandwidth, its byte term is about 36.7 microseconds. With fourteen ordered startup steps at two microseconds each, the simple estimate is 64.7 microseconds. For a 16 KiB payload the byte term falls to about 0.57 microseconds while startup remains 28: increasing link bandwidth barely changes that estimate.
Now measured times are 90 and 45 microseconds respectively. The model has not explained about 25.3 and 16.4 microseconds. Investigate arrival skew, synchronization, protocol choice and concurrent traffic rather than fitting one effective bandwidth to both points. A tree may reduce startup steps, but its actual schedule and congestion determine whether that wins. This calculation uses sent bytes per rank; counting both sends and receives would double the reported traffic without doubling independent full-duplex elapsed time.
2. A wrong ownership optimization¶
After reduce-scatter, rank zero holds the reduced first half and rank one the reduced second half. A downstream replicated optimizer mistakenly reads each local half as if it were a complete gradient. Shapes can still match if its parameter list was truncated too; the update is nevertheless a different model. Either all-gather the gradient for the replicated optimizer, or keep the optimizer and parameter update sharded and gather the updated parameters before the next replicated consumer. The point where ownership changes, not the collective's name alone, decides which path is valid.
3. Group mapping¶
Keep frequent latency-sensitive tensor-parallel collectives within the fastest GPU fabric and align ranks with PCIe/NIC locality. Form data-parallel groups from corresponding tensor/pipeline coordinates across replicas, preferably spreading them over independent rails without creating oversubscribed hot spots. Print group membership and physical paths, reserve cross-node bandwidth for large overlap-friendly reductions, and validate placement under one-node failure and scheduler fragmentation.
4. Useful overlap¶
Compare timelines and step time with overlap enabled and disabled at the same workload. Show that communication starts earlier, the dependency-free compute interval covers it, exposed communication decreases, and neither compute kernels nor other collectives slow from contention. Verify buffer lifetime and numerical equivalence. Total communication duration can increase while step time falls; the relevant metric is the critical path.
5. Intermittent collective latency¶
Separate rank arrival time from transport completion. Correlate slow iterations with input stalls, long kernels, memory pressure, checkpoint activity, network counters, message size, routing, and other communicator traffic. Identify the earliest late rank and its preceding event. If arrivals are aligned but transport is slow, inspect link errors, shared-uplink contention, protocol thresholds, and topology. Compare per-rank traces rather than only the maximum collective span.
6. Benchmark disagreement¶
Microbenchmarks often use aligned contiguous buffers, one communicator, steady message sizes, dedicated links, warm registrations, and no competing compute. Applications use buckets, nonuniform timing, multiple groups, topology-specific paths, concurrent storage or KV traffic, and may expose only part of the communication. Ensure the benchmark uses the same ranks, sizes, directions, concurrency, and metric definition before treating its bandwidth as a bound.