AI Researchestimator

Training memory planner

Training needs far more memory than the weights alone. With mixed precision and Adam, each parameter costs 16 bytes before sharding: 2 for the bf16 weight, 2 for its gradient, and 12 for the fp32 master copy plus Adam’s two fp32 moments. Activations come on top and grow with sequence length and batch size.

Fits

34.3 GB per GPU: 43% of one NVIDIA H100 SXM, with 45.7 GB free.

Per GPU34.3 GBof 80 GB
Memory on each GPU
  • Weights (bf16) 2 GB
  • Gradients (bf16) 2 GB
  • Optimiser and master weights 12 GB
  • Activations (estimate) 18.3 GB
  • Free 45.7 GB

Model and training setup

8B parameters as published; 32 layers, hidden size 4,096, 32 heads.

Optimiser
ZeRO stage

Optimiser states, gradients and weights are all split across the GPUs.

Activation recomputation

80 GB per GPU.

Breakdown

Weights2 GB8B parameters at 2 bytes
Gradients2 GB2 bytes per parameter
Optimiser and master weights12 GBAdam or AdamW plus an fp32 copy of the weights
Activations18.3 GBAn estimate; see the note below
Fewest GPUs that fit3At ZeRO stage 3
Per-GPU memory at each ZeRO stage
ZeRO stageWeightsGradientsOptimiserActivationsTotalFits
016 GB16 GB96 GB18.3 GB146.3 GBNo
116 GB16 GB12 GB18.3 GB62.3 GBYes
216 GB2 GB12 GB18.3 GB48.3 GBYes
3 (yours)2 GB2 GB12 GB18.3 GB34.3 GBYes
What this leaves out

Activations use the per-layer formulas of Korthikanti et al. without tensor or pipeline parallelism, so treat them as an estimate. The total also leaves out the output logits, embeddings, communication buffers, memory fragmentation and the CUDA context, which can add several gigabytes. It assumes bf16 weights and gradients with an fp32 master copy kept, and ZeRO shards across data-parallel GPUs only.

What it shows

Training needs far more memory than the weights alone. Each parameter costs 16 bytes before sharding, with mixed precision and Adam. Activations come on top.

ZeRO splits that cost across data-parallel GPUs. The tool adds the four parts per GPU, compares the total with the GPU you pick, and shows every ZeRO stage in one table.

How to read it

  • The headline says “Fits” or “Does not fit”, and how much memory is left or missing.
  • The bar splits memory per GPU into weights, gradients, optimiser and master weights, and activations.
  • Weights, gradients and optimiser states follow ZeRO’s accounting. They divide by the GPU count only at the stages that shard them.
  • Activations are an estimate from per-layer formulas. ZeRO does not divide them.
  • “Fewest GPUs that fit” is found at your ZeRO stage. At stage 0 adding GPUs does not shrink per-GPU states.
  • “What this leaves out” lists what the estimate misses. Real runs need a margin.

Questions

Why is training memory about 16 bytes per parameter?

The ZeRO paper counts 2 bytes for fp16 or bf16 weights, 2 for their gradients and 12 for the fp32 optimiser data: a master copy of the weights and Adam’s momentum and variance. Activations and buffers are extra.

What do the ZeRO stages shard?

Stage 1 shards optimiser states, stage 2 adds gradients and stage 3 adds the weights. Higher stages save more memory and add communication. Activations are not sharded by ZeRO.

How accurate are the activation numbers?

They are an estimate. The formulas count the main per-layer tensors of a standard transformer without tensor parallelism and leave out embeddings, output logits, communication buffers and fragmentation. Measure a real step before you commit to a configuration.

What does activation recomputation do?

Instead of storing every intermediate tensor for the backward pass, the run stores fewer and recomputes the rest. Selective recomputation drops only the memory-heavy attention scores; full recomputation keeps just each layer’s input. Both cost extra compute.

How does 8-bit Adam change the total?

It stores the two moments in 8 bits instead of 32, taking Adam’s 8 bytes per parameter down to 2. The fp32 master weights are still counted, so the saving is real but not fourfold on the whole total.

Sources

Explore further

Last updated

More tools

All tools

Your first senior-level
lesson is free.

Choose a course, open a free lesson, and explore an idea you’ve wanted to understand.