Muon Optimizer for LLM Training: Advantages and Engineering Guide

    This article explains why optimizer state, rather than parameter count or data volume, often limits large-scale pretraining. It traces the shift from element-wise adaptive optimizers to matrix-based updates such as Muon, compares their mechanics, and outlines the engineering work required to make them practical: hybrid usage, distributed adaptation, and numerical stability. Readers will also find deployment recommendations and risk controls for testing matrix-based optimization at scale.

    1. The Starting Problem: Optimizers Are Eating the Training Budget

    In large-scale pretraining, cost is usually attributed to parameter count and data volume. In practice, what limits the size of a single experiment is often the optimizer state.

    For a long time, element-wise adaptive methods have been the default choice. They maintain two statistics per parameter—a first moment and a second moment—and trade per-coordinate step scaling for more stable convergence. The price of this design is GPU memory.

    Take mixed-precision training as an example. Weights and gradients already take up considerable space, and the two moment states are typically stored at the same precision as the master weights. For a model on the order of a trillion parameters, the state variables alone can reach the tens-of-terabytes range, requiring sharding and offloading just to fit. The consequences are severe: available batch size and context length are compressed, communication and read/write amplification increase, and experiment iteration slows down.

    This is exactly where matrix-based optimization adds value. Instead of keeping separate accounts for every element, it treats each layer’s weight as a single geometric object and replaces per-coordinate scaling with matrix-level updates, reducing state overhead to roughly the same order as momentum.

    2. How the Method Evolved: From Racing Experiments to Engineering Readiness

    This line of thinking did not originate in ultra-large-scale training. It first appeared in model racing scenarios, where the goal was to reach a target loss with the least compute. While most researchers were tuning element-wise adaptive methods, some turned to orthogonalizing hidden-layer gradients and observed a significant reduction in the training steps needed to reach the same loss, setting new records in small-scale races at the time.

    The skepticism that followed was straightforward: what works at small scale does not necessarily work at large scale. Matrix-based updates involve matrix decomposition or iterative approximation, and the extra operators can become a bottleneck in parallel environments spanning thousands of GPUs. Meanwhile, structures such as attention and embedding layers are not well suited to uniform matrix treatment. Moving from “it runs” to “industrial-grade” therefore requires three engineering pieces:

    • Hybrid usage: apply matrix-based updates only to hidden-layer linear weights, and keep adaptive methods for the remaining parameters.
    • Distributed adaptation: align the update computation with sharding strategies and communication primitives to avoid extra full synchronization.
    • Numerical stability: replace high-precision decomposition with low-precision iterative approximation, combined with gradient clipping and loss scaling.

    3. How They Compare: Element-Wise Scaling vs. Matrix-Level Updates

    Element-wise methods treat a weight matrix as a large set of independent scalars. Each maintains its own history of gradients and squared gradients, and the step size is determined coordinate by coordinate.

    Matrix-based methods orthogonalize the matrix formed by combining the gradient and momentum, producing an update matrix with a single direction and controlled scale that is applied to the weights in one shot.

    An intuitive analogy is the difference between a queue and skirmishers: the former requires issuing instructions to each member individually, while the latter emphasizes overall formation and a unified rhythm. Geometrically, orthogonalization constrains the update to an approximate unit sphere, keeping the scale close across directions and reducing oscillation caused by scale imbalance in individual directions.

    Illustrative pseudocode (structure only, not a specific implementation):

    1. # g: gradient matrix of the current layer; m: momentum state
    2. m = beta * m + (1 - beta) * g
    3. u = orthogonalize(m) # iterative approximation, avoids high-precision decomposition
    4. w = w - lr * u # single-scale update

    4. What the Unique Advantages Mean for Engineering

    • Lower memory usage: state drops from two copies to one, and the freed space can be converted into longer context and larger batches.
    • Controllable update scale: orthogonalization naturally constrains the update norm, making the method relatively less sensitive to the learning rate and reducing tuning cost.
    • More communication-friendly: less state means less data to synchronize across shards, easing cross-node bandwidth pressure.
    • Compatible with parallelism: the matrix view naturally fits intra-layer tensor partitioning, making elastic scaling easier on containerized training platforms.

    5. Deployment Recommendations and Risk Control

    Start with controlled experiments at small to medium scale. Fix the data and initialization, switch only the update method, and observe the steps needed to reach the target loss and the peak GPU memory. Then scale up gradually to the target size, focusing on loss spikes, the distribution of gradient norms, and iterative approximation error.

    On the engineering side, include optimizer state in capacity planning, use object storage for checkpoint persistence, and track memory and throughput metrics with logging and monitoring alerts. General-purpose container platforms, object storage, and monitoring and alerting capabilities from Baidu AI Cloud can serve as a general foundation for running this kind of experiment.

    Overall, the significance of matrix-based optimization is not just saving memory. It reframes weight updates from a scalar-statistics problem into a geometric one, providing a new tuning knob for the stability and cost structure of ultra-large-scale training.