Memory-Friendly Optimizer Practices for Training Very Large Models
Optimizer states, not raw compute, often dominate the memory footprint of large-scale model pretraining. This article explains how element-wise adaptive optimization inflates memory with per-parameter moment states, how matrix-wide updates with orthogonalization can reduce them, and how to evaluate the switch honestly—covering memory accounting, training stability, parallelism trade-offs, and a minimal rollout checklist for production-scale training.
Memory-Friendly Optimizer Practices for Training Very Large Models
The Bottleneck Is Not Compute Alone, but Optimizer State
The bottleneck of large-model pretraining is often oversimplified as “not enough GPUs” or “slow kernels.” What actually squeezes training capacity is frequently the extra statistics the optimizer maintains for every parameter. Mainstream adaptive methods keep a first moment and a second moment for each scalar parameter: the former tracks a moving average of gradients, the latter a moving average of squared gradients, and both are used to scale the per-element step size.
For a parameter count of (N), the two moments alone occupy roughly (8N) bytes in single precision—before counting master weights, gradients, activations, and communication buffers. Once parameters reach the hundreds of billions or trillions, this state can be on the same order as—or larger than—the model weights themselves. Batch size and sequence length are forced down, and throughput sensitivity to cluster scale is amplified. Mixed-precision training relieves pressure on master weights and activations, but it does not automatically eliminate these two moments.
Optimizer design therefore has to answer two questions at once: is the update direction still stable, and how much resident state is required to produce it?
What Element-Wise Adaptation Actually Does
Consider a layer’s weight matrix (W) with gradient (G). Element-wise adaptation does not treat (W) as a geometric object; it treats each (W_{ij}) as an independent scalar:
- Accumulate gradient direction with momentum to suppress single-step noise;
- Estimate the gradient scale of each coordinate with second-order statistics;
- Take small steps on large-scale coordinates and large steps on small-scale ones, with clipping or bias correction applied to updates.
This approach works well for heterogeneous gradients, embedding tables, and output heads, where coordinate magnitudes can differ by several orders of magnitude. The cost is also clear: every trainable scalar carries at least two additional state tensors shaped like the parameters, plus possibly a master-parameter copy. State is bound to individual parameters and cannot be merged along matrix structure.
Metaphorically, every parameter rolls on its own one-dimensional slope, and the scheduler must record the velocity and road roughness of each individual “ball.” Precise, but the ledger is enormous.
Treating the Whole Weight Matrix as a Single Update
Another line of thinking works differently: for regularly shaped matrix parameters in hidden layers, instead of scaling coordinate by coordinate, first transform the “momentum-plus-current-gradient matrix” into a more balanced update direction, then apply it to (W) as a whole. The common mathematical tool is orthogonalization or approximate orthogonalization of the matrix, which makes step sizes across singular directions more uniform and prevents a few large singular values from dominating the update.
Compared with element-wise methods, the differences are mainly three:
- The unit of optimization changes from scalar to matrix. One update corresponds to a single linear transformation of the entire weight, not (N) unrelated scalings.
- State can be substantially smaller. If momentum is kept, typically only one momentum buffer shaped like the parameters is needed—no second moment. Orthogonalization is performed on the current step’s matrix, so no long-term per-element variance needs to be stored.
- The inductive bias differs. It assumes coordinates within the same matrix should advance in a more geometrically consistent way, which suits wide, regular linear layers—not all parameters.
This is not a claim that “marching in formation always beats skirmishers.” Embeddings, layer normalization, biases, gating scalars, and other low-dimensional or highly sparse parameters have widely varying gradient scales, and element-wise adaptation often remains more stable for them. A common engineering practice is a hybrid strategy: matrix backbones use whole-matrix updates, everything else uses adaptive updates.
How to Count the Memory Ledger Honestly
When comparing the two optimizer families, do not stop at the slogan “one tensor fewer.” Break down the resident memory:
| Item | Element-wise adaptive (typical) | Matrix-wide update (hybrid) |
|---|---|---|
| Master parameter copy | Usually requires high-precision master weights | Also required |
| Gradients | One copy per step | One copy per step |
| First-moment state | Present | Usually kept for matrix parts |
| Second-moment state | Present, shaped like parameters | Can be omitted for matrix parts |
| Extra compute | Element-wise multiply/divide, bandwidth-heavy | Orthogonalization or approximate factorization, compute-heavy |
The savings come mainly from the second-moment state. For networks dominated by matrix parameters, this can approach the size of a full-precision copy of the parameters, freeing memory for micro-batches or sequence length. However, orthogonalization, Newton–Schulz iterations, or similar matrix iterations add compute and temporary buffers. If temporary buffers are allocated at per-layer peak and never reused, the savings are wiped out. Implementations should use blocking, in-place iteration, and compute–communication overlap to keep the extra peak within acceptable bounds.
Nor should anyone claim that “less optimizer memory means exponentially lower cost.” Cost also depends on parallelism strategy, activation recomputation, sequence packing, and cluster utilization. Reducing optimizer state is a necessary condition, not a sufficient one.
Training Stability: Neat Is Not the Same as Usable
Step-count improvements on small models cannot be extrapolated directly to very large models. Matrix-wide updates must clear several hurdles:
- Scale. Orthogonalization changes the norm of the update. Without scaling decoupled from layer width and learning rate, deep networks easily develop layer-to-layer step-size imbalance.
- Momentum coefficient. The larger the momentum, the more history dominates; since orthogonalization acts on the fused matrix, the coefficient affects both noise suppression and turning speed.
- Numerical range. Half-precision momentum overflows easily on large-magnitude coordinates; upcasting or clipping is usually needed before orthogonalization.
- Scope of application. Enable it only for 2D, dense weights on the main residual path; keep adaptive updates for 1D parameters, vocabulary embeddings, and sparse expert-routing statistics.
- Monitoring metrics. Beyond loss, track the ratio of update norm to parameter norm, the layer indices where gradients explode, and numerical consistency across parallel sharding.
It is fair to question whether “square matrices can fight on a skirmisher’s battlefield.” The right response is not to deny the difference, but to split parameters into two classes and run ablations as width, depth, and data scale—not to declare victory only on tiny models.
How It Interacts with System Parallelism
Memory savings that never land in the parallelism strategy remain a paper ledger.
Under data parallelism, if optimizer state is still stored for global parameters, the per-node memory wall is merely postponed. Matrix-wide updates reduce per-device state, allowing larger local batches and helping amortize communication.
Tensor parallelism shards the same matrix across devices. If orthogonalization must see the full matrix, it requires aggregation before the update—a communication pattern different from element-wise updates, and full all-gather every step must be avoided. Practical options include blocked orthogonalization, approximation on local submatrices only, or reducing orthogonalization frequency, trading a little extra communication for state savings. The error of any such approximation must be validated against loss curves and update norms; never assume “more orthogonal is always better.”
Pipeline parallelism and activation recomputation govern activation memory and are largely orthogonal to optimizer state. When both are in play, fix the recomputation policy first, then measure the peak change from the optimizer switch alone; otherwise attribution is impossible.
Checkpointing must change too. Resuming training requires not only weights but also the state shapes and step counts of each optimizer. A hybrid optimizer means one global step maps to multiple state dictionaries—omitting a momentum buffer will cause a loss jump after resume.
A Minimal Rollout Sequence
- Classify parameters first: separately count element shares of 2D dense matrices, 1D vectors, embeddings, and output heads, and confirm that matrix parameters really dominate; otherwise state savings are limited.
- On the same data subset, compare three settings: fully adaptive; whole-matrix updates for hidden-layer matrices only; and whole-matrix updates with orthogonalization disabled. The third group distinguishes whether “dropping the second moment” or “orthogonalization itself” is doing the work.
- Fix global batch size and sequence length, and record peak memory, per-step time, and steps needed to reach the same loss. Judging by steps alone or memory alone leads to wrong conclusions.
- Run a short experiment at larger width and check whether update norms drift with width. If they drift, adjust the width-dependent learning-rate scaling first rather than simply increasing the batch size.
- Only then consider longer context. Context length increases activations, not optimizer state; the freed space must genuinely exist, or longer context will immediately trigger recomputation or reduced micro-batching.
A schematic update flow can be written as the following pseudocode. It expresses control flow only and does not map to any specific framework API:
for each parameter group:if group is dense matrix and rank == 2:M = beta * M + GU = orthogonalize(M) # computed per step; no long-term second-moment stateW = W - lr * scale(U, dim=W)else:# element-wise first and second moment updatesM = beta1 * M + (1 - beta1) * GV = beta2 * V + (1 - beta2) * G^2W = W - lr * M / (sqrt(V) + eps)
Deciding Whether to Switch
Conditions that favor matrix-wide updates are typically: linear layers dominate trainable parameters, optimizer state is already the main contributor to peak memory, and the team can tolerate the extra cost of matrix iterations. Situations where it should not be a standalone bet include: tasks that depend heavily on embedding quality, extremely sparse gradients, or communication already saturating step time—adding synchronous orthogonalization would only lengthen the critical path.
Evaluation conclusions should be written as reproducible comparisons: loss-vs-step curves, peak memory, and tokens processed per second, all under identical data order, precision strategy, and global batch size. Without these three, any discussion of “unique advantages” lacks evidence.
For general cluster-side capabilities, object storage holds checkpoints, monitoring and alerting watch memory and loss slope, and log services align numerical anomalies across parallel ranks. These are standard training-platform provisions and cannot substitute for validating the optimizer itself.
Summary
In very large model training, the value of adaptive optimization is per-coordinate step-size control, and its cost is moment state on the same order as the parameters. Treating regular matrices as a whole and using momentum plus orthogonalization to produce one update can trade less long-term state for more balanced matrix step sizes—but 1D parameters must stay on the adaptive path, and the compute, communication, and scaling issues of orthogonalization must be faced squarely. Only when the memory ledger, numerical monitoring, and ablation experiments all hold up is this hybrid update a production-ready engineering choice, rather than a direct scale-up of small-model benchmark results.
