ZeRO Optimization
What Is ZeRO Optimization?
ZeRO optimization, short for Zero Redundancy Optimizer, reduces GPU memory use by dividing training data across devices instead of storing duplicate copies on every GPU. It lets teams train or fine-tune larger neural networks than ordinary data parallelism can fit in one GPU's memory.
ZeRO does not replace an optimizer such as Adam. Adam determines how model weights change, while ZeRO changes where training information is stored and coordinated across GPUs. It is best known through the open-source DeepSpeed ZeRO documentation.
How ZeRO Works in Distributed Model Training
Training requires model parameters, gradients, and optimizer states. Conventional data parallelism copies all three to every GPU. ZeRO shards these states and exchanges the pieces needed for computation.
- Each GPU receives a different portion of training data.
- ZeRO assigns each GPU a shard of optimizer states, gradients, or parameters, depending on the stage.
- GPUs exchange required parameter shards during forward and backward passes.
- Each GPU updates its assigned shard and synchronizes results.
ZeRO Stages 1, 2, and 3 Compared
Later stages save more memory but require more device-to-device communication. They do not automatically make training faster.
| Stage | What it partitions | Memory impact | Best fit |
|---|---|---|---|
| ZeRO-1 | Optimizer states | Moderate reduction | Jobs that nearly exceed GPU memory |
| ZeRO-2 | Optimizer states and gradients | Larger reduction | Multi-GPU fine-tuning with capable networking |
| ZeRO-3 | Optimizer states, gradients, and parameters | Greatest reduction | Very large models that otherwise cannot fit |
Benefits of ZeRO Optimization
ZeRO helps when memory, rather than raw compute, limits training.
- It enables larger model training or fine-tuning without every GPU holding the full model state.
- It reduces per-device memory pressure and can allow larger batch sizes.
- It works alongside mixed-precision training and activation checkpointing.
- It can improve hardware utilization when carefully configured.
Practical Limits and Tradeoffs
Memory savings are not free. Measure end-to-end training time, not only whether a model fits.
- Sharding increases GPU communication and can expose a slow network interconnect.
- ZeRO-3 can add synchronization overhead during parameter gathering.
- Distributed checkpointing and debugging become more complex.
- Small models and single-GPU workloads may gain little.
Choosing the Right ZeRO Stage
Select the least complex stage that solves the memory problem.
- Start with ZeRO-1 when optimizer states cause out-of-memory errors.
- Use ZeRO-2 when gradients also exceed GPU memory.
- Use ZeRO-3 when parameters prevent training or fine-tuning.
- Consider ZeRO-Offload or ZeRO-Infinity when CPU memory or storage must help hold model state, while expecting slower transfers than GPU memory.
- Test batch size, GPU count, and network bandwidth before committing.
ZeRO Optimization and Emergent
Many AI products use hosted models through APIs and never need distributed training. Teams that fine-tune models still need dependable application delivery. An AI app builder can turn model capabilities into full-stack products, while cloud cost optimization helps evaluate the infrastructure tradeoffs of GPU-heavy workflows. Build AI-powered apps with Emergent.
on Emergent today

