What are DeepSpeed ZeRO stages 1, 2 and 3?
ZeRO-1 splits optimizer state, ZeRO-2 adds gradients, ZeRO-3 adds weights. Per-GPU memory math for 7B and 70B, configs and a rule for picking one.
DeepSpeed ZeRO stages 1, 2 and 3 split a model’s training state across GPUs: stage 1 splits the Adam optimizer state, stage 2 also splits the gradients, and stage 3 also splits the weights. On Nodus, the stage decides the hardware: by our math a 70B full fine-tune fits 8 x NVIDIA B200 at $44.00/hr with ZeRO-3, or 8 x NVIDIA H100 at $20.80/hr with ZeRO-3 and the optimizer in CPU memory. Only ZeRO-3 keeps cutting per-GPU memory as you add GPUs, and it moves 1.5 times as much data per step as stages 1 and 2.
This post is the memory and config reference for the stages themselves. If you are choosing between DeepSpeed and PyTorch FSDP, read our FSDP vs DeepSpeed guide. If you are new to sharding, start with FSDP vs DDP.
What does each ZeRO stage split across GPUs?
Section titled “What does each ZeRO stage split across GPUs?”Each stage removes one more copy that plain data parallelism keeps on every GPU. The ZeRO paper counts 16 bytes of model state per parameter for mixed-precision training with Adam: 2 bytes of 16-bit weights, 2 bytes of 16-bit gradients and K = 12 bytes of optimizer state. Those 12 bytes are an fp32 copy of the weights plus Adam’s two fp32 moments, 4 bytes each.
The DeepSpeed ZeRO tutorial defines the stages the same way. In stage 1, “each process updates only its partition” of the optimizer state. Stage 2 keeps only the gradients that match that partition. Stage 3 partitions the 16-bit weights and “will automatically collect and partition them during the forward and backward passes.”
With P parameters on N GPUs, section 5 of the paper gives the per-GPU model state:
| Stage | What is split | Model state per GPU | DeepSpeed setting |
|---|---|---|---|
| 0 (off) | Nothing | 16P | "stage": 0 |
| ZeRO-1 | Optimizer state | 4P + 12P/N | "stage": 1 |
| ZeRO-2 | Optimizer state and gradients | 2P + 14P/N | "stage": 2 |
| ZeRO-3 | Optimizer state, gradients and weights | 16P/N | "stage": 3 |
Activations are not in these numbers, and neither are temporary buffers. The DeepSpeed memory docs warn that for long sequences activations can take as much memory as weights, gradients and optimizer state combined. Treat every figure below as a floor.
How much GPU memory do 7B and 70B models need at each stage?
Section titled “How much GPU memory do 7B and 70B models need at each stage?”On 8 GPUs, a 7B model needs between 112 GB and 14 GB per GPU depending on the stage, and a 70B model between 1,120 GB and 140 GB. These are our numbers from the paper’s formulas, in decimal GB, before activations:
| Setting on 8 GPUs | 7B per GPU | 70B per GPU |
|---|---|---|
| Stage 0 | 112 GB | 1,120 GB |
| ZeRO-1 | 38.5 GB | 385 GB |
| ZeRO-2 | 26.25 GB | 262.5 GB |
| ZeRO-3 | 14 GB | 140 GB |
| ZeRO-2 + CPU optimizer offload | 14 GB | 140 GB |
| ZeRO-3 + CPU optimizer offload | 1.75 GB | 17.5 GB |
For 7B: 7 x 16 = 112; 7 x (4 + 12/8) = 38.5; 7 x (2 + 14/8) = 26.25; and 7 x 16/8 = 14. The 70B column multiplies by 70 instead. The two offload rows use the DeepSpeed memory docs, which put GPU memory at 2P for ZeRO-2 with the optimizer on CPU, and at 2P/N plus the largest layer for ZeRO-3.
The bigger lesson is in the formulas. ZeRO-1 and ZeRO-2 keep a full copy of something on every GPU, so they hit a floor: 4P for stage 1 and 2P for stage 2. For 70B those floors are 280 GB and 140 GB, more than any 80 GB GPU holds no matter how many you add. Only ZeRO-3 divides everything by N.
Adding GPUs barely helps ZeRO-1 and ZeRO-2 on a 70B model; only ZeRO-3 keeps shrinking.
The 70B curve points come from the same formulas, for example 70 x (4 + 12/32) = 306.25 GB for ZeRO-1 on 32 GPUs, and 70 x 16/32 = 35 GB for ZeRO-3.
How many GPUs does each stage need on Nodus?
Section titled “How many GPUs does each stage need on Nodus?”For 70B, ZeRO-1 never fits a listed GPU, ZeRO-2 fits only the 288 GB NVIDIA B300, and ZeRO-3 fits 8 x B200. We matched the 70B numbers against the per-GPU memory and hourly supply prices on the Nodus pricing page:
| 70B full fine-tune | Model state per GPU | Left for activations | Listed price |
|---|---|---|---|
| 8 x H100 (80 GB), ZeRO-3 + CPU optimizer | 17.5 GB | 62.5 GB | $20.80/hr |
| 16 x H100 (80 GB), ZeRO-3, two machines | 70 GB | 10 GB | $41.60/hr |
| 8 x H200 (141 GB), ZeRO-3 | 140 GB | 1 GB | $28.74/hr |
| 8 x B200 (180 GB), ZeRO-3 | 140 GB | 40 GB | $44.00/hr |
| 8 x B300 (288 GB), ZeRO-2 | 262.5 GB | 25.5 GB | $55.54/hr |
Prices checked November 30, 2026: H100 $2.600, H200 $3.593, B200 $5.500 and B300 $6.943 per GPU-hour, times the GPU count. The 8 x H200 row is there to show a trap: 1 GB of headroom will not hold real activations, so treat it as a miss.
The cheapest per hour is the offload setup, but CPU offload slows each step, so compare the price per finished run.
ZeRO-1 fails because its unsplit weights and gradients alone are 4 x 70 = 280 GB per GPU. The 16 x H100 row works on paper, but 10 GB of headroom is tight, and it needs two machines on a fast network. On Nodus, multi-node runs are in Beta and list the DeepSpeed launcher as “Accepted in the Beta, qualified later”.
A 7B model is much easier. With no ZeRO at all, its 112 GB fits one H200 with 29 GB to spare, or one B200 with 68 GB to spare. On 8 x H100, ZeRO-2 leaves 53.75 GB per GPU for activations, which is usually enough. For the GPU count behind longer training runs, see how many GPUs you need to train a model.
What does each stage cost in communication?
Section titled “What does each stage cost in communication?”ZeRO-1 and ZeRO-2 move the same data as plain data parallelism, and ZeRO-3 moves 1.5 times as much. Section 7 of the ZeRO paper works this out per GPU and per training step. Standard data parallelism all-reduces the gradients, which costs 2P values. ZeRO-2 replaces that with a reduce-scatter of gradients (P) and an all-gather of updated weights (P), again 2P.
ZeRO-3 adds a weight all-gather in the forward pass and another in the backward pass, plus the gradient reduce-scatter. That totals 3P. With 16-bit values at 2 bytes, here is our arithmetic for one step:
| Model | DDP, ZeRO-1, ZeRO-2 (2P) | ZeRO-3 (3P) |
|---|---|---|
| 7B | 28 GB per GPU | 42 GB per GPU |
| 70B | 280 GB per GPU | 420 GB per GPU |
ZeRO-3 buys its memory savings with 50% more traffic per step.
Inside one 8-GPU machine, the extra traffic stays on the GPUs’ own interconnect. Across machines it crosses the network, which is where it hurts most. DeepSpeed’s ZeRO++ targets that case: the config docs say zero_hpz_partition_size should ideally equal the number of GPUs per node, so weight gathers stay inside each machine.
Offload has a different cost. The config docs say that with offload_optimizer the optimizer computation runs on the CPU “regardless of device option”, so every step ships gradients to the host and updated weights back. The ZeRO-Offload tutorial says DeepSpeedCPUAdam is 5X to 7X faster than the standard PyTorch implementation, but we have not measured the end-to-end slowdown, and it depends on your CPUs.
Which ZeRO stage should you pick?
Section titled “Which ZeRO stage should you pick?”Pick the lowest stage that leaves room for activations, and offload only when no stage fits the GPUs you can get. Here is the rule we use, derived from the formulas above:
- Compute 2P + 14P/N for ZeRO-2. If that plus your activation estimate fits, use ZeRO-2. It moves no more data than DDP and uses less memory than ZeRO-1, so ZeRO-1 rarely wins.
- If ZeRO-2 does not fit, use ZeRO-3 and check 16P/N. Keep it on one machine when you can, because its extra traffic is cheap over NVLink.
- If ZeRO-3 does not fit, or a smaller GPU is much cheaper, add
offload_optimizerto CPU. That cuts GPU memory to about 2P/N but needs host RAM. - Offload weights too (
offload_param), or use NVMe, only when CPU memory runs out. This is ZeRO-Infinity, and it is the slowest option.
Host RAM is the check people skip. The DeepSpeed memory docs size ZeRO-3 with optimizer offload and zero.Init at P x 16 x 1.5 on one machine, which is 70 x 16 x 1.5 = 1,680 GB for 70B. Our 70B VRAM guide covers the LoRA and inference cases that avoid most of this.
What do the DeepSpeed configs look like for each stage?
Section titled “What do the DeepSpeed configs look like for each stage?”Each one is a zero_optimization block that goes into your full ds_config.json, next to your batch size and bf16 settings. The ZeRO-1 and ZeRO-2 blocks are copied from the ZeRO tutorial.
ZeRO-1:
{ "zero_optimization": { "stage": 1, "reduce_bucket_size": 5e8 }}ZeRO-2:
{ "zero_optimization": { "stage": 2, "contiguous_gradients": true, "overlap_comm": true, "reduce_scatter": true, "reduce_bucket_size": 5e8, "allgather_bucket_size": 5e8 }}ZeRO-2 with CPU optimizer offload, from the ZeRO-Offload tutorial. We fixed the comma placement in the published snippet so the JSON parses:
{ "zero_optimization": { "stage": 2, "offload_optimizer": { "device": "cpu" }, "contiguous_gradients": true, "overlap_comm": true }}ZeRO-3 with both offloads, the ZeRO-Infinity block from the ZeRO tutorial. Delete offload_param for optimizer-only offload, and delete both offload sections for plain ZeRO-3:
{ "zero_optimization": { "stage": 3, "contiguous_gradients": true, "stage3_max_live_parameters": 1e9, "stage3_max_reuse_distance": 1e9, "stage3_prefetch_bucket_size": 1e7, "stage3_param_persistence_threshold": 1e5, "reduce_bucket_size": 1e7, "sub_group_size": 1e9, "offload_optimizer": { "device": "cpu" }, "offload_param": { "device": "cpu" } }}To use NVMe, set "device": "nvme" and add "nvme_path": "/local_nvme", the default path in the config docs. The same docs say NVMe offload works only with stage 3, while CPU optimizer offload works with stages 1, 2 and 3.
How do you run a ZeRO stage on Nodus?
Section titled “How do you run a ZeRO stage on Nodus?”On one machine, pass the DeepSpeed launcher to nodus run. The nodus run reference shows nodus run --gpu H100:8 --max-cost 40 -d -- torchrun train.py; for DeepSpeed, only the part after -- changes:
nodus run --gpu H100:8 --max-cost 40 -d -- deepspeed train.py --deepspeed --deepspeed_config ds_config.jsonBefore an offload run, check host memory with nodus get gpus --gpu H100 --count 8 --region us and read the MEMORY column. The example listing in the Nodus GPU guide shows an 8 x H100 machine with 1800Gi. If you launch with torchrun instead, the ZeRO-Offload tutorial warns that it sets OMP_NUM_THREADS=1, which leaves CPU Adam on one thread, so export a higher value first.
Write DeepSpeed checkpoints under /nodus/state, which the checkpoint guide restores into the next attempt if a machine is lost. One limit: managed TrainingJobs “reject ZeRO1, ZeRO2 and ZeRO3 with a distributed shape before launch”, so use a plain Job for DeepSpeed sharding.
What is DeepSpeed ZeRO-3?
Section titled “What is DeepSpeed ZeRO-3?”ZeRO-3 is the stage that partitions the 16-bit weights as well as gradients and optimizer state, so each GPU holds about 16P/N bytes of model state and gathers each layer’s weights only when it runs. It is the stage that lets a 70B full fine-tune fit 8 x B200 on Nodus, at the price of 1.5 times the per-step traffic.
Does ZeRO reduce activation memory?
Section titled “Does ZeRO reduce activation memory?”No. ZeRO’s data-parallel stages cover weights, gradients and optimizer state only. Activations need gradient checkpointing or smaller micro-batches, and if you still run out, our CUDA out of memory guide goes through the other fixes.
Is ZeRO worth it for LoRA fine-tuning?
Section titled “Is ZeRO worth it for LoRA fine-tuning?”Much less. With LoRA only the small adapters have gradients and Adam state, so stages 1 and 2 have little to split. ZeRO-3 still helps by sharding the frozen base weights, which matters for 70B and up. See LoRA vs full fine-tuning.
More from the blog
inference10 min read
What is the KV cache, and why does it eat GPU memory?
The KV cache stores keys and values for every token an LLM has read. Per-token math for real models, what happens when it fills, and how to shrink it.
Read the postcomparisons7 min read
What are the best Lambda Labs alternatives for training?
Lambda Labs alternatives for GPU training: the same 8 x H100, 10 hour run priced on Nodus, Runpod, Nebius, CoreWeave and Vast.ai, and when Lambda still wins.
Read the post