Muon Optimizer: A Matrix-Based Approach to Solving GPU Memory Bottlenecks in LLM Training
This article explains how matrix-based optimizers like Muon address the GPU memory bottleneck in large language model training. It covers why optimizer states consume so much memory, how orthogonalized matrix updates differ from element-wise adaptive methods, what the memory savings enable, and a practical checklist covering learning rate configuration, small-scale comparison experiments, distributed strategy coordination, fallback switches, and observability. It also outlines the applicable boundaries and common pitfalls of this approach.
Muon Optimizer: A Matrix-Based Approach to Solving GPU Memory Bottlenecks in LLM Training
1. Where the Problem Starts: Optimizers Are Eating Your GPU Memory
When training models with extremely large parameter counts, an often underestimated fact is that what truly limits training scale is usually not the parameters themselves, but the optimizer states. Take mainstream element-wise adaptive optimization methods as an example: to maintain two statistics, the first moment and the second moment, for each parameter, you need to allocate two additional storage spaces in GPU memory, each the same size as the parameters. Under mixed-precision training, adding parameter copies and gradient copies on top of that, the optimizer states alone can occupy GPU memory on the order of tens of terabytes.
The chain reaction this brings is severe: the headroom available for batch size and context length is heavily compressed, engineers are forced to introduce more partitioning and recomputation, communication volume and implementation complexity rise in tandem, and the per-unit training cost is pushed up. In other words, GPU memory is not consumed by “computing” but by “storing.”
2. From Element-Wise to Matrix: A Fundamental Shift in Optimization Perspective
The implicit assumption of traditional adaptive optimizers is “element-wise optimization”: treating the weight matrix as a large number of mutually independent scalars, maintaining momentum and an adaptive step size separately for each element. This approach performs well on small and medium-sized models, but it overlooks a fact—the weight matrices in neural networks themselves carry geometric structure, with strong correlations between rows and columns.
The matrix-based optimization idea (represented by Muon in the industry) takes a different perspective: it treats a weight matrix of shape m×n as an indivisible high-dimensional geometric object, performs orthogonalization on the matrix as a whole after fusing the gradient and momentum, and then adds the result to the weights all at once. The direct benefits are: the optimizer state drops from “two element-wise statistics” to “one matrix momentum,” GPU memory usage decreases significantly; at the same time, the update direction becomes more regular, and the number of training steps often drops precipitously.
An intuitive analogy: element-wise optimization is like a group of iron balls each fighting on its own, requiring a separate rolling distance to be specified for each ball; matrix-based optimization first arranges the iron balls into a neat square formation, then advances them all together with a unified pace.
3. What Orthogonalization Actually Does
The goal of orthogonalization is to “align” the components in the update matrix that have different directions and vastly different scales, so that each singular direction receives a more balanced update magnitude. In engineering, costly exact decomposition is usually not performed; instead, iterative approximation is used (such as orthogonalization approximation based on matrix polynomial iteration), using a small number of matrix multiplications to approximate the result. The illustrative code below is only meant to show the calling form and does not represent any specific implementation:
# Pseudocode: the basic form of a matrix-based updatedef matrix_update(grad, momentum, beta, steps=5):buf = beta * momentum + (1 - beta) * grad # matrix-level momentum fusionupd = orthogonalize_approx(buf, steps) # iterative approximate orthogonalizationreturn upd# Parameter update: apply matrix-based updates only to 2D hidden-layer weightsfor name, p in model.named_parameters():if p.ndim == 2 and is_hidden(name):p.data.add_(matrix_update(p.grad, state[name], 0.95), alpha=-lr)else:p.data.add_(adam_like_step(p, state[name])) # other parameters keep the adaptive method
Three points worth noting in engineering:
- Enable it only for 2D hidden-layer weights. Embedding layers, output heads, normalization parameters, biases, and the like usually still keep the existing adaptive method; this kind of “hybrid optimizer” is currently the more reliable way to put it into practice.
- The number of orthogonalization iterations is a trade-off between precision and overhead. Too few steps make the update direction insufficiently regular, while too many spend the saved compute back, so it needs to be determined empirically according to model scale.
- Numerical stability depends on high-precision accumulation. Matrix multiplications and norm normalization are recommended to be done at higher precision to avoid overflow and jitter at low precision.
4. The GPU Memory Ledger: Where the Saved Space Goes
The value of matrix-based optimization is not just “saving GPU memory,” but converting the saved space into effective training throughput:
- Larger batches and longer contexts. The freed-up GPU memory can be directly used to increase the batch size or extend the sequence length, reducing the number of gradient accumulation steps and improving hardware utilization.
- Less partitioning and recomputation. When the state that fits on a single card becomes smaller, the partitioning granularity of pipeline parallelism and tensor parallelism can be coarser, and the communication proportion drops.
- A smoother scaling curve. The relationship between state memory and parameter count drops from “multiple copies” to “one copy”; at the trillion-parameter level, this coefficient difference is amplified into considerable resource savings.
It needs to be emphasized that the specific benefits are strongly correlated with model structure, parallelism strategy, and hardware bandwidth, and should be based on your own measured data rather than applying others’ conclusions.
5. A Practical Implementation Checklist
- Configure learning rates per layer. Matrix-based updates and element-wise updates have different effective step size scales, and usually require learning rates and warmup strategies to be set separately, to avoid a certain layer “running too fast.”
- Run small-scale comparison experiments first. Under the same compute budget, compare the number of steps and wall-clock time required for the target loss to reach the same level; this is the most credible evaluation method.
- Coordinate with the distributed strategy. Under tensor parallelism, orthogonalization needs to coordinate across the partitioned dimension, so pay attention to the choice of partitioning direction to avoid introducing extra high-frequency communication.
- Keep a fallback switch. If loss spikes appear early in training, you can temporarily switch back to the existing adaptive method to stabilize for a number of steps before switching back.
- Improve observability. Feed metrics such as gradient norm, update norm, and the condition number of the matrix before and after orthogonalization into logging services and monitoring alerts, making it easier to locate anomalies.
If the training task runs in the cloud, you can combine container platforms for elastic scaling, use object storage to hold checkpoints and datasets, and build a training observability system with logging services and monitoring alerts; the general capability categories offered by cloud vendors such as Baidu AI Cloud can serve as a reference direction when selecting infrastructure.
6. Applicable Boundaries and Common Pitfalls
Matrix-based optimization is not a panacea. For tasks with a small parameter count where element-wise adaptive methods are already sufficient for convergence, the gains from the modification are limited and instead add implementation complexity; for sparse update scenarios (such as ultra-large vocabulary embeddings), the cost-effectiveness of updating the matrix as a whole is also not high. Common pitfalls include: enabling matrix-based updates for all parameters across the board, ignoring the extra compute brought by orthogonalization iterations, and directly applying it to long-cycle training tasks without comparison experiments.
7. Summary
The evolution of optimizer design is essentially about “how to more efficiently decide which way the parameters should go under limited GPU memory and compute.” Treating the weight matrix as a whole and unifying the update direction with orthogonalization provides a practical path for ultra-large-scale training to reduce state memory and improve convergence efficiency. For engineering teams, the pragmatic approach is: use the two types of optimizers in a hybrid manner, determine hyperparameters with small-scale comparison experiments, and incorporate the key metrics of the training process into an observability system, then gradually scale up to the target scale.
