Skip to content

Zero Redundancy Optimiser

ZeRO shards optimiser states, gradients and parameters across data-parallel devices. Compare its three stages and distinguish ideal state savings from peak GPU memory.

The Zero Redundancy Optimiser (ZeRO) is a family of distributed-training memory techniques that partitions model state across data-parallel processes instead of storing every copy on every device. For a quant training a large forecasting or language model, it can make the training state fit within the available GPU memory. It changes state placement rather than replacing the underlying optimiser's update rule.

Three stages of removing duplication

Ordinary replicated data parallelism gives each process different training examples but a full copy of the model state. ZeRO progressively shares responsibility for storing and updating that state:

StagePartitioned across processesStill replicated in the ideal model-state accounting
1Optimiser stateModel weights and gradients
2Optimiser state and reduced gradientsModel weights
3Optimiser state, reduced gradients and model weightsNone of these three state groups
The stages are cumulative. Here, optimiser state includes a high-precision master weight copy when the precision recipe uses one, as well as the optimiser's history arrays. Adam, for example, keeps first- and second-moment estimates.
A gradient partition is not just the gradient from its owner's local mini-batch. Contributions from the data-parallel processes must be reduced so that the owner can apply the intended update. At stage 3, missing weights are gathered when needed for forward and backward computation, then can be released. Sharded ownership therefore does not mean a process computes forever using only its stored weights. The official DeepSpeed tutorial describes the cumulative stages; the original paper's Sections 5.1–5.3 explain their communication.

A twelve-parameter memory ledger

Use the paper's specific FP16/FP32 mixed-precision training convention. Each scalar parameter requires:
  • 2 bytes for its FP16 model weight;
  • 2 bytes for its FP16 gradient;
  • 12 bytes for three FP32 values: a master weight, first moment and second moment.
The last group is counted as optimiser state. It is not 12 bytes for the two moments alone. Section 3.1 of the paper gives this convention; other precision and optimiser choices have different byte budgets.
Let PP be the number of scalar parameters and DD the data-parallel degree. Assume equal partitions, all parameters trainable and no offloading. The ideal retained model-state bytes per device are
M0=16P,M1=4P+12PD,M2=2P+14PD,M3=16PD.\begin{aligned} M_0 &= 16P, \\ M_1 &= 4P+\frac{12P}{D}, \\ M_2 &= 2P+\frac{14P}{D}, \\ M_3 &= \frac{16P}{D}. \end{aligned}

For the fictional P=12P=12, D=3D=3 example, each sharded group assigns four parameters' worth of state to a device:

ArrangementWeightsGradientsMaster weights + momentsTotal per device
Replicated24 bytes24 bytes144 bytes192 bytes
ZeRO stage 124 bytes24 bytes48 bytes96 bytes
ZeRO stage 224 bytes8 bytes48 bytes80 bytes
ZeRO stage 38 bytes8 bytes48 bytes64 bytes
Ideal twelve-parameter example on three data-parallel devices: replicated storage is 192 bytes per device. ZeRO stages 1, 2 and 3 retain 96, 80 and 64 bytes respectively, split into weights, gradients and FP32 master weights plus two moments. Excludes peak-memory overheads.
Ideal twelve-parameter example on three data-parallel devices: replicated storage is 192 bytes per device. ZeRO stages 1, 2 and 3 retain 96, 80 and 64 bytes respectively, split into weights, gradients and FP32 master weights plus two moments. Excludes peak-memory overheads.
Original model-state accounting example, not a measured GPU benchmark. Stages progressively remove duplicated storage; transient working memory is excluded.

Stage 1 halves the retained state in this example; it does not divide the entire 192-byte total by three. Only stage 3 partitions all three groups. With one device, none of these partitions saves storage.

Why 64 bytes is not a peak-memory prediction

The ledger excludes activations, temporary parameter gathers, communication buffers, padding and allocator overhead. Those exclusions matter even when every permanent state group is sharded. In particular, DeepSpeed documents that each submodule's forward and backward work must fit in device memory; a full layer can still be too large. Its ZeRO documentation, checked on 1 November 2026, describes this constraint and tiling support.
Partitioning and offloading are separate choices. Sharding assigns state to different processes; offloading moves state to CPU or NVMe storage. The current documentation exposes offloading separately from the stage setting. Neither the ideal byte formula nor a higher stage establishes faster training: communication and the workload still matter.
For the underlying history arrays, the optimiser-choices lesson develops Adam's two accumulator recurrences. Its preview is public; the full lesson requires membership.

Sources

Last updated
  • deep learning
  • distributed training
  • memory
  • zero
  • deepspeed
← Back to the glossaryBack to top ↑