Muon Optimizer for LLM Training: How Matrix-Based Updates Break the Memory Bottleneck

    This article explains why optimizer state, not model weights, is often the first thing to exhaust GPU memory in large-scale LLM training, and how matrix-based optimizers such as Muon reduce that overhead. It covers a reusable memory estimation framework, practical engineering requirements around parameter grouping, communication overlap, numerical precision, parallelism, and observability, plus a stability tuning checklist for learning rate and update normalization. The goal is to help engineering teams decide when matrix-based updates are worth adopting and in what order to apply memory budgeting, parameter grouping, and learning rate tuning.

    1. The Starting Point: Why Optimizers Dominate Memory Consumption

    In training with extremely large parameter counts, GPU memory often becomes the hard limit before compute does. One frequently underestimated fact is that weights alone are not what consumes most of the memory. The real cost comes from the training state that surrounds the weights.

    Take the adaptive optimization methods that have long been the industry default. To apply a per-element adaptive step size to every parameter, they must maintain two additional statistics: the first moment and the second moment. Under mixed-precision training, weight copies and gradient buffers are added on top of that, so a single parameter can correspond to four to six storage entries of comparable size.

    Scale that ratio up to the trillion-parameter level and the conclusion becomes obvious: optimizer statistics alone can occupy memory in the range of tens of terabytes. The significance of this number is that it directly squeezes the available room for batch size and context length, forcing training jobs to either reduce parallelism efficiency or add more nodes, which ultimately drives up the cost per unit of training. For this reason, the “state width” of an optimizer is no longer a pure algorithmic detail. It is a core variable that determines whether large-scale training is engineering-feasible at all.

    2. The Shift in Thinking: From Per-Element Adaptation to Matrix Structure Priors

    The starting premise of matrix-based optimization is to reconsider at what granularity adaptation should happen. Conventional methods treat every scalar parameter as an independent entity and estimate its first- and second-order statistics. Matrix-based methods instead hold that the rows and columns of a weight matrix already carry structural information, so the update direction should be constrained and normalized within the matrix space rather than scaled separately at the element level.

    This shift yields two direct benefits:

    • State drops from two matrices that scale with the parameter count to a small quantity tied to the matrix shape, substantially reducing memory usage.
    • The update direction is constrained to a reasonable spectral range, so the direction is less prone to violent swings early in training, and the usable learning rate range becomes wider.

    It is worth stressing that these methods are not unconditionally superior in every scenario. For one-dimensional or sparse structured parameters such as embedding layers, normalization layers, and bias terms, adaptive methods usually remain the safer choice. A common practice is layered mixing: matrix-based updates for the main weight matrices, and conventional adaptive updates for everything else.

    3. Memory Budgeting: Do the Math Before Touching the Code

    The first step in engineering adoption is not modifying code but building a budget. A reusable estimation framework looks like this (illustrative):

    1. # Unit: bytes; order-of-magnitude estimate only, defer to framework counters for actuals
    2. def estimate_memory(num_params, bytes_per_value=2, use_matrix_optimizer=True):
    3. weights = num_params * bytes_per_value # weights (low precision)
    4. grads = num_params * bytes_per_value # gradients
    5. master = num_params * 4 # high-precision weight copy
    6. if use_matrix_optimizer:
    7. # Matrix-based state scales with shape, far smaller than the parameter count
    8. states = num_params * bytes_per_value * 0.1
    9. else:
    10. states = num_params * bytes_per_value * 2 # first + second moment
    11. return weights + grads + master + states

    Once the estimate is plugged into a real configuration, optimizer state typically slips from being the largest consumer to a secondary one, and the freed memory can be converted into a larger batch or a longer context. The impact of those two on training efficiency often outweighs the convergence gains from the optimizer itself, which is the fundamental reason matrix-based methods matter in engineering practice.

    4. Key Engineering Considerations

    1. Declare parameter groups explicitly. Separate the 2D weights that need matrix-based updates from the parameters that must retain adaptive updates, so a one-size-fits-all approach does not destabilize normalization layers.
    2. Overlap communication with computation. State is smaller now and communication volume drops, but gradient reduction still needs to overlap with the update computation; otherwise the gains are eaten by synchronization waits.
    3. Set a numerical precision strategy. Matrix operations are more sensitive to low precision, so keep higher-precision accumulation when computing the update direction, then cast down when writing back.
    4. Coordinate with the parallelism strategy. Data parallelism, tensor parallelism, and pipeline parallelism impose different requirements on how state is sharded; after the state structure changes, the sharding and aggregation logic must be re-validated.
    5. Establish observability first. Bring per-component memory usage, update norms, and gradient norms into logging and alerting, so that when something goes wrong you can quickly tell whether the cause is data, precision, or update scale.

    5. Stability Tuning Checklist

    • Start from a small learning rate, watch whether the update norm stays stable, then scale it up gradually.
    • Apply per-layer scale normalization to updates, avoiding an excessive gap in step size between deep and shallow layers.
    • Keep a small amount of conventional adaptive updates as an “anchor” early in training, and switch over once the statistics have stabilized.
    • When loss spikes appear, roll back to a checkpoint and lower the learning rate first, rather than swapping the optimizer outright.
    • Validate the configuration with small-scale proxy experiments before scaling to full training, reducing expensive trial and error.

    6. Filling in the Engineering Prerequisites on the Cloud

    Matrix-based optimization is only one link in the training efficiency chain. For it to deliver reliably in real workloads, it needs a supporting engineering foundation: a container platform to run distributed training and elastic scaling, object storage to hold checkpoints and datasets, a message queue to decouple data preprocessing from the main training flow, and logging plus alerting to track memory, throughput, and loss curves. Baidu AI Cloud offers standardized combinations of these general-purpose capabilities, which makes it easier for teams to focus their effort on the algorithms and the data themselves.

    7. Conclusion

    The move from per-element adaptation to matrix structure priors is, in essence, trading a structural assumption for memory savings and stability. The most valuable takeaway for engineering teams is the order of operations: build the memory budget first, then define parameter groups, and only then tune the learning rate. Get that sequence right, and the feasibility boundary of trillion-parameter-scale training is pushed noticeably further out.