﻿# Training memory includes gradients and optimizer state as well as weights

Training memory includes gradients, optimizer moments and possible master weights beyond model parameters. Build a dtype-aware memory ledger without a fixed universal multiplier.

Author: Retrivium editorial team
Updated: 2026-11-03
Canonical URL: https://retrivium.ai/journal/optimizer-state-training-memory-ledger/
Language: en

A checkpoint’s weight size is only one part of a training memory budget. Adam-like optimizers retain additional state, gradients require storage, and mixed-precision recipes may keep another parameter representation. A component ledger explains these allocations more reliably than multiplying model size by an unexplained constant.

## Separate mathematical objects from stored copies

Parameters, parameter gradients and optimizer moments have different roles. Adam maintains moment estimates used by its adaptive update; these are not the model’s inference weights. Some training recipes retain high-precision master parameters alongside lower-precision working copies. Whether an object is separately allocated, aliased, sharded or temporarily materialized depends on implementation. Begin by listing actual stored objects rather than assuming every conceptual quantity always consumes a distinct full-sized buffer. A ledger should distinguish persistent state from temporary storage created during a step.

## Attach a dtype and element count to each row

For an illustrative parameter group with 1,000 elements, a separately stored 4-byte array occupies 4,000 bytes before allocator and alignment effects. If two moment arrays use that format, their combined payload is 8,000 bytes. Additional parameter and gradient arrays add their own rows according to their actual formats. This is arithmetic on a declared example, not a complete GPU capacity estimate. It shows why a memory claim must state the representation of each object instead of labeling the entire run with one precision word.

## Frozen parameters change the update ledger

A frozen base model may still need its weights for forward computation while not requiring a trainable gradient or optimizer state for every base parameter. Adapter training changes which parameter subset participates in updates. Conversely, an optimizer can initialize state lazily, so memory observed before a first update can understate later persistent allocations. Record the lifecycle stage at which a measurement was taken. The presence of weights in memory does not imply that all of them have matching optimizer arrays, and early absence of state does not prove it will remain absent.

## The ledger is not the whole peak

Activations, attention workspaces, communication buffers and allocator reservations can dominate additional peak memory. Distributed sharding changes local ownership and may create temporary gathered objects. Build the persistent-state subtotal first, then measure peak execution memory under the intended batch and sequence layout. Report both what the arithmetic includes and what the measurement observes. This produces a useful explanation of a training-memory discrepancy without claiming that parameter-state accounting alone predicts every transient allocation of an optimized training system.

## Primary research and implementation references

- [Mixed Precision Training](https://arxiv.org/abs/1710.03740).

- [Training Deep Nets with Sublinear Memory Cost](https://arxiv.org/abs/1604.06174).

- [Adam: A Method for Stochastic Optimization](https://arxiv.org/abs/1412.6980).

## Related engineering context

[Reproducible inference stacks: preserving a GPU pilot’s result](/journal/software-stack-reproducibility/); [A GPU inference benchmark you can trust](/journal/inference-benchmark-method/).
