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), and 12*Psi bytes of FP32 optimizer state (master weights, momentum, variance), totaling 16*Psi bytes (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, linear Nd-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+g plus ZeRO-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.
Per-GPU model-state memory for a 7.5B mixed-precision Adam model across 64 GPUs
Baseline DDP
120 GB/GPU (1x comm volume)
15 GB FP16 weights + 15 GB FP16 grads + 90 GB FP32 Adam states (replicated on every GPU).
Stage 1 (Pos)
31.4 GB/GPU (1x comm, fits 32 GB V100)
Optimizer states sharded 64 ways (90 GB to 1.4 GB); weights and grads remain replicated (4Psi + 12Psi/Nd).
Stage 2 (Pos+g)
16.6 GB/GPU (1x comm, 7.2x savings)
Gradients also sharded via Reduce-Scatter during backprop (2Psi + 14Psi/Nd).
Stage 3 (Pos+g+p)
1.88 GB/GPU (1.5x comm, 64x savings)
Parameters sharded too (16*Psi/Nd); each layer is broadcast just before forward/backward compute and discarded after.

Source: Rajbhandari et al. (2020), Figure 1, Section 5, and Table 1.

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*Psi per step), yet replicates all 16*Psi model 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/s NVSwitch links) onto InfiniBand EDR (12.5 GB/s per 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.

How ZeRO-R handles activations, buffers, and fragmentation
Partitioned activations Pa

Shards replicated MP checkpoints across MP GPUs (33 GB down to 2 GB on a 100B model at MP=16) for under 10% extra MP traffic, with optional CPU offload (Pa+cpu).

Constant-size buffers CB

Caps fused FP32 all-reduce buffers at a fixed throughput-efficient size so a 3B model never loses 12 GB to one temporary buffer.

Memory defrag MD

Pre-allocates contiguous pools for long-lived checkpoints and gradients, preventing short-lived recomputed tensors from causing OOMs with 30%+ free RAM.

Source: Rajbhandari et al. (2020), Sections 6 and 8.

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.

Memory footprint, communication, and cluster scaling across ZeRO stages

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

Baseline

Replicates 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.

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*Psi bytes 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 the 12*Psi FP32 optimizer states with zero extra communication (2*Psi), cutting 7.5B model state from 120 GB to 31.4 GB at Nd=64 and scaling to 100B with intra-node MP=16.
  • Stage 2 (Pos+g): keeps gradients partitioned after Reduce-Scatter (still 2*Psi comms), cutting 7.5B state to 16.6 GB at Nd=64, training 13B models with DP alone, and reaching 170B (15 Petaflops) as ZeRO-100B.
  • Stage 3 (Pos+g+p): shrinks model state linearly as 16*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): Pa jumps fixed-batch capacity from 40B to 60B, Pos+g jumps to 140B, and Pa+cpu reaches 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.