Breaking the Memory Barrier in Large-Scale Training: How the Muon Optimizer Works and How to Use It
This article explains why optimizer state, not model weights, is often the first thing to exhaust GPU memory in large-scale pretraining, and how matrix-based optimization with the Muon optimizer addresses it. You will see how moving from element-wise to matrix-level updates compresses state from two moment buffers to a single momentum matrix, how orthogonalization shapes update directions, and what the memory savings look like at the trillion-parameter scale. It also covers a schematic implementation, the key engineering constraints around layer selection, distributed sharding, numerical stability, learning-rate retuning and observability, plus practical criteria for deciding when switching is worth it.
1. Where the Problem Starts: Optimizers Are Eating Your Memory Budget
In large-scale pretraining, GPU memory is usually the first resource to hit the ceiling. A lot of attention goes to parameter count, but the fact that often gets overlooked is this: what determines whether training can run at all is frequently not the weights themselves, but the extra state an optimizer maintains in order to “remember history.”
Element-wise adaptive optimizers have long been the default choice. The core idea is to maintain two statistics per parameter, a first moment and a second moment, and to scale each coordinate independently using the first- and second-order information from historical gradients. The upside is robustness: such designs are insensitive to the learning rate and require almost no tuning. The cost is that memory usage multiplies.
Take mixed-precision training as an example. One copy of the weights, one copy of the gradients, and two moment estimates add up to optimizer state that can reach several times the parameter count on its own. Once a model crosses into the trillion-parameter range, this overhead balloons to the tens of terabytes, directly squeezing the room available for batch size and context length. Those two variables are exactly what drive throughput and long-range modeling capability, so training costs climb and experiment iteration slows down.
A natural engineering question follows: does an optimizer have to remember history coordinate by coordinate? If the optimization granularity could be raised from scalars to matrices, what would happen to the cost structure of memory and compute?
2. From Element-Wise to Matrix-Level: A Shift in Optimization Granularity
Element-wise optimization rests on an implicit assumption: every element in a parameter matrix is an independent individual whose history should be recorded and scaled separately. Matrix-based optimization takes a different view: a weight matrix of shape m×n is an indivisible high-dimensional geometric object, and the update direction should be constrained uniformly across the whole matrix.
This shift in perspective has two immediate consequences.
First, state can be compressed substantially. Matrix-based methods typically maintain only one momentum matrix instead of storing a second moment for every element, cutting state memory from two copies to one. At extreme scale, that is an enormously significant structural saving.
Second, the update acquires geometric meaning. A common approach is to orthogonalize the matrix obtained by fusing the gradient with the momentum, producing an orthogonal (or column-orthogonal) matrix that is then added to the weights as a whole. The intuition: rather than letting updates concentrate too heavily in certain directions, energy is spread as evenly as possible across directions, preventing a few singular directions from dominating the training trajectory.
An analogy of iron balls rolling downhill helps. Element-wise methods are like a crowd of iron balls each fighting its own battle, requiring a separate step size and direction for every ball: precise, but with extremely high coordination cost. Matrix-based methods first arrange the balls into a formation and move them forward in unison. The former is a scattered walk, the latter a marching column, and the difference in command efficiency is obvious at a glance.
It is worth stressing that orthogonalization is not “smarter second-order information.” It does not explicitly estimate curvature; it improves the conditioning and directional distribution of updates through a structural constraint. Understanding this is what lets you set correct expectations for where the gains stop.
3. How Orthogonalization Works in Practice: A Schematic Implementation
The core steps of a matrix-based update can be abstracted as: momentum accumulation → removal of cross terms → orthogonalization → write back with a scaling factor. The pseudocode below only illustrates the computation flow and does not map to any specific framework API:
# Schematic pseudocode: matrix-based orthogonalized updatedef matrix_update(W, G, buf, lr, beta):# 1) Momentum accumulation (a single state buffer)buf = beta * buf + (1 - beta) * G# 2) Optional: suppress cross-coupling terms in the momentum matrix# A common approach subtracts transpose-related terms to make# the matrix closer to symmetric / decorrelatedbuf = buf - 0.5 * cross_term(buf)# 3) Orthogonalization: iteratively approximate (X X^T)^(-1/2) XX = orthogonalize(buf, steps=5)# 4) Scale uniformly and write back to the weights as a wholeW = W - lr * scale(X, shape=W.shape)return W, buf
In engineering practice, an exact orthogonal decomposition is rarely performed. Instead, a few iterations (for example, 3 to 5 Newton-style steps) are used to approximate it, because the matrix-multiplication structure is very friendly to tensor cores and the actual cost is far lower than a general-purpose decomposition of comparable accuracy.
Another key detail is the scaling factor. The magnitude of elements in the orthogonalized matrix depends on the shape of the original matrix. Without normalization by fan-in/fan-out, layers of different shapes end up with inconsistent update scales, and training diverges very easily in the early stages. In practice, the scaling is usually tied to the free dimensions of the matrix so that update magnitudes are comparable across layers.
4. Why It Saves Memory: A Clear Accounting
Break the overhead apart and the source of the difference is unambiguous:
- Element-wise adaptive optimizer: two state buffers per parameter, a first moment and a second moment;
- Matrix-based optimizer: one momentum state per parameter;
- Intermediate matrices in the orthogonalization step are temporary memory that can be reused at the peak of the compute pipeline and do not accumulate across training steps.
At trillion-parameter scale with mixed precision enabled, reducing the state term from two copies to one typically saves memory on the order of tens of terabytes. That budget can be converted directly into a larger micro batch, a longer context, or less activation recomputation, the last of which trades time for memory. Saved memory reduces the recomputation ratio, which improves throughput at the same time.
Put differently, a structural saving at the optimizer level gets amplified along the chain of memory → batch/sequence length → parallelism strategy → throughput. That is why it carries more leverage than tuning individual operators.
5. Key Constraints for Engineering Adoption
Matrix-based optimization is not an unconditional replacement. Evaluate the following before adopting it.
1) Which layers to apply it to. Empirically, the clearest gains are on the two-dimensional weights of hidden layers; embedding layers, output heads, and normalization parameters usually keep element-wise adaptive updates, forming a hybrid optimizer structure. For sparse or very large vocabulary settings, the robustness of element-wise methods on long-tail updates still has value.
2) Compatibility with distributed sharding. Once weights are split by tensor parallelism or parameter sharding, each device holds only a block of the matrix, while orthogonalization needs global information. Viable options include local approximation along the sharded dimension, periodic aggregation of statistics, or restricting orthogonalization to the local block and accepting some approximation error. An explicit tradeoff between communication cost and update quality is required here, and small-scale experiments should verify whether convergence is affected.
3) Numerical stability. In low precision, iterative inversion amplifies errors easily. Common practice is to accumulate in higher precision during orthogonalization, keep a higher-precision master copy of the weights, and use a deterministic accumulation order when reducing gradients, avoiding irreproducible drift across different parallelism configurations.
4) Coupling with the learning-rate schedule. Orthogonalization changes the scale distribution of updates, so the existing learning rate and warmup settings usually need recalibration. A small-scale learning-rate sweep first, then scaling up to the target size, is recommended, so an optimizer problem is not misdiagnosed as a data or parallelism problem.
5) Observability. Before rollout, bring gradient norm, update norm, orthogonalization residual, and the per-layer ratio of update scales into monitoring and alerting. A residual that keeps climbing usually means too few iterations or insufficient precision.
6. Choosing Wisely: When Switching Is Worth It
The decision criteria come down to three points. First, whether parameter scale has already made optimizer state the dominant memory consumer. Second, whether the model body consists largely of two-dimensional dense weights. Third, whether the team has the capability for distributed debugging and numerical monitoring. When all three hold, the gains from switching are usually most visible.
Conversely, if the model is small, memory is plentiful, or the structure is dominated by sparse lookups, a mature element-wise adaptive optimizer remains the safer choice: tuning costs are low and community experience is deep, so there is no need to take on extra uncertainty for the sake of structural elegance.
In cloud practice, the optimizer switch can be run as a gradual, rollback-capable experiment: validate the convergence curve on a small model first, then scale up step by step, keeping the old configuration as a control baseline. The supporting pieces are the observability chain formed by container platform scheduling, object storage for weight and checkpoint persistence, and logging plus monitoring and alerting.
7. Summary
The essence of optimizer memory overhead is a design choice about how much history to keep per coordinate. Raising optimization granularity from scalars to matrices, replacing two moment estimates with one momentum matrix plus an orthogonalization constraint, is a valuable engineering lever in large-scale training: the memory it frees is amplified along the parallelism and throughput chain, while the better directional distribution of updates improves training stability. It is not a master key, though. Layer selection, distributed sharding, numerical precision, and learning-rate recalibration can each eat the gains if handled poorly. Treating it as a systems engineering change that demands rigorous validation, rather than a one-line configuration swap, is the right way to adopt it.
