ParallelismOptimization track

ZeRO & FSDP

Read it in Chapter 4 · checkpoint +50 XP →

Shard optimizer state, gradients and parameters across data-parallel ranks instead of replicating them.

Plain Data parallelism (DDP) wastes memory: every rank stores identical copies of everything. ZeRO (and PyTorch's FSDP) shards it:

StageShardedPer-GPU state (mixed-precision Adam)
0nothing16 B/param
1optimizer states4 + 12/N B/param
2+ gradients2 + 14/N B/param
3 / FSDP+ parameters16/N B/param

The catch with stage 3: parameters must be all-gathered before each layer's forward and backward, every micro-batch. For a 70B model that's ~140 GB moved twice per micro-batch. On NVLink that's fine. Over a 400 Gb/s NIC it can dominate the step.

Practical guidance

  • ZeRO-1 is nearly free and almost always worth it.
  • ZeRO-3/FSDP is excellent within a node or on fast fabrics, and for fitting a model that otherwise wouldn't fit.
  • At large scale, mix it: TP inside the node, ZeRO-1 or hybrid sharding (shard within a node, replicate across nodes).
LIVE Training memory calculator
weights 13.4 GBgradients 13.4 GBoptimizer 5.0 GBactivations 36.5 GBframework 3.0 GB
80 GB HBM
Per GPU
71.3 GB
Verdict
fits
Data parallel
dp = 16
Params / GPU
6.70 B

Per-GPU memory for mixed-precision Adam, sequence length 4096, flash attention. Activations use the Korthikanti et al. estimate.

Use it in a mission

Related

Sources & further reading

Written for LazyLab in our own words; sources are cited for depth and verification.