How Orthogonalized Matrix Optimizers Cut Memory Usage in Large Model Training
Optimizer states are a major source of GPU memory pressure when training large language models. Orthogonalized matrix optimizers replace Adam's per-element first and second moment buffers with a single momentum buffer and update weights at the matrix level, cutting optimizer state memory roughly in half. This article explains the motivation, the core algorithm with example code, the memory savings and computational trade-offs, and a practical checklist for adopting this approach in mixed-optimizer training setups.
1. Background: Why Optimizer States Become a Memory Bottleneck
When training large models, GPU memory is mainly consumed by three types of data: model parameters, gradients, and optimizer states. Adaptive optimizers like Adam maintain a first moment (m_t) and a second moment (v_t) for every parameter, and both are typically stored in FP32.
For a 1.6T-parameter model, optimizer states alone require:
1.6 × 10^12 × 2 (two states) × 4 bytes ≈ 12.8 TB
This memory footprint grows linearly with the number of parameters and does not scale down with batch size. The more memory optimizer states consume, the less is left for activations, batch size, and context length. Teams usually have to compensate by adding more GPUs, sharding optimizer states, or enabling activation recomputation—all of which drive up training costs.
2. From Per-Element Updates to Whole-Matrix Updates
Adam computes the update step size independently for each scalar parameter, with no interaction between parameters. However, most hidden-layer weights in large models are two-dimensional matrices—for example, the weight of a 1000×1000 linear layer—whose elements are structurally correlated. The starting point of orthogonalized matrix optimizers is simple: treat the entire weight matrix as a single unit when deciding the update direction.
The core process has three steps:
- Accumulate gradients with momentum to obtain a momentum matrix M_t;
- Compute the orthogonal matrix O_t closest to M_t. If we decompose M_t via singular value decomposition as M_t = UΣVᵀ, then O_t = UVᵀ—keeping the singular directions while unifying all singular values to 1;
- Multiply O_t by the learning rate and update the weights.
In practice, a full SVD is unnecessary; iterative methods are commonly used to approximate the orthogonal matrix. Here is illustrative code, where the polynomial coefficients are pre-set constants. It assumes the matrix has no more rows than columns; otherwise, transpose first:
def orthogonalize(M, coeffs, steps=5, eps=1e-7):"""Approximate the orthogonalization of M (UV^T) iteratively"""a, b, c = coeffs # pre-set polynomial coefficientsX = M / (M.norm() + eps) # normalize to ensure convergencefor _ in range(steps):A = X @ X.TX = a * X + (b * A + c * (A @ A)) @ Xreturn Xdef matrix_optimizer_step(W, grad, momentum, lr, coeffs, beta=0.95):momentum = beta * momentum + grad # only one momentum buffer neededupdate = orthogonalize(momentum, coeffs)W = W - lr * updatereturn W, momentum
The intuition behind this update rule: if gradients along a few singular directions are unusually large, per-element methods and standard momentum methods may let those directions dominate training. Orthogonalization flattens the update magnitude across directions so that a single update acts uniformly along all principal directions of the matrix.
3. Memory Savings and Computational Cost
Memory savings. This approach stores only one momentum buffer for matrix parameters, eliminating the second moment entirely. Using the same 1.6T-parameter example, if all parameters used this scheme, optimizer states would drop from roughly 12.8 TB to about 6.4 TB—a 50% reduction. The actual savings depend on how many parameters in the model are two-dimensional hidden-layer matrices, so total savings are usually below this theoretical ceiling.
Computational cost. Iterative orthogonalization requires multiple matrix multiplications at every training step. The number of iterations is a hyperparameter that needs tuning, and larger matrices incur higher per-step overhead.
Distributed implementation. Adam’s per-element operations allow parameters to be sharded arbitrarily, with each GPU computing independently after sharding. Matrix-level operations, by contrast, require either the full matrix or specialized sharding and communication strategies, which significantly increases engineering complexity. This must be considered early when designing the training framework.
4. Addressing the Skepticism: Are Uniform Updates Practical?
A common objection: real loss landscapes are highly anisotropic, so wouldn’t uniform update magnitudes waste useful information? It helps to distinguish two concepts. Orthogonalization does not abandon adaptivity—it raises the granularity of adaptation from individual elements to the spectral structure of the matrix. Nor does it replace fundamental techniques such as learning rate scheduling, weight decay, and gradient clipping.
Early validation focused mainly on small-scale models, where fewer training steps were observed to reach the same loss. Results at larger scales need separate verification and cannot be extrapolated directly.
In practice, a hybrid strategy is therefore common:
- Hidden-layer 2D weights: use the orthogonalized matrix optimizer;
- Embedding layers, output layers, normalization parameters, and biases: keep using Adam-style optimizers.
5. Deployment Checklist
- Parameter grouping: Partition parameters by tensor shape and module, and clarify which parameters follow the matrix path.
- Tune the learning rate separately: Suitable learning rates for the two optimizer types usually differ—do not directly reuse Adam’s configuration.
- Monitoring metrics: Beyond loss, track gradient norms, update norms, and per-group update magnitudes to catch numerical anomalies early.
- Interaction testing: Verify that combinations with weight decay, gradient clipping, and mixed-precision scaling behave as expected.
- Small-scale ablation first: Compare loss curves at the same training token count, and scale up only after confirming the benefit.
6. When It Applies
Orthogonalized matrix optimizers primarily address the memory pressure of optimizer states and, under certain conditions, convergence speed. If your bottleneck is data quality, model architecture, or activation memory, the improvement will be limited. Before adopting one, use memory profiling tools to confirm that optimizer states are indeed the dominant cost, then weigh the decision against the engineering constraints of your distributed training setup.
