Skip to main content
issue 2026-08-06System Design45 minSC 2020interactive

ZeRO: Memory Optimizations Toward Training Trillion Parameter Models

This research paper explains how Zero Redundancy Optimizer partitions model states across data-parallel ranks in three cumulative stages while keeping communication close to ordinary data parallelism.

ZeRO shards optimizer states, gradients, and parameters across data-parallel ranksA baseline data-parallel tower on the left keeps a full replicated model-state stack. Four ranks on the right each own one shard of optimizer states, gradients, and parameters. Tokens circulate on an all-gather ring when a layer needs the full parameter set, then remote shards leave again.DPREPLICATE ALLOSFULLGFULLPFULLEVERY RANKZeRO-DPENTER GATHER · RUN LAYER · LEAVE REMOTE SHARDSR0OS₀G₀P₀R1OS₁G₁P₁R2OS₂G₂P₂R3OS₃G₃P₃ALL-GATHER P WHEN LAYER RUNSOWN SHARDOWN SHARDPARTITION OS · G · P — MEMORY FALLS WITH NdPos ≈4× · Pos+Pg ≈8× · Pos+Pg+Pp LINEAR IN NdZeRO stages shrink per-GPU model-state memoryFour cards show data-parallel replication, then ZeRO optimizer-state partitioning, gradient partitioning, and parameter partitioning with increasing memory reduction.SHARD · DO NOT REPLICATEDP · FULL OS + G + Psame stack on every rankPos · SHARD OPTIMIZER~4× model-state cut at large Nd+ Pg · SHARD GRADIENTS~8× cut · reduce-scatter owners+ Pp · SHARD PARAMETERSlinear in Nd · gather on demandOWN SHARD · GATHER · RUN · RELEASE

Large language models hit a wall that looks like “not enough GPUs,” but is often “each GPU still keeps a full copy of the training state.” Classic data parallelism (DP) is easy and efficient — until Adam’s momentum, variance, master weights, gradients, and parameters all replicate on every rank. Then a 1.5B GPT-2-style model that needs only about 3GB for fp16 weights still refuses to train on a 32GB GPU once optimizer states join the party.

ZeRO (Zero Redundancy Optimizer) keeps DP’s compute grain and communication pattern, but partitions model states across ranks instead of replicating them. Three cumulative stages — optimizer states (PosP_{\mathrm{os}}), gradients (PgP_{\mathrm{g}}), then parameters (PpP_{\mathrm{p}}) — turn cluster memory into one shared pool. The paper’s analysis says a trillion-parameter Adam mixed-precision model (~16TB of model states) fits in principle on 1024 GPUs at ~16GB per device.

What this paper explains

Training memory splits into two buckets:

  1. Model states — parameters, gradients, and optimizer states (for Adam: momentum + variance, plus an fp32 master copy under mixed precision).
  2. Residual states — activations, temporary buffers, and allocator fragmentation.

ZeRO attacks both:

  • ZeRO-DP removes DP redundancy with staged partitions PosP_{\mathrm{os}}, PgP_{\mathrm{g}}, PpP_{\mathrm{p}}.
  • ZeRO-R shrinks residual pressure (activation partition/offload, sized buffers, defragmentation).

The evaluated system in the paper, ZeRO-100B, ships Pos+PgP_{\mathrm{os}}+P_{\mathrm{g}} plus ZeRO-R (parameter partitioning PpP_{\mathrm{p}} was planned as the path to full trillion-scale support).

ZeRO-DP stage spectrum of model-state memoryFour points from full data-parallel replication through optimizer, gradient, and parameter partitioning, with increasing memory reduction.DPPosPos+Pg+Pp16Ψ bytes~4× cut~8× cutlinear in Ndcumulative ZeRO-DP stages (paper Figure 1)
Optimizer-state partitioning alone removes most of the Adam footprint. Adding gradient partitioning reaches ~8×. Parameter partitioning makes per-device model-state memory scale down with the data-parallel degree.

