# 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.

Source: https://www.nodus-compute.ai/blog/deepspeed-zero-stages-explained/
Build revision: 654ee55d95b7b4ec5fca7780411e6390f486ddfa

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](https://www.nodus-compute.ai/blog/fsdp-vs-deepspeed/). If you are new to sharding, start with [FSDP vs DDP](https://www.nodus-compute.ai/blog/fsdp-vs-ddp/).

## 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](https://arxiv.org/abs/1910.02054) 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](https://www.deepspeed.ai/tutorials/zero/) 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](https://deepspeed.readthedocs.io/en/latest/memory.html) 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?

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.

![Model state per GPU for a 70B full fine-tune as GPUs grow: on 2, 4, 8, 16 and 32 GPUs, ZeRO-1 needs 700, 490, 385, 332.5 and 306.25 GB; ZeRO-2 needs 630, 385, 262.5, 201.25 and 170.625 GB; ZeRO-3 needs 560, 280, 140, 70 and 35 GB.](https://www.nodus-compute.ai/blog-charts/deepspeed-zero-stages-explained/70b-vs-gpu-count.svg) *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?

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](https://www.nodus-compute.ai/pricing/):

|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.

![Hourly price of the setups that hold a 70B full fine-tune’s model state with room for activations: 8 x H100 with ZeRO-3 and CPU optimizer offload at $20.80, 16 x H100 with ZeRO-3 at $41.60, 8 x B200 with ZeRO-3 at $44.00 and 8 x B300 with ZeRO-2 at $55.54.](https://www.nodus-compute.ai/blog-charts/deepspeed-zero-stages-explained/70b-setups-price.svg) *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](https://www.nodus-compute.ai/docs/guides/multi-node/) 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](https://www.nodus-compute.ai/blog/gpus-needed-to-train-a-model/).

## 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|

![Data each GPU sends and receives per training step for a 70B model in 16-bit: 280 GB for DDP, ZeRO-1 and ZeRO-2, and 420 GB for ZeRO-3.](https://www.nodus-compute.ai/blog-charts/deepspeed-zero-stages-explained/70b-comm-per-step.svg) *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](https://www.deepspeed.ai/docs/config-json/) 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](https://www.deepspeed.ai/tutorials/zero-offload/) 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?

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:

1. 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.
2. 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.
3. If ZeRO-3 does not fit, or a smaller GPU is much cheaper, add `offload_optimizer` to CPU. That cuts GPU memory to about 2P/N but needs host RAM.
4. 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](https://www.nodus-compute.ai/blog/vram-needed-for-70b-model/) covers the LoRA and inference cases that avoid most of this.

## 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](https://www.deepspeed.ai/tutorials/zero/).

ZeRO-1:

```json
{
    "zero_optimization": {
        "stage": 1,
        "reduce_bucket_size": 5e8
    }
}
```

ZeRO-2:

```json
{
    "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](https://www.deepspeed.ai/tutorials/zero-offload/). We fixed the comma placement in the published snippet so the JSON parses:

```json
{
    "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:

```json
{
    "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](https://www.deepspeed.ai/docs/config-json/). 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?

On one machine, pass the DeepSpeed launcher to `nodus run`. The [nodus run reference](https://www.nodus-compute.ai/docs/reference/cli/nodus_run/) shows `nodus run --gpu H100:8 --max-cost 40 -d -- torchrun train.py`; for DeepSpeed, only the part after `--` changes:

Terminal window

```bash
nodus run --gpu H100:8 --max-cost 40 -d -- deepspeed train.py --deepspeed --deepspeed_config ds_config.json
```

Before 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](https://www.nodus-compute.ai/docs/guides/gpus/) 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](https://www.nodus-compute.ai/docs/guides/checkpoints/) restores into the next attempt if a machine is lost. One limit: managed [TrainingJobs](https://www.nodus-compute.ai/docs/guides/training/) “reject `ZeRO1`, `ZeRO2` and `ZeRO3` with a distributed shape before launch”, so use a plain Job for DeepSpeed sharding.

## FAQ

### 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?

No. ZeRO’s data-parallel stages cover weights, gradients and optimizer state only. Activations need [gradient checkpointing](https://www.nodus-compute.ai/blog/gradient-checkpointing-explained/) or smaller micro-batches, and if you still run out, our [CUDA out of memory guide](https://www.nodus-compute.ai/blog/fix-cuda-out-of-memory-pytorch/) goes through the other fixes.

### 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](https://www.nodus-compute.ai/blog/lora-vs-full-fine-tuning/).
