Summary
The first of two parallelism lectures, taught by Percy Liang, introducing the mechanics of multi-GPU training from the ground up. It extends the previous week’s single-GPU kernel material by adding two more levels to the memory hierarchy: intra-node GPUs connected by NVLink/NVSwitch, and inter-node GPUs connected by InfiniBand or Ethernet. The first half covers collective communication primitives and the hardware and software stack that implements them (NCCL, torch.distributed); the second half implements data, tensor, and pipeline parallelism on a multi-layer MLP. It deliberately works at the level of explicit collective calls rather than library wrappers, since the course builds things from scratch.
Key Takeaways
- The framing principle is the same as for single-GPU work: compute is far from data, so the job is to orchestrate computation to avoid data-transfer bottlenecks. What counted as slow last week (HBM) counts as fast here.
- Two distinct reasons to go multi-GPU: parameters, gradients, and optimizer state do not fit in one device’s HBM (a B200 has 192 GB, far short of a 1T-parameter model), and splitting work across devices trains faster even when the model does fit.
- Collectives divide into warm-ups (broadcast, scatter, gather, reduce) and the ones that actually drive LM training (all-gather, reduce-scatter, all-reduce), plus all-to-all, which matters for MoE routing where each rank holds both a data shard and a subset of experts.
- The key identity, demonstrated by example in code: all-reduce equals reduce-scatter followed by all-gather. Breaking all-reduce into its two halves is what later enables ZeRO and FSDP to intervene between the steps.
- Hardware calibration: typically 8 GPUs per node on NVLink/NVSwitch, with NVLink 5 giving about 1.8 TB/s aggregate against roughly 8 TB/s of B200 HBM bandwidth, so inter-GPU transfer is about 4x slower than local memory. NVL72 extends a single NVLink domain to 72 GPUs.
- RDMA lets one GPU read and write another’s memory without involving the CPU. NVLink/NVSwitch and InfiniBand support it; plain Ethernet does not, which is why RoCE (RDMA over Converged Ethernet) exists as a cheaper alternative to InfiniBand.
- Measured effective bandwidth for all-reduce works out to
size * 2 * (world_size - 1) / world_size / duration, about 400 GB/s in the demo. As world size grows the factor approaches 1, so bandwidth is independent of both world size and the ring/tree topology NCCL chooses. All-reduce moves twice the data of reduce-scatter and takes twice as long, so the two report the same bandwidth. - DDP is a one-line change to a normal training loop: after the backward pass, all-reduce and average
param.gradacross ranks, so every rank updates identical parameters from a distinct data shard. It is fully modular and does not care what the forward pass looks like. - Tensor parallelism (here column-parallel) instead splits each weight matrix, so every layer must all-gather activations in the forward pass and reduce-scatter in the backward pass — a duality that recurs throughout. Pipeline parallelism splits layers and uses point-to-point send/recv, with micro-batches to shrink pipeline bubbles.
- Choice of strategy follows the interconnect: tensor parallelism moves large activations every layer and so belongs inside an NVLink domain, while pipeline parallelism tolerates slow links and is used in decentralized training. Data parallelism is bounded by the critical batch size, beyond which more batch stops helping.
Extracted Notes
- None yet.