Prior limits

  • DP keeps high compute granularity and modest communication, but replicates every model state → OOM above ~1.4B parameters on 32GB GPUs in their baseline stack.
  • Model parallelism (MP) shards layers and saves memory, but communication between layers hurts once you leave a high-bandwidth node (they report ~5 TFLOPS/V100 on a 40B Megatron run across two DGX-2 nodes).
  • Pipeline parallelism can partition parameters/activations but brings micro-batch, tied-weight, and batch-norm friction; large micro-batch counts to hide bubbles also grow activation memory.
  • CPU offload of full model states can burn large fractions of step time on PCIe copies.

The core tension: DP is usable and fast but memory-wasteful; MP/PP are memory-aware but harder and often less efficient across nodes.

The mechanism

Where the bytes go (mixed-precision Adam)

For Ψ\Psi parameters, mixed-precision Adam needs roughly:

TensorPrecisionBytes
Parameters (compute copy)fp162Ψ2\Psi
Gradientsfp162Ψ2\Psi
Master parametersfp324Ψ4\Psi
Momentumfp324Ψ4\Psi
Variancefp324Ψ4\Psi

Optimizer-state multiplier K=12K = 12, so total model-state memory is 2Ψ+2Ψ+KΨ=16Ψ2\Psi + 2\Psi + K\Psi = 16\Psi bytes. GPT-2 1.5B → about 24GB of model states, not 3GB of fp16 weights.

Interactive

Per-device model-state memory

Fixed 7.5B parameters, mixed-precision Adam (paper Table 1). Slide data-parallel degree Nd and ZeRO stage to watch the stack shrink.

Also shard gradients (ZeRO-100B core). Numbers match the paper's 7.5B Table 1 column.

ZeRO-DP stages (cumulative)

PosP_{\mathrm{os}} — Optimizer state partitioning. Split momentum/variance/(fp32 masters) into NdN_d shards. Rank ii updates only shard ii, then all-gather refreshed parameters. Large NdN_d: model-state memory 4Ψ\approx 4\Psi → about reduction vs full DP.

Pos+PgP_{\mathrm{os}}+P_{\mathrm{g}} — Add gradient partitioning. Each rank only keeps reduced gradients for its parameter shard (bucketized reduce-scatter during backward). Large NdN_d: footprint 2Ψ\approx 2\Psi → about reduction.

Pos+Pg+PpP_{\mathrm{os}}+P_{\mathrm{g}}+P_{\mathrm{p}} — Add parameter partitioning. Each rank stores only its parameter shard and broadcast/all-gathers remote shards just-in-time for the active layer. Memory falls linearly with NdN_d (e.g. 64× at Nd=64N_d=64) with about 1.5× communication volume vs baseline DP (~50% increase).

ZeRO communication schedule across ranksFour ranks each own a parameter shard. Forward gathers shards for the active layer. Backward reduce-scatters gradients to owner ranks for the optimizer step.Rank 0owns shard 0OS / G / PRank 1owns shard 1OS / G / PRank 2owns shard 2OS / G / PRank 3owns shard 3OS / G / Pforward: gather Pbackward: reduce-scatter G
Under parameter partitioning, ranks keep only their shard resident. A dynamic schedule gathers parameters for the live layer and reduce-scatters gradients to the owners that will run the optimizer update — keeping communication volume near ordinary data parallelism.

ZeRO-R (residual path)

After model states shrink, activations/buffers/fragments dominate:

  • Partition activation checkpoints across MP ranks (remove accidental replication) and optionally offload checkpoints when arithmetic intensity hides PCIe.
  • Keep temporary fused buffers constant-sized so they do not grow with Ψ\Psi.
  • Defragment by parking long-lived checkpoints/gradients into preallocated contiguous arenas.

Algorithm walkthrough

One training step under full ZeRO-DP intuition:

  1. Forward: For each layer, gather the parameter shard(s) you need; compute; release remote shards you no longer need.
  2. Backward: Produce gradients; reduce each gradient bucket only to the owner rank for that shard; free local gradient memory after reduction.
  3. Optimizer step: Owner ranks update their optimizer-state shards and corresponding parameter shards.
  4. Publish weights: All-gather (or equivalent) so the next step sees updated parameters — or, under PpP_{\mathrm{p}}, keep parameters sharded and gather again on demand.

