Optimizer Memory Bottlenecks in Large Model Training: A Practical Guide to Low-Memory Optimizer Design
This article breaks down why optimizer states have become a rigid, second-largest memory cost in large-scale pretraining, and how to evaluate whether a low-memory optimizer is worth adopting. It includes a reusable static memory estimation framework, the technical core of structured low-memory updates such as Muon, a hybrid optimizer dispatch pattern by parameter dimension, a verification-driven selection checklist, and a production rollout checklist covering observability and rollback. Engineers will learn how to quantify the memory budget, run equal-cost comparison experiments, and turn saved memory into larger batches and longer contexts.
1. Background: Why Optimizers Became a Hidden Memory Sink
In large-scale pretraining, engineers tend to focus on parameter count, parallelism strategy, and communication efficiency, while optimizer states are routinely underestimated. In fact, since adaptive optimization methods became mainstream, the optimizer itself has become the second-largest hard cost in the memory budget, behind only parameters and gradients.
The root cause lies in how the adaptive mechanism is implemented. To give every parameter its own learning rate scale, the optimizer must maintain an extra first moment (momentum term) and second moment (a moving average of squared gradients) for each parameter. Under common mixed-precision configurations, parameters and gradients are usually stored in half or mixed precision, while moment estimates are often kept in single precision for numerical stability. As a result, the number of optimizer state bytes per parameter is multiplied several times over.
For a trillion-parameter-scale model, the first and second moments alone can consume on the order of ten-plus terabytes of memory in total (summed across all training nodes). What makes this number damaging is that it is rigid: it cannot be reclaimed through activation recomputation, nor eliminated by operator fusion. It can only squeeze the budget from three places: model size, batch size, and context length.
2. Breaking Down the Memory Budget
Before deciding whether an optimizer is worth replacing, the first step is to get the memory accounting straight. A reusable estimation framework is shown below (illustrative; actual behavior depends on the framework implementation):
# Illustrative memory budget estimation, not a specific framework APIdef estimate_memory(num_params, bytes_param=2, bytes_grad=2,bytes_moment=4, num_moments=2):param_mem = num_params * bytes_paramgrad_mem = num_params * bytes_gradoptim_mem = num_params * bytes_moment * num_momentsreturn {"parameters": param_mem,"gradients": grad_mem,"optimizer_states": optim_mem,"static_total": param_mem + grad_mem + optim_mem}# 1.6e12 parameters, mixed precision, two moments in single precisionprint(estimate_memory(1.6e12))# optimizer_states is about 1.28e13 bytes, roughly 12.8 TB (excluding replica and shard overhead)
Three optimization paths can be read directly from the formula:
- Reduce the number of state bytes per parameter (lower-precision states, single-moment methods);
- Reduce the number of states (drop the second moment, or switch to a structural approximation);
- Slice the states across more devices (sharded parallelism), but this only changes per-GPU pressure and does not reduce the total.
The key point is that sharding can relieve the problem of a single node not being able to fit everything, but it cannot solve the problem of a total volume so large that it constrains batch size and sequence length. This is exactly where low-memory optimizers create value.
3. The Technical Core of Low-Memory Optimization
A class of methods represented by Muon has drawn attention not because of “stronger convergence,” but because it redesigns the structure of optimizer states: instead of storing a full second-moment matrix for every parameter, it uses the matrix structure itself, through orthogonalization/normalization operations, to constrain the update direction, reducing the state overhead from a fixed multiple of the parameter count to a more controllable magnitude.
The engineering significance can be summarized in three points:
- Optimizer state memory drops significantly, and the optimizer’s share of static memory falls back from a dominant term to a secondary one;
- The freed budget can be converted directly into larger batches and longer contexts, improving throughput and sample efficiency;
- Combined with sharded parallelism, per-GPU headroom increases, leaving more room for trade-offs in activation recomputation strategy.
It is worth emphasizing that these methods are not naturally better for every layer. A common practice in engineering is a “hybrid optimizer”: use low-memory structured methods for matrix-shaped weights (such as attention and projection layers), and keep mature element-wise adaptive methods for vector-shaped parameters (biases, normalization scales, embedding layers, and so on), balancing stability and overhead.
# Pseudocode: dispatch optimizers by parameter dimensionalityfor name, p in model.named_parameters():if p.ndim >= 2:opt.add_param_group(group="matrix", params=[p]) # structured low-memory updateelse:opt.add_param_group(group="vector", params=[p]) # element-wise adaptive update
4. Selection Framework: When Should You Switch
Replacing an optimizer is a central change to the training stack and should be driven by verifiable criteria rather than hype. Evaluate in the following order:
- Memory accounting: has the optimizer state become the single largest item in static memory, and has it already materially limited batch size or sequence length;
- Convergence equivalence: run alignment experiments on a small-scale proxy task with the same data and the same token budget, comparing loss curves and downstream metrics;
- Numerical stability: observe update norms, gradient clipping trigger rate, and loss spike frequency;
- Throughput accounting: convert the saved memory into achievable batch size and parallelism efficiency, and assess end-to-end time gains;
- Rollback cost: keep the original optimizer configuration and checkpoint compatibility so a quick rollback is possible.
A practical acceptance method is to set up an “equal-cost comparison experiment”: fix compute and data, switch only the optimizer, and compare the time and peak memory required to reach the same target loss.
5. Production Checklist
- Start with a static memory breakdown, clarifying the share of parameters, gradients, optimizer states, and activations;
- Adopt a hybrid optimizer strategy, dispatching by parameter dimensionality to avoid a one-size-fits-all approach;
- Treat optimizer state precision, sharding strategy, and recomputation granularity as a jointly tunable set of parameters and search in small steps;
- Build training observability: bring peak memory, throughput, and loss spikes into standard dashboards for monitoring, alerting, and logging;
- Record the optimizer implementation and configuration version in checkpoints to guarantee reproducibility and rollback;
- Validate memory and communication behavior after scaling on container platforms and elastic compute resources before scaling up to full training.
6. Conclusion
Optimizer memory overhead is a structural problem that has long been underestimated. The elegance of adaptive methods comes at the cost of two states per parameter, which amplifies into terabyte-scale rigid overhead in trillion-parameter scenarios and directly compresses batch and context space. New approaches represented by low-memory structured updates pull the optimizer back from a dominant memory item to a secondary one, opening up space for both training scale and efficiency. For engineering teams, the right path is not the replacement itself, but to quantify first, then run small-scale alignment validation, and finally roll out gradually under conditions that are observable and rollback-capable. On top of the general compute, container, and monitoring capabilities provided by Baidu AI Cloud, this approach can land more smoothly in production training.
