A 1.5-billion-parameter GPT-2 model needs just 3 GB to hold its weights in 16-bit precision, yet it crashes with an out-of-memory error on a 32 GB GPU under standard PyTorch or TensorFlow data parallelism. In 2020, Microsoft researchers Samyam Rajbhandari, Jeff Rasley, Olatunji Ruwase, and Yuxiong He accounted for every gigabyte behind that crash and introduced the Zero Redundancy Optimizer (ZeRO), partitioning replicated training state across data-parallel GPUs without requiring developers to refactor their models.
ZeRO (released inside DeepSpeed and mirrored today in PyTorch FSDP) transformed data parallelism from a throughput technique capped at 1.4B parameters on 32 GB V100 GPUs into the memory backbone of multi-node LLM training, working alongside Megatron-LM tensor parallelism and Llama 3’s four-dimensional parallelism.
- The 16x parameter memory tax: in mixed-precision training with Adam, a
Psi-parameter model stores FP16 parameters (2*Psi), FP16 gradients (2*Psi), and12*Psibytes of FP32 optimizer state (master weights, momentum, variance), totaling16*Psibytes (24 GB for 1.5B, 120 GB for 7.5B). - Three cumulative sharding stages (
ZeRO-DP): partitioning optimizer states (Pos, up to 4x reduction, 1x comms), gradients (Pos+g, up to 8x reduction, 1x comms), and parameters (Pos+g+p, linearNd-fold reduction, 1.5x comms). - Residual memory (
ZeRO-R) stops hidden OOMs: partitions model-parallel activation checkpoints (Pa), caps fused temporary buffers (CB), and defragments short- and long-lived tensors (MD) that otherwise cause OOMs with over 30% of memory free. - Empirical scale on 400 V100 GPUs:
ZeRO-100B(Pos+gplusZeRO-R) trains 13B models with pure data parallelism (vs. 1.4B in PyTorch DDP), scales to 170B models with intra-node MP (8x larger and up to 10x faster than Megatron-LM), sustains 15 Petaflops (38+ TFlops/GPU), shows super-linear scaling on 60B models, and trained the 17B Turing-NLG model.
Where training memory goes and why existing parallelisms stall
Section 3 splits GPU training memory into model states and residual states. For a mixed-precision Adam run with Psi parameters, FP16 weights consume 2*Psi bytes and FP16 gradients consume 2*Psi bytes. The optimizer itself needs three FP32 tensors: master weights (4*Psi), momentum (4*Psi), and gradient variance (4*Psi), giving an optimizer multiplier K = 12 and a total model-state bill of 16*Psi bytes. For 1.5B-parameter GPT-2, that is already 24 GB before a single activation is stored.
Residual memory fills the remaining headroom in three ways. First, activations scale as roughly 12 * hidden * batch * seq * layers, consuming 60 GB for 1.5B GPT-2 at sequence length 1,024 and batch size 32. Activation checkpointing trims that to 8 GB at a 33% recompute cost, yet a 100B model still demands 60 GB of checkpoints at batch size 32. Second, frameworks fuse gradients into flat FP32 buffers for faster collectives, costing 6 GB at 1.5B parameters (12 GB at 3B). Third, mixing long-lived tensors (activation checkpoints, parameter gradients) with short-lived tensors (recomputed activations, activation gradients) fragments the allocator, causing OOMs when over 30% of GPU memory is still unallocated.
Naive alternatives solve one piece by breaking another:
- Standard Data Parallelism (DDP) keeps high arithmetic granularity and low communication (
2*Psiper step), yet replicates all16*Psimodel states across every worker. Adding GPUs adds zero model capacity, capping DDP at 1.4B parameters on 32 GB V100s. - Model Parallelism (MP) splits layers vertically, shrinking model states per GPU while still replicating layer input activations across workers and shrinking GEMM sizes. Worse, MP communicates every layer, so once a model crosses one DGX-2 node (
300 GB/sNVSwitch links) onto InfiniBand EDR (12.5 GB/sper link), throughput collapses: a 40B Megatron-LM model across two DGX-2 nodes hit just 5 TFlops per V100 (under 5% of hardware peak). - Pipeline Parallelism (PP) forces large batch sizes in GPipe (hurting convergence and inflating activation memory) or stores multiple stale parameter copies in PipeDream (wasting memory and altering optimization semantics).
- Naive CPU Offloading pushes model states over PCIe, burning up to 50% of training time on host-device transfers.
How ZeRO-DP and ZeRO-R remove redundancy without extra hops
ZeRO-DP’s central trick (Section 7) turns ring all-reduce inside out. In standard DDP, averaging Psi gradients across Nd GPUs via an all-reduce already runs in two phases: a Reduce-Scatter (Psi data movement, leaving 1/Nd of the reduced gradients on each GPU) followed by an All-Gather (Psi data movement, re-replicating every gradient on every GPU) for 2*Psi total traffic.
Because each GPU in Pos (Stage 1) and Pos+g (Stage 2) updates only its owned 1/Nd parameter shard, ZeRO simply skips re-replicating gradients and optimizer states. During backward propagation, Pos+g bucketizes gradients by partition and runs a Reduce-Scatter (Psi volume), releasing each gradient buffer immediately afterward. Each GPU updates its 1/Nd slice of FP32 master weights, casts it to FP16, and runs one All-Gather (Psi volume) on the updated FP16 weights. Total traffic stays Psi + Psi = 2*Psi, identical to standard DDP, while model-state memory drops up to 4x (Pos) or 8x (Pos+g).
Pos+g+p (Stage 3) applies the same temporal insight to parameters: a layer’s weights are only needed during that layer’s forward and backward compute. Each partition owner broadcasts (or all-gathers) weights layer by layer right before compute and discards non-owned weights immediately afterward. Doing this once in forward (Psi), once in backward (Psi), and once for gradient Reduce-Scatter (Psi) brings total communication to 3*Psi, only 1.5x DDP, while cutting model-state memory linearly by Nd. Across 1,024 GPUs, a 1-trillion-parameter model’s 16 TB of model state drops to 15.6 GB per GPU.
Once ZeRO-DP shrinks model states, ZeRO-R targets the three residual bottlenecks summarized below.
Compare ZeRO stages and residual configs at cluster scale
Not every training job needs full Stage 3 parameter sharding or CPU activation offload. Compare the memory ceilings, communication multipliers, and measured V100 cluster numbers across standard DDP, the three ZeRO-DP stages, and the paper’s five ZeRO-R ablation configs below.
Select a configuration (or use Left and Right arrow keys) to compare per-GPU memory formulas, communication volume, and measured 32 GB V100 benchmarks.
Standard PyTorch Distributed Data Parallel
BaselineReplicates FP16 weights, FP16 gradients, and all FP32 Adam states identically on every GPU.
- Per-GPU model state
- 16*Psi bytes regardless of GPU count Nd: 24 GB for 1.5B parameters and 120 GB for 7.5B parameters.
- Communication volume
- 2*Psi per step via standard gradient all-reduce (Reduce-Scatter plus All-Gather).
- Measured cluster limit
- Without MP, PyTorch DDP caps at 1.38B parameters on 32 GB V100 GPUs and runs below 20 TFlops per GPU on 128 GPUs.
- Multi-node MP fallback
- Adding Megatron-LM MP across two DGX-2 nodes for a 40B model drops throughput to ~5 TFlops/V100 (under 5% peak) over 12.5 GB/s InfiniBand.
Optimizer State Partitioning (Pos)
ZeRO-DPShards the 12*Psi FP32 master weights, momentum, and variance across Nd GPUs while leaving FP16 weights and gradients replicated.
- Per-GPU model state
- 4*Psi + 12*Psi / Nd bytes (up to 4x reduction). Drops a 7.5B model from 120 GB to 31.4 GB at Nd=64.
- Communication volume
- 2*Psi per step (gradient reduce-scatter of Psi followed by parameter all-gather of Psi on updated shards), matching standard DP.
- Measured cluster limit
- Table 2 measured 6.2B (MP=1), 12.5B (MP=2), 25B (MP=4), 50B (MP=8), and 100B (MP=16) on 32 GB V100s, closely tracking theory.
- When it fits
- Enough by itself whenever FP32 optimizer states dominate and 4x model-state reduction fits the target model on your cluster.
Optimizer + Gradient Partitioning (Pos+g)
ZeRO-DP (ZeRO-100B)Retains only each worker's 1/Nd gradient shard right after Reduce-Scatter, freeing the remaining gradient memory immediately during backprop.
- Per-GPU model state
- 2*Psi + 14*Psi / Nd bytes (up to 8x reduction). Drops a 7.5B model to 16.6 GB at Nd=64 and 128B to 284 GB.
- Communication volume
- Still 2*Psi per step: one bucketed Reduce-Scatter (Psi) for gradients and one All-Gather (Psi) for updated FP16 parameters.
- Measured cluster limit
- As ZeRO-100B (with ZeRO-R), trains 13B models with pure DP (>40 TFlops/GPU on 128 GPUs), 170B models with MP=16 on 400 GPUs (15 Petaflops), and Turing-NLG 17B (41.4 TFlops/GPU).
- Super-linear scaling
- On a 60B model from 64 to 400 GPUs, shrinking per-GPU model state lets batch size rise (64 to 1,600 total), doubling throughput faster than GPU count.
Full State + Parameter Partitioning (Pos+g+p)
ZeRO-DP (Analytical)Shards FP16 parameters alongside gradients and optimizer states, gathering each layer on demand and discarding non-owned weights right after compute.
- Per-GPU model state
- 16*Psi / Nd bytes (linear with DP degree). Cuts 7.5B to 1.88 GB (Nd=64), 128B to 32 GB (Nd=64), and 1T parameters to 15.6 GB (Nd=1,024).
- Communication volume
- 3*Psi per step (1.5x DDP): pipelined parameter all-gather in forward (Psi), reverse all-gather in backward (Psi), and gradient reduce-scatter (Psi).
- Paper status caveat
- Evaluated analytically in this 2020 paper (Tables 1 and 2); not yet implemented in ZeRO-100B at publication (shipped later in DeepSpeed ZeRO-3).
- Compute reality check
- 1T parameters fits in memory on 1,024 V100s, yet at ~3,000x BERT-Large compute per sample it would still take 140 days to over a year on 2020 hardware.
Residual Memory Ablations (Configs C1 through C5)
Residual ablationsIsolates how Pa, Pos+g, and CPU checkpoint offload (Pa+cpu) expand max model size and alter throughput on 400 V100 GPUs with MP=16.
- C1 -> C2 (add Pa)
- Adding partitioned activation checkpoints to Pos+CB+MD raises fixed-batch max model size from 40B (C1) to 60B (C2) by cutting activation checkpoints 16x.
- C2 -> C4 (add Pos+g)
- Switching from Pos to Pos+g halves remaining model-state memory, jumping max model size from 60B (C2) to 140B (C4).
- C4 -> C5 (add Pa+cpu)
- Offloading partitioned checkpoints to host CPU pushes max size to 150B at fixed batch and enables 170B training (where C4 runs OOM).
- C5 throughput penalty
- On a 60B model, C5 runs slower than C4 due to PCIe CPU-GPU transfers; Pa+cpu helps only when models OOM or batch size is otherwise tiny.
Source: Rajbhandari et al. (2020), Tables 1 through 4 and Section 10.
Without clicking through the tabs, the five regimes show where each ZeRO piece earns its keep:
- Standard DP: replicates all
16*Psibytes per GPU and hits OOM past 1.4B parameters on 32 GB V100s, while cross-node Megatron-LM MP stalls below 5 TFlops/V100. - Stage 1 (
Pos): shards the12*PsiFP32 optimizer states with zero extra communication (2*Psi), cutting 7.5B model state from 120 GB to 31.4 GB atNd=64and scaling to 100B with intra-node MP=16. - Stage 2 (
Pos+g): keeps gradients partitioned after Reduce-Scatter (still2*Psicomms), cutting 7.5B state to 16.6 GB atNd=64, training 13B models with DP alone, and reaching 170B (15 Petaflops) asZeRO-100B. - Stage 3 (
Pos+g+p): shrinks model state linearly as16*Psi / Nd(fitting 128B on 64 GPUs or 1T on 1,024 GPUs) for 1.5x DDP communication (3*Psi), though it was analytical-only in this paper. ZeRO-R(C1-C5):Pajumps fixed-batch capacity from 40B to 60B,Pos+gjumps to 140B, andPa+cpureaches 150B to 170B while trading away speed on 60B models over PCIe.
Scope limits and what changed after ZeRO-100B
Three caveats keep the 2020 paper’s claims grounded. First, Stage 3 (Pos+g+p) was not yet implemented or benchmarked in the paper’s code: every empirical speedup and 170B run came from ZeRO-100B (Pos+g plus ZeRO-R), and Section 9 explicitly warns that fitting 1T parameters in memory on 1,024 V100 GPUs still leaves a massive compute gap (140 days to over a year of wall-clock training). Second, super-linear scaling has a batch-size ceiling: scaling a 60B model from 64 to 400 GPUs more than doubled throughput per doubling of GPUs because freed memory allowed larger per-GPU batch sizes, yet Footnotes 1 and 5 note that pushing global batch size past the critical batch size slows statistical convergence. Third, CPU activation offload (Pa+cpu) is a last resort: Config C5 degraded 60B throughput relative to C4 and only paid off at 170B where C4 ran out of memory.
Since 2020, Pos+g+p shipped in DeepSpeed ZeRO-3 and PyTorch FSDP, and sequence parallelism with selective recomputation generalized Pa so non-checkpointed activations such as LayerNorm and dropout never replicate across tensor-parallel ranks. For engineers configuring distributed training today, the practical hierarchy from ZeRO still governs cluster layout: keep tensor parallelism inside fast intra-node NVLink/NVSwitch domains, turn on Stage 1 or Stage 2 sharding first (free memory savings at 1x DDP traffic), and step up to Stage 3 or activation offload only when model state or batch size genuinely overflows GPU HBM.


