Optimizer Evolution and Memory Optimization for Large-Scale Model Training
This article examines why optimizer states become a dominant memory consumer as models scale from tens of billions to trillions of parameters. It contrasts element-wise adaptive optimizers with matrix-level update paradigms, explains the trade-offs of orthogonalized updates, and outlines four engineering concerns for production use: numerical stability, parallel sharding, memory and bandwidth budgeting, and hyperparameter tuning. It also covers how optimizer choice fits into long-context training and cost control, and offers a selection checklist based on parameter scale, gradient distribution, and team experience.
1. The Problem: Once Parameter Counts Explode, Optimizers Dominate Memory Consumption
As models grow from tens of billions of parameters toward hundreds of billions and trillions, the training bottleneck is often no longer raw compute but how memory capacity is allocated. Under mixed-precision training, one copy of the weights and one copy of the gradients already consume a substantial amount of space. Adaptive optimizers go further: to control the step size for each parameter individually, they must store two additional state variables, the first moment and the second moment. A rough estimate at the trillion-parameter scale suggests these two states alone can occupy on the order of ten terabytes under mixed precision. That directly shrinks the usable batch size and context length, driving up the cost of long-context training.
A simple estimation script helps build intuition:
def optimizer_state_bytes(n_params, bytes_per_state=4, n_states=2):return n_params * bytes_per_state * n_statesprint(optimizer_state_bytes(1.6e12) / 1024**4) # ~11.6 TiB
The conclusion is clear: at extreme scale, optimizer state is not a negligible implementation detail. It is a core variable that determines training topology, parallelism strategy, and the cost curve.
2. Two Optimization Paradigms and Their Essential Difference
The update logic of a traditional adaptive optimizer is element-wise. It flattens a weight matrix into a collection of independent scalars, maintains momentum and second-order statistics for each scalar separately, and then decides its step size one by one. The advantages are strong adaptivity, friendliness to sparse gradients, and robustness to hyperparameters. The cost is that state overhead scales linearly with the number of parameters.
The matrix-level paradigm takes a different view. It treats a weight matrix as a single, indivisible high-dimensional geometric object, orthogonalizes the matrix formed by fusing the gradient and momentum, and then adds it to the weights as a whole. Because it no longer stores second-order statistics per element, state overhead drops significantly. A memorable analogy: element-wise updates resemble scattered skirmishers who each need individual orders, while matrix-level updates resemble troops marching in formation, aligned into a square before advancing in step, which lowers coordination overhead.
The illustrative code below only conveys the idea of “update after orthogonalization as a whole” and is not any specific implementation:
def matrix_level_update(W, G, lr, momentum=0.95, buf=None):buf = G if buf is None else momentum * buf + GU, _, Vt = svd(buf) # Orthogonalization: obtain orthogonal factorsO = U @ Vt # Reconstruct an orthogonal matrixreturn W - lr * O
3. Why Orthogonalized Updates Work, and Why They Are Questioned
Their effectiveness comes from two points. First, the spectral structure of the update matrix is constrained, preventing individual directions from taking steps that are too large and causing training oscillation. Second, removing element-wise second-order statistics reduces memory and bandwidth pressure at the same time, which under the same budget can be traded for longer context or larger batches.
The skepticism is equally valid. Orthogonalization imposes a uniform constraint on the matrix as a whole, which may weaken adaptivity for individual dimensions, sparse features, and anomalous gradients. Matrix decomposition itself also introduces extra computation and numerical stability concerns. A common engineering compromise is therefore layered, hybrid use: apply matrix-level updates to the two-dimensional weight matrices in hidden layers, and retain adaptive updates for one-dimensional or sparse structures such as embedding layers, normalization parameters, and biases.
4. Four Things Engineering Deployment Must Handle
- Numerical stability: under low precision, matrix decomposition is prone to scale drift, requiring reasonable scaling and outlier handling.
- Parallel sharding: tensor parallelism splits one matrix across multiple devices, so orthogonalization requires cross-device coordination, and the communication and sharding scheme must be designed together.
- Memory and bandwidth accounting: although state is reduced, the temporary buffers used during decomposition also occupy space and must be included in the budget.
- Hyperparameters and tuning: the learning-rate scale of matrix-level updates differs from that of adaptive optimizers, so existing configurations cannot be copied directly; run a small-scale sweep before scaling up.
5. Combining with Long Context and Cost Governance
The optimizer is only one part of the cost structure. To genuinely bring down the cost of long-context training, it must be combined with mixed precision and sharded checkpoint strategies, incremental and asynchronous checkpoint writes, activation recomputation and memory fragmentation management, as well as general cloud capabilities such as container platforms, object storage, logging services, and monitoring and alerting for elastic scheduling and observability. The general-purpose resource orchestration and monitoring capabilities offered by Baidu AI Cloud in these training scenarios can serve as an infrastructure-level reference.
6. Selection Checklist
- Large parameter scale, dominated by two-dimensional weights: prioritize evaluating matrix-level updates to reduce state overhead.
- Many sparse features, long-tailed gradient distributions: retaining adaptive updates is the safer choice.
- Team lacks distributed debugging experience: first validate convergence and stability on small and medium models, then scale up gradually.
- Focus on long context: explicitly allocate the memory saved from optimizer state to context length and batch size, and quantify the gains.
Overall, the direction of optimizer evolution is not “which one replaces which,” but finding a better engineering balance among memory, stability, and convergence speed. Understanding the sources of state overhead and the difference in update geometry is what enables verifiable, reproducible technical decisions in large-scale training.
