The Zero Redundancy Optimizer (ZeRO) is a memory optimization paradigm for data-parallel training that partitions the optimizer states, gradients, and model parameters across all devices in a distributed system to eliminate memory redundancy. Developed by Microsoft, it enables the training of models whose size far exceeds the memory capacity of any single accelerator, such as a GPU or NPU, by ensuring each device stores only a unique shard of the model's total memory footprint.
Glossary
Zero Redundancy Optimizer (ZeRO)

What is Zero Redundancy Optimizer (ZeRO)?
A memory optimization technique for distributed training that partitions model states across devices to eliminate redundancy.
ZeRO operates through three progressive stages: ZeRO-1 partitions only the optimizer states, ZeRO-2 adds gradient partitioning, and ZeRO-3 partitions all model parameters. This approach transforms the classic data-parallel strategy, where each device holds a full model replica, into a hybrid data-and-model-parallel system. It requires communication to gather parameters or gradients as needed during the forward and backward passes, trading increased network traffic for dramatically reduced per-device memory consumption, which is critical for training large language models and vision transformers.
Key Features of ZeRO
The Zero Redundancy Optimizer (ZeRO) is a suite of memory optimization stages for data-parallel training. It systematically partitions optimizer states, gradients, and model parameters across devices to eliminate memory redundancy, enabling the training of models far larger than a single device's memory capacity.
ZeRO Stage 1: Optimizer State Partitioning (P_os)
This is the foundational stage of ZeRO. It partitions the optimizer states (e.g., momentum, variance for Adam) across all data-parallel processes. Each GPU stores and updates only its assigned portion of the optimizer states, reducing memory usage proportional to the data-parallel degree.
- Memory Reduction: The memory footprint for optimizer states is divided by the number of GPUs (D_pp).
- Communication Overhead: Minimal. Only requires a single all-gather operation when the full optimizer state is needed for a parameter update, which is infrequent.
- Impact: Enables training models with ~3x larger batch sizes or model sizes compared to standard data parallelism.
ZeRO Stage 2: Gradient Partitioning (P_os+g)
Builds on Stage 1 by also partitioning the gradients across devices. After the backward pass, each GPU only retains the gradients corresponding to its assigned portion of the parameters. A reduction operation is performed to aggregate gradients across devices only for the locally owned slices.
- Memory Reduction: Eliminates the memory redundancy for gradients, in addition to optimizer states.
- Communication Pattern: Uses a reduce-scatter operation during gradient synchronization instead of an all-reduce. This is more communication-efficient for this purpose.
- Impact: Enables training models roughly 8x larger than possible with standard data parallelism, as both major training memory components (optimizer states and gradients) are partitioned.
ZeRO Stage 3: Parameter Partitioning (P_os+g+p)
The most memory-aggressive stage. It partitions the model parameters themselves across GPUs. Each GPU stores only the slice of parameters it is responsible for. Parameters are gathered on-demand from all devices just before computation in the forward or backward pass and are discarded immediately after.
- Memory Reduction: The model's parameter memory is divided by the number of GPUs. This enables training models with trillions of parameters.
- Communication Overhead: Significant. Requires all-gather operations before every layer's computation in both forward and backward passes, and reduce-scatter after backward passes. This trades increased communication for massive memory savings.
- Use Case: Essential for training the largest foundational models (e.g., models with hundreds of billions to trillions of parameters).
Communication Patterns & Overlap
ZeRO's performance depends critically on optimizing communication. It replaces standard all-reduce with more efficient collective operations and overlaps them with computation.
- Reduce-Scatter: Used in Stage 2/3 for gradient synchronization. Each GPU ends up with a unique slice of the summed gradients.
- All-Gather: Used in Stage 3 to collect parameters from all GPUs before computation.
- Overlap Strategy: Modern implementations (e.g., in DeepSpeed) carefully schedule these communications to overlap with independent computation (e.g., the forward pass of one layer with the all-gather for the next layer), hiding much of the communication latency.
Integration with Model & Pipeline Parallelism
ZeRO is primarily a data parallelism optimizer. For maximum scalability, it is combined with other forms of parallelism in 3D Parallelism.
- ZeRO + Model Parallelism (Tensor Parallelism): ZeRO partitions data-parallel groups, while tensor parallelism splits individual layers (e.g., attention heads, MLP blocks) across devices within a group. This combination reduces memory per device and communication volume for very large layers.
- ZeRO + Pipeline Parallelism: Pipeline parallelism splits the model vertically by layers. ZeRO can be applied within each pipeline stage to further reduce memory usage for the layers resident on that stage's devices.
- Orchestration: Frameworks like DeepSpeed and PyTorch Fully Sharded Data Parallel (FSDP) manage this complex orchestration, allowing the training of the world's largest AI models.
How ZeRO Works: The Three Stages
The Zero Redundancy Optimizer (ZeRO) eliminates memory waste in distributed training by partitioning model states across devices. It operates through three progressive stages, each offering greater memory savings at the cost of increased communication.
ZeRO Stage 1 (Optimizer State Partitioning) partitions only the optimizer states (e.g., momentum, variance) across data-parallel processes. Each GPU stores and updates only its assigned partition, reducing memory footprint proportional to the data-parallel degree. This stage requires a single all-gather communication during the optimizer step to collect the full state for updating each GPU's local model parameters.
ZeRO Stage 2 (Gradient Partitioning) extends partitioning to the gradients, in addition to the optimizer states. Gradients are reduced across devices in a partitioned manner, where each GPU only stores and aggregates the slice of gradients corresponding to its optimizer state partition. This requires an all-gather for gradients before the weight update and eliminates gradient memory redundancy, enabling the training of larger models or the use of larger batches.
ZeRO vs. Other Parallelism Strategies
This table compares the core memory optimization and communication characteristics of the Zero Redundancy Optimizer (ZeRO) against other fundamental distributed training strategies.
| Feature / Metric | ZeRO (Zero Redundancy Optimizer) | Data Parallelism (DP) | Model Parallelism (MP) | Pipeline Parallelism (PP) |
|---|---|---|---|---|
Primary Optimization Goal | Eliminate memory redundancy of states/parameters | Increase batch size and throughput | Fit a single layer on a device | Overlap computation across layers |
Memory Reduction per Device | Up to 8x (ZeRO-3) vs. DP | None (full model replica) | Proportional to layer split | Proportional to stage split |
Communication Volume | High (gradients, parameters) | High (gradients only) | Very High (activations, gradients) | Moderate (activations between stages) |
Communication Synchronization | All-reduce per optimizer step | All-reduce per backward pass | Point-to-point between layers | Point-to-point between pipeline stages |
Ideal Model Size | Extremely Large (>> single GPU memory) | Fits in single GPU memory | Single layer > GPU memory | Model depth >> GPU count |
Implementation Complexity | High (requires framework integration) | Low (standard in frameworks) | Very High (manual layer splitting) | High (requires careful bubble management) |
Supports Layer Dropout/BatchNorm | ||||
Requires Model Code Modification |
Frameworks & Implementations
The Zero Redundancy Optimizer (ZeRO) is a foundational memory optimization technique for distributed deep learning training. It systematically partitions model states across devices to eliminate memory redundancies, enabling the training of models with trillions of parameters.
Core Optimization Stages
ZeRO operates through three progressive stages of memory partitioning, each eliminating a different type of redundancy:
- ZeRO Stage 1 (P_os): Partitions optimizer states (e.g., momentum, variance) across data-parallel processes. Reduces memory by ~4x.
- ZeRO Stage 2 (P_os+g): Adds partitioning of gradients. Each process only stores gradients for its assigned parameters, reducing memory by ~8x.
- ZeRO Stage 3 (P_os+g+p): Partitions the model parameters themselves. Parameters are gathered on-demand for the forward/backward pass and discarded afterward, enabling near-linear memory scaling with the number of GPUs.
ZeRO vs. Classic Data Parallelism
ZeRO enhances, rather than replaces, standard Data Parallel (DP) training.
- Classic DP: Replicates the entire model, optimizer states, and gradients on every GPU. Communication is a single all-reduce of gradients. Memory usage is identical on all devices.
- ZeRO-powered DP: Maintains the data parallelism paradigm but partitions the model states. It uses a reduce-scatter operation to distribute gradient aggregation and an all-gather to collect parameters, trading increased communication for massive memory savings. The computational workload per device remains the same.
Communication Overhead & Optimizations
ZeRO Stage 3 introduces significant communication for gathering parameters. Key optimizations mitigate this cost:
- Overlapping Communication and Computation: Parameters for the next layer are gathered while the current layer computes.
- Parameter Persistence: Keeping a small subset of critical parameters (e.g., embedding layers) resident on each GPU.
- Hierarchical Partitioning: In multi-node setups, parameters are partitioned first across nodes, then within nodes, to optimize for slower inter-node links. The communication volume is approximately 1.5x that of classic DP, but the enabling of larger batch sizes often results in better aggregate throughput.
Related Concept: Mixture of Experts (MoE) with ZeRO
ZeRO is particularly effective for training Mixture of Experts (MoE) models like Google's Switch Transformers.
- In MoE models, only a subset of 'expert' layers are activated per token, creating a naturally sparse, massive model.
- Applying ZeRO Stage 1 to the shared optimizer states and ZeRO Stage 2 to the sparse gradients is highly efficient.
- The combination allows for models with over a trillion parameters while keeping the computational cost per token similar to a dense model 1/10th the size.
Integration with Other Parallelism Strategies
ZeRO is often combined with other forms of parallelism for training extreme-scale models:
- ZeRO + Tensor Parallelism: ZeRO handles data parallelism across nodes, while tensor parallelism splits individual layers (e.g., attention heads, MLP blocks) across GPUs within a node. This is used in Megatron-DeepSpeed.
- ZeRO + Pipeline Parallelism: ZeRO optimizes memory within a pipeline stage, while pipeline parallelism splits the model layers sequentially across devices. This hybrid approach is standard for models exceeding hundreds of billions of parameters.
- The choice of hybrid strategy depends on the cluster topology, model architecture, and communication bandwidth.
Frequently Asked Questions
The Zero Redundancy Optimizer (ZeRO) is a foundational memory optimization technique for training massive neural networks across multiple devices. It systematically partitions optimizer states, gradients, and model parameters to eliminate memory redundancy, enabling the training of models far larger than the memory of any single accelerator.
The Zero Redundancy Optimizer (ZeRO) is a memory optimization technique for data-parallel training that partitions optimizer states, gradients, and model parameters across devices to eliminate memory redundancy. It works through three progressive stages (ZeRO-1, ZeRO-2, ZeRO-3) that incrementally offload different components of the training state. In ZeRO-1, the optimizer states (e.g., momentum, variance) are partitioned, with each device storing and updating only its assigned slice, requiring an all-gather communication during the optimizer step. ZeRO-2 adds the partitioning of gradients, further reducing memory by ensuring each device only holds the gradients corresponding to its slice of the parameters. ZeRO-3, the most aggressive stage, partitions the model parameters themselves. Each device stores only the parameters for which it is responsible, requiring all-gather communication before the forward and backward passes to materialize the full layers temporarily.
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 memory optimization for large-scale training. These related techniques and concepts are essential for engineers building efficient, hardware-aware distributed systems.
Model Parallelism
A distributed training strategy where the parameters and computational graph of a single neural network are partitioned across multiple devices. Unlike data parallelism, where each device holds a full model copy, model parallelism splits the model itself.
- Tensor Parallelism: A specific form where individual tensor operations (e.g., matrix multiplications within a linear layer) are split across devices.
- Pipeline Parallelism: Partitions the model by layers into stages, forming a processing pipeline where micro-batches flow sequentially.
- ZeRO Integration: ZeRO's stages 2 and 3 can be viewed as a form of model parallelism for optimizer states, gradients, and parameters, often combined with data parallelism in frameworks like DeepSpeed.
Gradient Checkpointing
A memory optimization technique that trades compute for memory by selectively storing only a subset of layer activations during the forward pass. Non-checkpointed activations are recomputed during the backward pass as needed.
- Core Trade-off: Can reduce activation memory by up to 80-90% at the cost of approximately 30% more compute time.
- Synergy with ZeRO: Often used in conjunction with ZeRO. While ZeRO partitions optimizer components, checkpointing reduces the memory footprint of activations, together enabling the training of models with trillions of parameters.
- Implementation: Available in major frameworks (e.g.,
torch.utils.checkpoint). Critical for training very deep networks like those in large language models.
Pipeline Parallelism
A model parallelism strategy that partitions a network's layers across multiple devices. The model is divided into sequential stages, each placed on a different device. Micro-batches of data are pumped through this pipeline to keep all devices utilized.
- Bubble Overhead: A key challenge is the 'pipeline bubble'—idle time at the start and end of a batch as the pipeline fills and drains. Techniques like 1F1B (One Forward pass followed by One Backward pass) scheduling minimize this.
- Communication Pattern: Requires point-to-point communication of activations and gradients between adjacent stages in the pipeline.
- DeepSpeed & PyTorch FSDP: Modern implementations (e.g., DeepSpeed's pipeline, FairScale's Pipe) combine pipeline parallelism with ZeRO data parallelism for extreme model scale.
All-Reduce Communication
A collective communication operation fundamental to data-parallel training. It sums a target array (like gradients) across all processes in a group and distributes the result back to all processes.
- ZeRO's Impact: Standard data parallelism requires a costly all-reduce on gradients after every backward pass. ZeRO stages 1 and 2 optimize this:
- ZeRO-1: Uses reduce-scatter for gradients (more efficient than all-reduce).
- ZeRO-2: Also partitions gradients, further reducing communication volume.
- Bandwidth Cost: All-reduce communication is often the performance bottleneck for data parallelism at scale. ZeRO's optimizations directly address this by reducing the size of the communicated data.

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