Roughly how much accelerator memory do weights, gradients and Adam state need for a 70-billion-parameter model trained in mixed precision? Show the accounting and say which precision choices change it.
Answer
Model answer, written in a candidate's voice
In short
- bf16 weights 2 B + bf16 grads 2 B + fp32 master 4 B + Adam m/v 8 B = 16 B/param
- 70B params × 16 B = 1.12 TB (≈1.02 TiB), before activations and fragmentation
- bf16 vs fp16: same 2 B size, but fp16 needs loss scaling/range care; bf16 has fp32’s range with less mantissa
- FP8 (≈14 B/param) and 8-bit optimisers (≈10 B/param, ≈8 B with both) reduce parts of the total, but the fp32 master copy often remains
- Sharding (ZeRO/FSDP) divides per-device memory by the data-parallel degree (1.12 TB / 64 ≈ 17.5 GB); cluster total is unchanged
In full
For a 70B-parameter model in standard mixed precision, the accounting is bf16 weights (2 B) + bf16 gradients (2 B) + fp32 master weights (4 B) + Adam m and v in fp32 (4 B + 4 B) = 16 B per parameter, about 1.1 TB before activations, communication buffers and fragmentation.
bf16 and fp16 are both 2 B for weights and gradients, but fp16 has a narrower exponent range and usually needs loss scaling, while bf16 has the same range as fp32 with less mantissa precision, so it rarely needs loss scaling. FP8 can shrink GEMM operands, but it does not automatically shrink the fp32 master weights or Adam state; if only weights and gradients go to FP8 the total is closer to 14 B/param, and adding 8-bit Adam brings it towards roughly 8 B/param, depending on scales and implementation. 8-bit optimisers reduce m and v from 8 B to about 2 B per parameter, giving roughly 10 B/param with bf16 weights/gradients and an fp32 master copy. Sharding does not change the cluster-wide total: ZeRO/FSDP-style sharding divides the sharded weights, gradients and optimiser state across the data-parallel degree, so per-device memory falls roughly by that factor, with ZeRO-1/2/3 sharding progressively more of the state (optimiser state, then gradients, then parameters).
What a strong answer covers
- bf16 weights (2 B) + bf16 gradients (2 B) + fp32 master weights (4 B) + Adam m and v (8 B) ≈ 16 bytes per parameter, about 1.1 TB, before activations.
- bf16 vs fp16 (range, loss scaling).
- FP8 training; 8-bit optimisers.
- Sharding divides the total by the data-parallel degree.
Common mistakes
- Counting only the weights.
- Forgetting the master copy and optimiser state.