Inferensys

Glossary

ZeRO Optimization

A memory optimization technology that partitions model states, gradients, and optimizer states across data-parallel processes to eliminate memory redundancy.
Data scientist building training data pipeline on laptop, data preprocessing visible, technical workspace.
DISTRIBUTED TRAINING EFFICIENCY

What is ZeRO Optimization?

ZeRO (Zero Redundancy Optimizer) is a memory optimization technology that partitions model states, gradients, and optimizer states across data-parallel processes to eliminate memory redundancy, enabling the training of models with trillions of parameters.

ZeRO Optimization, introduced by Microsoft as part of the DeepSpeed library, fundamentally addresses the memory bottleneck in distributed training. Standard data parallelism replicates the entire model state—including optimizer states, gradients, and parameters—on every GPU, creating massive redundancy. ZeRO eliminates this by partitioning these states across the data-parallel dimension, allowing each device to store only a fraction of the total state, dramatically reducing per-GPU memory consumption.

ZeRO operates in three progressive stages. Stage 1 partitions only the optimizer states, reducing memory by a factor equal to the number of data-parallel processes. Stage 2 additionally partitions gradients, and Stage 3 partitions model parameters themselves, distributing the entire model state. This enables near-linear scaling of model size with the number of GPUs, making it possible to train models with hundreds of billions of parameters without model parallelism.

Memory Optimization

Core Characteristics of ZeRO

ZeRO (Zero Redundancy Optimizer) eliminates memory redundancy in data-parallel training by partitioning model states across GPUs, enabling the training of models with trillions of parameters.

01

Three-Stage Partitioning Strategy

ZeRO operates in three sequential optimization stages, each partitioning a different component of the model state to progressively reduce memory consumption:

  • Stage 1 (ZeRO-1): Partitions optimizer states across data-parallel processes, reducing memory by 4x.
  • Stage 2 (ZeRO-2): Additionally partitions gradients, reducing memory by 8x cumulatively.
  • Stage 3 (ZeRO-3): Partitions model parameters as well, achieving memory reduction linear with the number of GPUs (Nd x).

Each stage communicates only the necessary shards during forward and backward passes, maintaining computational efficiency while drastically lowering per-GPU memory requirements.

8x
Memory Reduction (Stage 2)
Nd x
Linear Scaling (Stage 3)
03

Communication Primitives and Efficiency

ZeRO leverages high-performance collective communication primitives to manage sharded states without becoming communication-bound:

  • All-Gather: Used to collect parameter shards before a forward or backward pass.
  • Reduce-Scatter: Used to aggregate and redistribute gradients efficiently after the backward pass.
  • Bandwidth Optimization: ZeRO dynamically selects between ring-based and tree-based algorithms depending on message size and topology.

By carefully orchestrating these primitives, ZeRO achieves near-linear scaling efficiency even as the number of GPUs increases, making it practical for clusters with thousands of accelerators.

04

ZeRO-Infinity for Trillion-Parameter Models

ZeRO-Infinity extends the core ZeRO paradigm to leverage heterogeneous memory hierarchies—combining GPU memory, CPU DRAM, and NVMe storage as a unified memory pool.

  • Bandwidth-Centric Partitioning: Data placement decisions are driven by the bandwidth characteristics of each memory tier.
  • Overlap Centric Design: Data movement between tiers is aggressively overlapped with computation to prevent stalls.
  • Memory-Centric Tiling: Large operators are tiled to process data in chunks that fit within the fastest available memory.

This architecture enabled the first training of models exceeding 1 trillion parameters on a single GPU cluster without requiring model parallelism code changes.

1T+
Parameters Enabled
05

Integration with DeepSpeed Runtime

ZeRO is implemented as a core component of the DeepSpeed optimization library, providing a drop-in replacement for standard PyTorch optimizers with minimal code changes.

  • Configuration-Driven: Users specify ZeRO stages and offloading targets via a JSON configuration file.
  • Automatic Tensor Partitioning: The runtime handles all sharding logic, communication scheduling, and memory management transparently.
  • Compatibility: Works alongside other DeepSpeed features like mixed-precision training (fp16/bf16) and gradient accumulation.

This tight integration allows engineers to scale from a single GPU to thousands without rewriting training logic, significantly reducing the engineering overhead of large model training.

ZERO REDUNDANCY OPTIMIZATION

Frequently Asked Questions

Explore the core mechanisms behind ZeRO, the memory optimization technology that makes training massive multi-billion parameter models feasible by eliminating data-parallel redundancy.

ZeRO (Zero Redundancy Optimizer) is a memory optimization technology that partitions model states—parameters, gradients, and optimizer states—across data-parallel processes to eliminate memory redundancy, enabling the training of models with trillions of parameters. Unlike classic data parallelism where each GPU holds a full replica of the model, ZeRO shards these states across devices. During the forward and backward passes, it uses all-gather communication collectives to reconstruct the required state partitions on the fly, then discards them. This trades a slight increase in communication overhead for a dramatic reduction in per-device memory consumption, allowing models that would otherwise exceed GPU memory to be trained efficiently.

MEMORY REDUNDANCY ELIMINATION

ZeRO Stages vs. Standard Data Parallelism

Comparison of memory consumption per GPU and communication overhead across ZeRO optimization stages versus standard data parallelism for training large models.

FeatureStandard DPZeRO Stage 1ZeRO Stage 2ZeRO Stage 3

Optimizer State Partitioning

Gradient Partitioning

Parameter Partitioning

Memory Reduction vs. Standard DP

1x (baseline)

4x

8x

Linear with N GPUs

Communication Volume Overhead

1x (baseline)

1x

1x

1.5x

Full Model Replication per GPU

Offload to CPU/NVMe Supported

Max Model Size (Adam, 32GB GPU)

~1.4B params

~6B params

~12B params

~100B+ params

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.