Advantages and Practical Guide to the Muon Optimizer in Large-Scale Training

    This article explains why optimizer state memory becomes a structural bottleneck in large-scale training and how matrix-based optimization with the Muon optimizer addresses it. It compares element-wise adaptive methods with matrix-level updates, breaks down the benefits in state memory savings, throughput, hyperparameter transferability, and checkpoint overhead, and outlines the trade-offs around orthogonalization cost, extreme matrix shapes, numerical stability, and ecosystem maturity. Engineering guidance covers approximate orthogonalization, parameter grouping, precision strategy, distributed sharding, and observability, followed by a decision checklist and general cloud infrastructure capabilities.

    1. The Starting Point: Optimizer State Is Eating Your Memory Budget

    When training large dense models, GPU memory usage breaks down into roughly four parts: the parameters themselves, gradients, optimizer state, and activations plus temporary buffers. The first two scale linearly with parameter count, while optimizer state is often the hidden heavyweight.

    Take element-wise adaptive methods as an example. To maintain an adaptive step size for every scalar parameter, you must store two extra states: the first moment and the second moment. In mixed-precision training, once you add copies of the parameters and gradients, the state portion alone can reach several times the parameter count. When you push model scale into the trillions of parameters, this overhead can balloon from tens of gigabytes to multiple terabytes, and the consequences cascade:

    • Batch size gets squeezed, the communication-to-computation ratio worsens, and cluster utilization drops;
    • Context length is constrained, making long-sequence tasks hard to run;
    • The number of parallelism dimensions is forced up, increasing pipeline bubbles and the synchronization cost of tensor parallelism;
    • Checkpointing and state recovery slow down, amplifying the cost of retraining after failures.

    For this reason, “reducing optimizer state overhead” is not a micro-optimization. It is a structural issue that directly determines training feasibility and unit cost.

    2. Two Optimization Paradigms: Element-wise Adaptive vs. Matrix-level Update

    The implicit assumption of traditional adaptive methods is that every element in a parameter matrix is an independent individual with its own learning rate and momentum. The advantages are generality, friendliness to sparse gradients, and insensitivity to the learning rate. The drawback is that state overhead scales strictly linearly with parameter count, and the structural information inside the parameter matrix is ignored.

    The matrix-based approach treats a layer’s weight as an indivisible high-dimensional geometric object. It still maintains momentum, but it no longer stores a second adaptive state per element. Instead, it takes the matrix fused from the gradient and momentum, orthogonalizes it, and then adds it to the weights in a single step. An intuitive analogy: the element-wise method is like a crowd taking a walk where each person acts independently and needs individual instructions; the matrix-based method first arranges the group into a formation and then moves in unison, with significantly lower coordination overhead.

    The intuition behind orthogonalization is this: if the “step size” in the matrix-norm sense is unconstrained, the update can be dominated by a few directions, causing the effective learning rate to drift across layers. Orthogonalizing the update matrix is like making all directions advance at a similar scale, so the actual update magnitude across layers becomes more comparable. This allows a larger global learning rate and reduces the need for per-layer tuning.

    It is worth stressing that orthogonalization is not “free.” It introduces extra matrix-decomposition-style computation, which is the main engineering cost of matrix-based methods. Mitigation is covered later.

    3. Breaking Down the Advantages: What You Actually Save

    1. Optimizer state memory is roughly halved or lower. Removing the element-wise second moment reduces optimizer state from “two states” to “one momentum,” and the absolute savings at ultra-large scale are substantial.
    2. Freed memory converts into effective throughput. The saved space can be used for larger batches or longer contexts, which often improves hardware utilization more than operator-level speedups alone.
    3. Better hyperparameter transferability. Matrix-level updates make the global learning rate act more consistently, narrowing the search space for cross-scale tuning and reducing the cost of large-scale trial and error.
    4. Potential for fewer convergence steps. On small- and mid-scale racing benchmarks, matrix-based methods often show fewer training steps; whether this advantage extrapolates linearly to trillions of parameters must be verified with measurements on your own cluster.
    5. Controllable compatibility with parallelism strategies. With only one momentum state, state sharding and recovery are lighter, and checkpoints are smaller.

    4. Costs and Constraints: Four “Buts” You Should Not Ignore

    First, orthogonalization itself is not cheap. Orthogonalizing an update matrix of shape m×n has far higher complexity than element-wise multiply-add; if every layer is solved exactly at every step, the overhead can eat up the gains.

    Second, layers with extreme shapes are unfriendly. When a matrix is extremely tall-and-thin or close to square, the numerical behavior of orthogonalization differs noticeably. One-dimensional parameters (such as biases and normalization scales) and gating vectors are usually unsuitable for matrix-based updates and need to keep the original element-wise path.

    Third, higher numerical stability is required. Iterative orthogonalization in low precision tends to lose orthogonality, requiring higher-precision intermediate accumulation and careful scaling.

    Fourth, ecosystem maturity. Existing distributed training frameworks, operator libraries, and debugging tools support element-wise adaptive methods more completely, while matrix-based methods often require you to fill in kernels and fault-tolerance paths yourself.

    5. Engineering Implementation

    5.1 Approximate Orthogonalization

    Exact orthogonalization is expensive, so practice commonly uses iterative approximation (such as matrix polynomial iteration to approximate the inverse square root), trading a few iterations for acceptable accuracy. The illustrative pseudocode below only expresses the flow and does not correspond to any specific product interface:

    1. # X: update matrix (m, n) fused from momentum and gradient
    2. def orthogonalize(X, steps=5):
    3. # Pre-scale with the Frobenius norm to keep the iteration numerically stable
    4. X = X / (X.norm() + 1e-7)
    5. for _ in range(steps):
    6. # Polynomial iteration approximating (X X^T)^(-1/2) X
    7. A = X @ X.T if X.shape[0] <= X.shape[1] else X.T @ X
    8. # Choose iteration coefficients based on the spectral range of A; a real implementation must branch by shape
    9. X = a * X + b * (A @ X)
    10. return X

    Key points: the number of iterations is usually a single digit; pre-scaling cannot be omitted; for matrices with more rows than columns, transpose before processing and transpose back afterward to avoid pitfalls in the singular value distribution.

    5.2 Parameter Grouping

    It is recommended to split parameters into three groups: matrix parameters go through matrix-based updates; one-dimensional parameters go through element-wise updates with lightweight adaptive state; embedding layers and output heads, due to sparse gradients and special shapes, usually form their own group with an independent learning rate.

    1. groups = [
    2. {"params": matrix_params, "use_matrix_update": True, "lr": 0.02},
    3. {"params": vector_params, "use_matrix_update": False, "lr": 1e-3},
    4. {"params": embed_params, "use_matrix_update": False, "lr": 5e-4},
    5. ]

    5.3 Precision Strategy

    Weights and gradients can be stored and communicated in low precision, but momentum accumulation, orthogonalization iterations, and norm scaling are best done in higher precision. When the loss shows spikes, prefer rolling back to the last stable checkpoint and lowering the learning rate rather than pushing through.

    5.4 Distributed Sharding

    Under tensor parallelism, weight matrices are often sharded, and orthogonalization needs aggregated information across shards. Options include: performing local approximate orthogonalization along the sharded dimension (low cost, slightly lower accuracy), or completing orthogonalization within each shard after parameter sharding and then synchronizing momentum. The former is simpler to implement; the latter has cleaner semantics. The trade-off must be decided based on measured parallelism.

    5.5 Observability

    Be sure to monitor: the orthogonality residual of the update matrix, per-layer update norms, the distribution of gradient norms, optimizer state memory usage, and the share of orthogonalization in single-step time. These metrics determine whether you can quickly locate where “the gains are being eaten up.”

    6. Decision Checklist: When Is It Worth Switching

    • The model is large and optimizer state has become the main memory item;
    • Cluster communication takes a high share, and increasing batch size would significantly improve utilization;
    • The team has the ability to maintain custom operators and kernels;
    • A stable baseline evaluation and regression mechanism is in place, able to verify convergence quality rather than just the loss curve.

    Conversely, if the model is small, iteration cycles are measured in hours, or there is no operator-maintenance capability, it is safer to first build the pipeline with a mature element-wise adaptive method.

    7. General Capability Mapping for Cloud Deployment

    Regardless of which optimizer you choose, large-scale training relies on several general infrastructure capabilities: high-performance block storage and object storage to hold checkpoints and datasets; a container platform for image-based environments and elastic scheduling; a message queue for task orchestration and decoupling data pipelines; and logging services plus monitoring and alerting to cover throughput, memory, failures, and slow-node diagnosis. The capabilities Baidu AI Cloud provides in these general categories can serve as a reference foundation for building a training platform; for specific specifications and quotas, refer to the official documentation.

    8. Conclusion

    The value of the matrix-based optimization idea is essentially replacing “per-parameter bookkeeping” with “whole-layer geometric updates,” using one controlled matrix operation to significantly compress optimizer state and achieve more consistent learning rate semantics. It is not a cost-free silver bullet: orthogonalization compute, extreme-shape handling, low-precision stability, and ecosystem maturity all require engineering investment. For trillion-parameter-scale training, the return on this investment often shows up in the freed batch and context space. It is advisable to first run strict controlled experiments at small and mid scale, confirm convergence quality and single-step overhead, then scale up gradually, and make orthogonality residual and state memory part of routine monitoring.