Summary
The second parallelism lecture, taught by Tatsunori Hashimoto, moving from the mechanics of the previous lecture to the full modern toolbox and how practitioners combine it. It works through the ZeRO stages and FSDP, then pipeline, tensor, sequence, expert, and context parallelism, with careful memory accounting at each step. The recurring theme is that no single strategy dominates: each consumes a different resource (batch size, bandwidth, memory) and each has a regime where it fails. It ends with a simple prescription for combining them into so-called 4D parallelism, and a survey of published parallelism configurations from real training runs.
Key Takeaways
- Memory accounting motivates everything: a rule of thumb of roughly five copies of weights and about 16 bytes per parameter, with Adam’s first and second moments dominating. Naive data parallelism replicates all of that on every device and saves no memory at all.
- ZeRO stage 1 shards optimizer state, replacing DDP’s single all-reduce with a reduce-scatter of gradients plus an all-gather of updated parameters. Since those two equal one all-reduce, the memory saving is communication-free.
- ZeRO stage 2 shards gradients by reducing each layer’s gradients as the backward sweep produces them and freeing them immediately, which is again free. ZeRO stage 3 (FSDP) shards parameters too, gathering them on demand per layer: two all-gathers plus one reduce-scatter, so one extra all-gather, hidden in practice by overlapping communication with computation.
- The practical payoff: on 8x A100 the baseline cannot fit a 7B model, while ZeRO stage 3 reaches roughly 50B. FSDP’s utilization lands close to single-GPU performance.
- Data parallelism consumes the global batch size as a resource, and the critical batch size caps how far that goes — the reason model parallelism becomes necessary rather than optional. ZeRO also leaves activation memory untouched.
- Model parallelism differs from FSDP in what moves: FSDP ships parameters and runs the ordinary computation, while pipeline, tensor, and expert parallelism ship activations.
- Pipeline parallelism’s utilization is stages over micro-batches, so bubbles shrink only with large batches. Zero-bubble pipelining splits the backward pass into propagating partials (urgent, blocks the next stage) and computing weight gradients (deferrable into gaps), nearly filling the pipeline. Its communication is only
b*s*hand point-to-point, so it belongs on the slowest links. - Tensor parallelism cuts column-wise at MLP up-projections and attention projections and row-wise at the corresponding outputs, replicating small ops like layer norms and routers. It all-reduces at activation size every matmul, so it stays within one box (up to 8 on GPUs); TPUs can go wider because of the uniform mesh.
- Activation memory is about
34*s*b*hplus a quadratic attention term. Tensor parallelism divides 24 of the 34 but leaves roughly10*s*b*hin layer norms, dropout, and residual inputs; sequence parallelism splits that remainder along the sequence axis with all-gathers and reduce-scatters, and recomputation removes the softmax term, giving a practical floor of34*s*b*h/t. - For MoEs, expert parallelism is preferred over tensor parallelism (per NVIDIA’s Megatron guidance), since slicing matrices too finely shrinks matmuls and hurts utilization. Its all-to-all dispatch is latency-critical, which is why DeepSeek’s DeepEP library reaches for undocumented PTX instructions.
- The prescription: shard the model until it fits, using tensor or expert parallelism inside the fast interconnect, then pipeline or ZeRO-3 to close the gap, then spend remaining devices on data parallelism, with gradient accumulation if the batch gets too small.
- Published configurations bear this out: OLMo 7B trained purely with FSDP; DeepSeek V3 uses 64-way expert parallelism across 8-machine groups; Llama 3 405B ran TP 8, CP 1, PP 16, DP 128, raising context parallelism for long-context extension (and hit 148 GPU failures); Gemma 2 uses FSDP with tensor and sequence parallelism and no pipeline at all.
Extracted Notes
- None yet.