Optimizer Evolution and GPU Memory Optimization for Large-Scale Model Training
As models scale to trillions of parameters and context windows stretch to millions of tokens, GPU memory capacity and bandwidth—not compute—become the first bottleneck in training. This article breaks down the memory ledger of training (weights, gradients, optimizer states, and activations), compares element-wise adaptive optimizers with matrix-level orthogonalized optimizers in terms of state overhead and step efficiency, outlines where each approach applies, and provides a practical checklist for memory optimization, parallelism alignment, mixed precision, observability, and staged validation.
1. The Problem: Once Parameter Counts Explode, Memory Runs Out First
The latest generation of ultra-large open-source models—flagship versions at the trillion-parameter scale and lightweight versions at the ten-billion-parameter scale—have pushed long-context capability to the million-token range. The first wall engineering teams hit is not compute, but GPU memory capacity and memory bandwidth. The reason is straightforward: memory usage during training goes far beyond the weights themselves.
Take a typical mixed-precision training configuration as an example. Four types of data usually coexist in GPU memory:
- Model weights (typically keeping a higher-precision copy for updates)
- Gradients
- Optimizer states
- Activations and temporary buffers (strongly correlated with batch size and sequence length)
The first three scale only with the number of parameters; only the fourth scales with batch size and context length. This creates an awkward situation: once optimizer states consume the vast majority of memory, the space left for activations is severely compressed. Teams are forced to reduce batch size or shorten context length, then compensate with more gradient accumulation steps to reach an equivalent batch. Training time is stretched, and costs rise non-linearly.
2. The Memory Ledger of Element-Wise Adaptive Optimization
Adaptive moment estimation optimizers have long been the de facto default. The core idea is to maintain two statistics—first moment and second moment—for each parameter, using historical moving averages of the gradient to independently scale the step size for each coordinate.
The advantages are clear: they are friendly to sparse gradients, parameters at different scales, and scenarios requiring fine-grained tuning, with robust hyperparameters and a mature ecosystem.
The cost is equally clear: each parameter requires two additional state tensors. A rough calculation: with “weights + gradients + two moment states” and higher precision used in some parts, the memory overhead per parameter is often several times the parameter itself. Multiply that by a trillion parameters, and the state variables alone can reach the tens of terabytes, requiring multi-dimensional parallel sharding and remote storage offloading just to run.
Here is a schematic look at the state allocation logic (pseudocode, expressing only the memory ledger structure):
# Element-wise adaptive optimization: state count scales linearly with parameters, with a constant factor of 2m = zeros_like(param) # First moment, memory ≈ parameter countv = zeros_like(param) # Second moment, memory ≈ parameter countm.mul_(beta1).add_(grad, alpha=1 - beta1)v.mul_(beta2).addcmul_(grad, grad, value=1 - beta2)param.addcdiv_(m, v.sqrt().add_(eps), value=-lr)
3. Matrix-Level Orthogonalized Optimization: Treating the Weight Matrix as a Whole
The matrix-level orthogonalized optimization route takes a different perspective: instead of viewing a weight matrix as N unrelated scalars, it treats it as a high-dimensional geometric object that cannot be arbitrarily split. The update works by first fusing the gradient with momentum into a matrix, then orthogonalizing that matrix (in practice, using a low-cost approximate iterative orthogonalization rather than an exact decomposition), and finally adding the resulting orthogonal matrix to the weights as a whole.
This brings two direct benefits:
- Fewer states. There is no need to store a second moment for each parameter, so state overhead drops significantly. The saved memory can be returned to batch size and context length.
- More balanced update directions. Orthogonalization makes the scale of updates consistent across singular directions, equivalent to conditioning the update matrix. On hidden layers of deep networks, this often reaches the target loss in fewer training steps.
An analogy: element-wise optimization is like letting each small ball decide how far to roll on its own, requiring fine-grained instructions for every ball. Matrix-level optimization first arranges the balls into a square formation, then advances them in unison, greatly reducing coordination overhead.
Schematic representation (pseudocode):
# Matrix-level orthogonalization: maintain only one momentum buffer; the update is decided by orthogonalizationbuf = zeros_like(weight_matrix) # The only state, memory ≈ parameter countbuf.mul_(momentum).add_(grad)update = orthogonalize(buf) # Approximate orthogonalization iteration, no second moment storedweight_matrix.add_(update, alpha=-lr)
It is worth emphasizing that the orthogonalization iteration itself introduces extra computation and several matrix multiplications. This is a trade of “compute for memory and steps,” and whether it pays off depends on the compute-to-memory ratio of the hardware.
4. Questions and Boundaries: It Is Not a Universal Replacement
Once these methods appeared, they immediately faced reasonable questions: in real training, gradient distributions are highly uneven—does forcing uniform scale actually harm convergence? The answer is that it has clear applicability boundaries.
- Applicable: large matrix parameters in hidden layers, typically weights of wide linear layers.
- Not applicable: embedding layers, output heads, scaling and shifting in normalization layers, bias terms, and other parameters with one-dimensional or sparse updates. These are generally still handled by adaptive optimizers.
- Engineering conclusion: the mainstream approach is grouped hybrid use—binding different optimizers and learning rates to different parameter groups—rather than a global one-size-fits-all replacement.
param_groups = [{"params": hidden_matrix_params, "optimizer": "matrix_orthogonal", "lr": 1e-2},{"params": vector_and_sparse_params, "optimizer": "adaptive_moment", "lr": 1e-4},]
5. Deployment Checklist
- Calculate the memory ledger first. Estimate the four categories—weights, gradients, states, and activations—identify the bottleneck, and then decide the optimization direction.
- Prioritize state compression. Reducing state precision, sharding states, and offloading cold data to host memory or remote storage are all low-risk gains.
- Align with the parallelism strategy. Tensor parallelism splits matrices, pipeline parallelism splits layers, and data parallelism splits batches. These need to align with how optimizer states are sharded to avoid duplicate storage.
- Be careful with mixed precision. Orthogonalization iterations are sensitive to numerical precision. It is recommended to keep higher-precision master weights and key intermediate values, and to clip update magnitudes and monitor loss scaling.
- Ensure observability as a safety net. Set up monitoring and alerts for gradient norms, update norms, and loss spikes. Combined with logging services and elastic resource scheduling from container platforms, this allows quick identification of anomalies during long training runs.
- Validate at small scale before scaling up. First verify convergence curves and throughput on the ten-billion-parameter lightweight version, then migrate to the trillion-parameter flagship configuration, avoiding high-risk experiments directly on large-scale jobs.
6. Summary
Long context and trillion parameters have shifted the training bottleneck from “is there enough compute” to “how to allocate memory.” Element-wise adaptive optimization wins on robustness and ecosystem; matrix-level orthogonalized optimization wins on state overhead and step efficiency. They are not replacements for each other but a division of labor. What truly determines training cost is whether the memory ledger is calculated clearly, whether parallel sharding aligns with optimizer states, and whether the monitoring system can maintain stability over long training cycles.
