Muon Optimizer: How Matrix Orthogonalization Reduces Memory Usage in LLM Training

    Muon handles weight matrices as a whole, orthogonalizing the momentum instead of tracking per-element adaptive states as Adam does. This article explains the optimizer-state memory problem, Muon's three-step update rule, why it cuts memory roughly in half for matrix parameters, a reference implementation with Newton-Schulz iteration, the geometric intuition behind it, and key engineering considerations for adoption.

    Where the Problem Lies: The Memory Cost of Optimizer States

    When training large models, GPU memory must simultaneously hold model weights, gradients, activations, and optimizer states. Among these, optimizer states are often underestimated.

    Take Adam as an example. It stores two additional variables for every trainable parameter: the first moment m_t (the running average of gradients) and the second moment v_t (the running average of squared gradients). These two variables determine the update direction and the per-parameter step size, respectively.

    Under a typical mixed-precision training setup, both momentum states are kept in fp32, requiring 8 bytes per parameter. For a model with 1.6×10^12 (about 1.6 trillion) parameters, these two states alone require:

    1.6×10^12 × 8 bytes ≈ 12.8 TB

    This does not even include other overhead such as fp32 master weights. The more memory optimizer states consume, the less room remains for batch size and context length. At very large training scales, this directly raises the per-sample training cost.

    As a result, the industry has been looking for methods that reduce optimizer states while preserving convergence quality. Muon has attracted attention in exactly this context.

    Adam’s Element-Wise Perspective

    Adam’s update can be summarized as computing an adaptive step size independently for each parameter element. For a 1000×1000 weight matrix, Adam treats it as one million separate scalars, each maintaining its own m and v and deciding how far to move on its own.

    This approach is simple to implement and easy to parallelize, but it embeds an assumption: the relationships between parameters can be ignored, and each coordinate can be optimized independently.

    For linear layers in neural networks, this assumption does not fully match reality. A weight matrix maps vectors from one space to another, and its rows and columns have structure. Breaking it apart into independent scalars discards that structural information.

    Muon’s Core Idea: Treat the Weight Matrix as a Whole

    Muon’s starting point is that the weight matrices of hidden layers should be treated as a whole, not as a pile of unrelated numbers. Its update process has three steps.

    Step one: compute the momentum. As in standard momentum methods, it maintains an exponential moving average of historical gradients:

    Mt = β × M{t-1} + G_t

    where G_t is the current gradient matrix and β is the momentum coefficient.

    Step two: orthogonalize the momentum matrix. Given the singular value decomposition M_t = UΣV^T, the orthogonalized result is UV^T. All singular values of this matrix equal 1, so it preserves the singular-vector directions of M_t while flattening the magnitude differences across directions.

    Step three: update the weights with the orthogonalized matrix:

    Wt = W{t-1} - η × O_t

    where O_t is the orthogonalized update and η is the learning rate.

    Performing a full SVD is expensive on GPUs, so practical implementations approximate orthogonalization with Newton-Schulz iteration. This iteration consists only of matrix multiplications, making it well suited for accelerators.

    Why Memory Usage Is Lower

    Adam needs to store two states, m and v, for every parameter. For matrix parameters, Muon only needs to store a single momentum buffer M_t; orthogonalization is computed on the fly at each step and does not require long-term storage.

    Therefore, for matrix parameters using Muon, optimizer state memory is reduced by roughly half. The saved memory can be used to increase batch size or extend context length.

    Note that Muon is typically applied only to two-dimensional hidden-layer weights. Embedding layers, output layers, normalization parameters, and biases are not suitable for matrix orthogonalization and still require AdamW or other methods. The overall memory savings therefore depend on the proportion of matrix parameters in the model.

    Reference Implementation

    The example below shows Muon’s core steps to clarify the data flow. A production implementation also needs to handle distributed sharding, mixed precision, and parameter grouping.

    1. import torch
    2. def newton_schulz(G, steps=5, eps=1e-7):
    3. # A commonly used set of quintic polynomial coefficients for
    4. # approximate orthogonalization
    5. a, b, c = 3.4445, -4.7750, 2.0315
    6. X = G / (G.norm() + eps)
    7. transposed = X.size(0) > X.size(1)
    8. if transposed:
    9. X = X.T
    10. for _ in range(steps):
    11. A = X @ X.T
    12. B = b * A + c * A @ A
    13. X = a * X + B @ X
    14. if transposed:
    15. X = X.T
    16. return X
    17. @torch.no_grad()
    18. def muon_step(params, momentum_buf, lr=0.02, beta=0.95, wd=0.0):
    19. for p in params:
    20. if p.grad is None:
    21. continue
    22. buf = momentum_buf[p]
    23. buf.mul_(beta).add_(p.grad) # Update momentum
    24. update = newton_schulz(buf) # Orthogonalize
    25. # Scale the update magnitude by matrix shape so it stays in a
    26. # similar range to updates from adaptive optimizers
    27. scale = max(1.0, p.size(0) / p.size(1)) ** 0.5
    28. p.mul_(1 - lr * wd) # Decoupled weight decay
    29. p.add_(update, alpha=-lr * scale)

    Three things are worth noting in this code. First, there is only one momentum buffer, which is the source of the memory savings. Second, the number of Newton-Schulz steps affects both orthogonalization accuracy and compute cost; usually a few steps are enough. Third, the shape-dependent scaling factor aligns the update magnitude; without it, the learning rate would need to be tuned separately for each type of parameter.

    Geometric Interpretation: Why Whole-Matrix Updates May Work

    Muon’s update can be understood as choosing the steepest descent direction under a spectral-norm constraint. The spectral norm measures the maximum factor by which a matrix can stretch a vector, and it better reflects the actual effect of a linear transformation than element-wise distance.

    From this perspective, Adam’s element-wise updates are like taking the steepest route separately along each coordinate axis, while Muon focuses on the matrix’s overall behavior as a transformation. After orthogonalization, all singular directions receive equal update magnitudes, so directions with originally small magnitude — which may correspond to rare features — are not completely overwhelmed by dominant directions.

    This interpretation helps explain Muon’s mechanism, but it does not mean Muon outperforms Adam on every task. The criteria remain actual training convergence speed and final results.

    Responding to the “Neat but Impractical” Critique

    An early criticism held that parameter updates should be adapted to local conditions, and that a uniform, whole-matrix step — while tidy — does not fit the complexity of the loss surface.

    This critique has some merit. Element-wise adaptivity does handle gradient scale differences across parameters, and whole-matrix updates do impose stronger constraints on certain directions. But the two methods emphasize different things; the relationship is not a simple matter of one being better than the other.

    A more reasonable way to evaluate is to check whether the update rule matches the model’s structure and loss geometry, and to validate with experiments. Muon initially achieved good training speed on small-scale models, which shows the idea deserves attention. At larger scales, however, its performance needs re-validation, including learning rate, weight decay, and training stability.

    Key Points for Engineering Adoption

    To introduce Muon in a real project, the following steps are recommended.

    1. Parameter grouping. Use Muon for two-dimensional hidden-layer weights, and AdamW for embeddings, output layers, normalization layers, and biases.
    2. Learning rate and scaling. Muon’s optimal learning rate differs from AdamW’s and needs a separate search. Scaling updates by matrix shape so their RMS is closer to AdamW’s can reduce re-tuning effort.
    3. Distributed training. Orthogonalization requires the complete gradient matrix. If parameters are sharded across multiple GPUs, extra communication is needed to gather the matrix, which affects communication overhead and the choice of sharding strategy.
    4. Number of iterations. More Newton-Schulz steps yield more precise orthogonalization but higher compute cost. Different step counts can be compared on a validation set.
    5. Metric monitoring. Beyond the loss curve, record per-step time, peak memory, and throughput to confirm that the optimizer’s benefits outweigh its extra compute cost.

    Summary

    Muon’s core change is treating weight matrices as a whole, replacing element-wise adaptivity with orthogonalized updates. It stores only one momentum buffer, significantly reducing optimizer-state overhead for matrix parameters.

    Its value depends on the specific task. If memory is the main training bottleneck, Muon is worth evaluating as a candidate. If the existing setup is already stable and efficient, the migration cost and benefit should be assessed first.