ZeRO (Zero Redundancy Optimizer) is a memory optimization paradigm for distributed data parallel training that partitions the optimizer states, gradients, and model parameters across all participating GPUs instead of replicating them, thereby eliminating memory redundancy and enabling the training of models far larger than the memory of any single device. It achieves this through three progressive stages—ZeRO-1, ZeRO-2, and ZeRO-3—each offering greater memory savings at the cost of increased communication overhead, fundamentally changing the scalability limits of large language model (LLM) training.
Glossary
ZeRO (Zero Redundancy Optimizer)

What is ZeRO (Zero Redundancy Optimizer)?
ZeRO is a groundbreaking memory optimization technique for distributed training that partitions model states across GPUs to eliminate redundancy and enable the training of models with trillions of parameters.
The technique is foundational to frameworks like Microsoft's DeepSpeed, where it is combined with other optimizations like model parallelism and offloading. By dynamically gathering partitioned parameters only when needed for computation, ZeRO maintains the computational efficiency of data parallelism while overcoming its primary memory bottleneck, making it a critical tool for engineering teams tasked with LLM deployment and serving who must manage the extreme resource demands of foundation models.
Key Features and Benefits of ZeRO
ZeRO (Zero Redundancy Optimizer) is a family of memory optimization stages for distributed training that partitions model states across data parallel processes to eliminate memory redundancy, enabling the training of models with trillions of parameters.
ZeRO Stage 1: Optimizer State Partitioning
ZeRO Stage 1 partitions only the optimizer states (e.g., momentum, variance for Adam) across the data parallel processes. Each GPU stores and updates only its assigned partition of the optimizer states, reducing the memory footprint of the optimizer by a factor of the data parallel degree (N). This is the most basic form of ZeRO, offering significant memory savings with minimal communication overhead.
- Example: With 8 GPUs (N=8), the memory for Adam optimizer states is reduced by 8x.
- Benefit: Enables training of models 8x larger with the same GPU memory, or allows the use of larger batch sizes.
ZeRO Stage 2: Gradient Partitioning
ZeRO Stage 2 builds on Stage 1 by also partitioning the gradients across processes. After the backward pass, each GPU only retains the gradients corresponding to its partition of the parameters. A global all-gather operation is required to collect the full gradients before the optimizer step, but they are immediately discarded after use.
- Mechanism: Eliminates the memory redundancy of storing a full copy of gradients on every GPU.
- Benefit: Further increases model size capacity. Combined with Stage 1, memory reduction scales with N for both optimizer states and gradients.
ZeRO Stage 3: Parameter Partitioning
ZeRO Stage 3 is the most memory-efficient stage, partitioning the model parameters themselves across GPUs. Each GPU stores only a fraction of the parameters. During the forward and backward passes, parameters are gathered on-demand for each layer via communication collectives and then released, a process known as the ZeRO-3 forward/backward pass.
- Key Concept: Parameter offloading can be combined with Stage 3, where inactive parameter partitions are moved to CPU RAM, enabling training of models larger than the aggregate GPU memory.
- Trade-off: Maximizes model size capability but introduces the highest communication overhead, requiring careful tuning for performance.
Communication Patterns and Overhead
ZeRO's memory savings come with increased inter-GPU communication, which is managed through optimized collective operations.
- All-Gather: Used in Stage 3 to collect parameters for a layer and in Stage 2 to collect gradients. This is a bandwidth-intensive operation.
- Reduce-Scatter: Used to sum and partition gradients across GPUs during the backward pass.
- Overhead Management: The communication overhead is often hidden by overlapping it with computation. Frameworks like DeepSpeed implement sophisticated communication scheduling to minimize the performance impact.
Integration with Model Parallelism
ZeRO is fundamentally a data parallelism technique. It is most powerful when combined with other forms of parallelism to train extremely large models.
- ZeRO + Tensor/Pipeline Parallelism: A common 3D parallelism strategy. ZeRO handles data parallelism across model replicas, while tensor and pipeline parallelism split the model itself across GPUs. This combination allows scaling to thousands of GPUs.
- Role in Training: ZeRO efficiently manages the memory footprint of the data parallel dimension, while model parallelism techniques manage the memory and compute of the model's layers.
ZeRO vs. Other Parallelism Techniques
A technical comparison of ZeRO's memory optimization approach against core distributed training parallelism strategies.
| Feature / Dimension | ZeRO (Zero Redundancy Optimizer) | Data Parallelism (DP) | Model Parallelism (Tensor/Pipeline) |
|---|---|---|---|
Core Optimization Goal | Eliminate memory redundancy for optimizer states, gradients, and parameters | Scale batch size and accelerate training via replicated workers | Fit a model larger than a single GPU's memory by partitioning it |
Memory Footprint per GPU | Dramatically reduced; scales inversely with number of GPUs | Full model replica + optimizer states + gradients (high redundancy) | Only a partition of the model; scales with partition size |
Communication Volume | Moderate; collective operations for gradients and parameters | High; all-reduce of gradients after each backward pass | Very high; frequent exchange of activations/gradients between layers (tensor) or pipeline bubbles (pipeline) |
Communication-Computation Overlap | Yes, via ZeRO-Offload and ZeRO-Infinity | Limited; synchronization is a blocking operation | Challenging; often a sequential dependency, especially in pipeline parallelism |
Ease of Implementation | Integrated into DeepSpeed; requires framework support | Simple; native in most frameworks (e.g., PyTorch DDP) | Complex; requires manual model partitioning or specialized frameworks |
Model Size Scalability | Extremely high; enables training of trillion-parameter models | Limited by single-GPU memory for the full model replica | High; limited by aggregate GPU memory across the partition |
Compute Utilization | High; maintains data parallel efficiency while reducing memory | High, but limited by gradient synchronization overhead | Often lower due to communication overhead and idle GPU time (bubbles) |
Typical Use Case | Training extremely large models where memory is the primary constraint | Training models that fit on a single GPU, needing faster iteration | Training models whose individual layers are too large for one GPU |
Implementations and Frameworks
ZeRO is a family of memory optimization techniques for distributed training, primarily implemented within the DeepSpeed library. These stages partition model states across data parallel processes to eliminate memory redundancy.
ZeRO Stages: 1, 2, and 3
The core ZeRO technique is implemented in three progressive stages, each partitioning more model state to save more memory:
- ZeRO Stage 1 (Optimizer State Partitioning): Partitions the optimizer states (e.g., momentum, variance for Adam) across processes. Reduces memory by ~4x.
- ZeRO Stage 2 (Gradient Partitioning): Adds partitioning of gradients after the backward pass. Reduces memory by ~8x.
- ZeRO Stage 3 (Parameter Partitioning): Partitions the model parameters across processes, fetching them via all-gather only when needed for computation. Enables training of models with trillions of parameters.
ZeRO-Offload & ZeRO-Infinity
These extensions push memory savings beyond GPU RAM limits by leveraging CPU and storage.
- ZeRO-Offload: Efficiently offloads optimizer states and gradients to CPU memory while keeping parameters on GPU. Enables training models 10x larger on a single GPU.
- ZeRO-Infinity: The most advanced stage, offloading all ZeRO components—optimizer states, gradients, parameters—to both CPU and NVMe solid-state storage. This allows for training models with tens of trillions of parameters by leveraging terabytes of CPU/NVMe memory.
Integration with Hugging Face
ZeRO is accessible to a broad audience through tight integration with the Hugging Face Transformers and Accelerate libraries.
- The
Trainerclass in Transformers natively supports DeepSpeed via a JSON configuration file. - Hugging Face Accelerate provides a unified interface for distributed training, supporting ZeRO configurations through its
DeepSpeedPlugin. - This integration allows users to apply ZeRO optimizations with minimal code changes to existing training scripts.
PyTorch Fully Sharded Data Parallel (FSDP)
FSDP is PyTorch's native implementation of the ZeRO-3 concept, integrated into the torch.distributed module. It shards model parameters, gradients, and optimizer states across data-parallel processes.
Key comparisons with DeepSpeed ZeRO-3:
- Tighter PyTorch Integration: Uses PyTorch's native communication primitives.
- Flexible Sharding: Can shard parameters at the layer level for more efficient communication.
- Simplified Configuration: Managed via wrapping model layers with
FullyShardedDataParallel. Often preferred for new PyTorch-centric projects.
Frequently Asked Questions
ZeRO (Zero Redundancy Optimizer) is a foundational memory optimization technique for distributed training of large language models. This FAQ addresses its core mechanisms, implementation, and role in modern LLMOps.
ZeRO (Zero Redundancy Optimizer) is a memory optimization paradigm for distributed data parallel training that partitions the three primary memory-consuming states—optimizer states, gradients, and model parameters—across data parallel processes to eliminate memory redundancy.
It works through progressive stages of optimization:
- ZeRO Stage 1 (Optimizer State Partitioning): The optimizer states (e.g., momentum, variance for Adam) are partitioned across processes. Each process only updates the parameters for its assigned partition, reducing memory footprint proportional to the data parallel degree.
- ZeRO Stage 2 (Gradient Partitioning): In addition to optimizer states, gradients are also partitioned. During the backward pass, each process only stores the gradients corresponding to its parameter partition, with a collective communication operation (
all-gather) to make full gradients available when needed. - ZeRO Stage 3 (Parameter Partitioning): The model parameters themselves are partitioned across processes. Parameters are only gathered on-demand for the forward and backward passes of a given layer, then immediately released. This enables training models far larger than the memory of any single GPU.
The technique is implemented within frameworks like DeepSpeed, allowing it to be integrated with other parallelism strategies such as tensor parallelism and pipeline parallelism.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
ZeRO is a cornerstone of modern large-scale model training. These related concepts are essential for understanding the broader ecosystem of distributed optimization and model parallelism.
Model Parallelism
A family of techniques for splitting a neural network across multiple devices (GPUs) when it is too large to fit on a single device. It is the foundational concept upon which ZeRO builds. There are two primary strategies:
- Tensor Parallelism: Splits individual layers (e.g., the weights of a linear layer) across devices, requiring frequent communication (all-reduce) during each forward/backward pass.
- Pipeline Parallelism: Places different groups of layers (stages) on different devices, passing activations sequentially like an assembly line, often using micro-batching to keep all devices busy. ZeRO is often categorized as a form of optimized data parallelism that incorporates model parallelism ideas for optimizer states, gradients, and parameters.
Data Parallelism
The standard distributed training approach where the entire model is replicated on each GPU. A large batch of training data is split into smaller mini-batches, each processed independently on a different GPU. Gradients are then synchronized across all GPUs by averaging them (using an all-reduce operation) before the optimizer step updates the weights. While simple, its major limitation is memory redundancy—each GPU holds a full copy of the model, optimizer states, gradients, and activations. ZeRO directly addresses this redundancy by partitioning these components across the data parallel processes.
Gradient Checkpointing
A memory optimization technique that trades compute for memory. During the forward pass, only a subset of layer activations are stored (the 'checkpoints'). During the backward pass, the missing activations are recomputed on-the-fly from the nearest checkpoint. This can reduce activation memory by up to 5-10x but increases computation time by ~20-30%. It is complementary to ZeRO; they are often used together. While ZeRO optimizes memory for parameters, gradients, and optimizer states, gradient checkpointing targets the memory consumed by activations, enabling the training of models with even deeper architectures.
Mixed Precision Training
The use of lower-precision numerical formats (like FP16 or BF16) for parts of the training process to speed up computation and reduce memory usage. A typical scheme uses FP16 for forward/backward passes and FP32 for the master weight copy and optimizer states to maintain stability. ZeRO's memory savings are particularly impactful here, as the optimizer states (e.g., momentum, variance in Adam) are often kept in FP32, becoming a major memory bottleneck. ZeRO-Offload, a stage of ZeRO, can move these FP32 optimizer states to CPU memory, further leveraging mixed precision's characteristics.
Fully Sharded Data Parallel (FSDP)
PyTorch's native implementation of the ZeRO-3 algorithm, introduced in PyTorch 1.11. It shards model parameters, gradients, and optimizer states across data parallel workers. Key features include:
- Automatic wrapping: Simplifies integration by allowing users to specify which sub-modules to shard.
- Flexible precision policies: Native support for mixed precision training.
- Integration with PyTorch ecosystem: Works seamlessly with
torch.compile, DistributedDataParallel (DDP) APIs, and other PyTorch components. FSDP has become the standard method for training large models within the PyTorch framework, providing a user-friendly API for ZeRO's capabilities.

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us