ZeRO-100B in the paper implements Pos+PgP_{\mathrm{os}}+P_{\mathrm{g}} (+ ZeRO-R), still pairing with modest MP when activations demand it.

What to notice when reading

  • Figure 1’s three bars are the whole mental model: same Ψ\Psi, shrinking per-GPU model-state stack as stages unlock.
  • Table 1’s bold cells mark “fits on 32GB V100” combinations — including 1T parameters at Nd=1024N_d=1024 with Pos+g+pP_{\mathrm{os}+g+p} (~15.6GB).
  • Communication is not free under PpP_{\mathrm{p}}, but the paper argues volume stays near DP (1.5×), unlike naive MP across nodes.
  • ZeRO does not change Adam’s math — only where states live — so convergence behavior of the optimizer is preserved by design.

Results and evidence

Authors’ reported system results (ZeRO-100B = Pos+PgP_{\mathrm{os}}+P_{\mathrm{g}} + ZeRO-R), not timeless absolutes:

ClaimPaper figure
Model scaleEfficient 170B runs with MP; baseline Megatron-style stack struggles past ~40B across nodes (~ model size)
Throughput100B model on 400 V100s: >38 TFLOPS/GPU, aggregate >15 PFLOPS (~10× vs their SOTA for same size)
ScalingSuperlinear speedup 64→400 GPUs on a 60B model (larger DP → smaller shards → larger per-GPU batch)
UsabilityUp to 13B without MP/PP refactor (beyond T5-11B / Megatron-8.3B as cited); vanilla DDP OOM near 1.4B
DownstreamPowered Turing-NLG 17B (cited as then-largest LM with record accuracy)
AnalysisFull Pos+g+pP_{\mathrm{os}+g+p}1T params on 1024 GPUs at ~16GB/GPU model states

Table 1 memory examples (mixed-precision Adam, per device): a 7.5B model drops from 120GB (DP) to 31.4 / 16.6 / 1.88GB under PosP_{\mathrm{os}} / Pos+gP_{\mathrm{os}}+g / Pos+g+pP_{\mathrm{os}+g+p} at Nd=64N_d=64.

Limitations

  • Full trillion-parameter wall-clock training was still impractical on then-current flops even if memory fit; the evaluated path targets ~100B-class models.
  • PpP_{\mathrm{p}} (stage 3) was not in the ZeRO-100B evaluation slice at publication time — linear memory scaling to 1T is an analysis + roadmap claim in the paper.
  • Activation memory can still dominate; ZeRO often still pairs with MP or checkpointing for huge models.
  • Very large global batch from high DP can hurt convergence; MP remains a knob for batch-size control.
  • Results are on V100-era clusters and DeepSpeed’s implementation details; absolute TFLOPS will not transfer unchanged to newer GPUs.

How to read the paper

  1. Abstract + §1 — problem framing and the three-stage punchline.
  2. §3 — the 16Ψ mixed-precision Adam accounting (why 1.5B needs ~24GB).
  3. §5 — deep dive on PosP_{\mathrm{os}}, PgP_{\mathrm{g}}, PpP_{\mathrm{p}} + Table 1.
  4. §4 / ZeRO-R sections — activations, buffers, fragmentation.
  5. §7 — dynamic communication schedule (why volume stays near DP).
  6. Evaluation figures 2–3 — 100B/170B throughput and superlinear scaling.
  7. Related-work contrasts with MP/PP/offload — what ZeRO refuses to trade away.

Knowledge check

In mixed-precision Adam, why is model-state memory about 16Ψ bytes rather than 2Ψ for fp16 weights?

What do ZeRO-DP stages P_os, P_g, and P_p partition?

Why can increasing DP degree yield superlinear speedup under ZeRO?

Keep reading

  1. Original paper (arXiv:1910.02054) — Figure 1, Table 1, Figures 2–3.
  2. Megatron-LM tensor model parallelism — arXiv:1909.08053.
  3. Adam optimizer — arXiv:1412.6980.
  4. Related Fanout Daily: Switch Transformers, Chinchilla, Scaling Laws, PagedAttention (inference-side memory).

Sources

Practice this paper

All challenges