Muon Optimizer Explained: Matrix-Level Updates and Practical Implementation

    Muon replaces element-wise adaptive updates with approximately orthogonalized matrix updates for hidden-layer weights. This article explains its motivation, momentum-based algorithm, optimizer-state memory savings, and Newton–Schulz implementation, then examines parameter grouping, distributed training, hyperparameter tuning, and validation against AdamW. The focus is on evaluating practical training efficiency rather than assuming that a theoretical memory advantage guarantees better results.

    1. The Starting Point: Optimizer Memory Overhead

    Optimizer states account for a substantial share of memory usage in large-model training. Common adaptive optimizers such as Adam and its decoupled weight-decay variant, AdamW, maintain two states for each trainable parameter: a first moment, $m_t$, that tracks an exponential moving average of gradients, and a second moment, $v_t$, that tracks an exponential moving average of squared gradients. Together, they determine each parameter’s adaptive step size.

    This design has a memory cost. With FP32 state storage, the two states require a total of 8 bytes per parameter. For a model with 1.6 trillion parameters, optimizer states alone require approximately:

    <br>1.6×1012×8B≈12.8TB<br><br>1.6\times10^{12}\times8\,\text{B}\approx12.8\,\text{TB}<br>

    That excludes model weights, gradients, and activations.

    Optimizer-state memory also constrains the training configuration. With a fixed memory budget, larger optimizer states leave less room for batch size and context length. Both affect throughput and training efficiency, making optimizer-state reduction a clear opportunity for improving large-scale training.

    2. Where Muon Came From—and What It Demonstrated

    Muon emerged in late 2024 during a small-model training speedrun competition. Participants aimed to train a small Transformer language model to a target loss using as little compute and time as possible. Many community efforts were still focused on carefully tuning Adam’s hyperparameters and learning-rate schedules.

    Muon’s key finding was that orthogonalizing updates for hidden-layer, two-dimensional weight matrices substantially reduced the number of training steps needed to reach the same loss. This suggested that changing the geometry of the update could be more effective than simply adjusting element-wise step sizes.

    That initial evidence came from very small models. It supported a promising experimental direction, not a fully established universal principle. The discussion below follows the same distinction.

    3. Two Views of an Update: Individual Elements or an Entire Matrix

    The central idea behind Muon becomes clearer when comparing two ways to treat a weight update.

    The element-wise view: Adam. Adam treats a weight matrix as a collection of scalar parameters. Each element has its own first- and second-moment estimates and its own adaptive step size. This approach is broadly applicable and straightforward to implement, but it does not explicitly account for structural relationships among matrix elements.

    The matrix-level view: Muon. Muon treats a weight matrix $W$ as a complete linear transformation. Conceptually, it takes the singular value decomposition of a momentum matrix:

    <br>M=UΣV⊤<br><br>M=U\Sigma V^\top<br>

    It then replaces the original update with the orthogonalized factor $UV^\top$. In this view, singular values are set to 1, preserving the update’s directional structure while discarding differences in magnitude across singular directions.

    The intuition is that gradient singular values are often unevenly distributed, with a few directions dominating the update. Orthogonalization gives the singular directions comparable update magnitudes, so weaker directions that may still matter are less likely to be overwhelmed.

    4. Algorithm and Memory Characteristics

    A Muon parameter update can be broken down into four steps:

    1. Compute the gradient $G_t$ on the current minibatch.
    2. Update the momentum buffer:

      <br>M<em>t=μM</em>t−1+Gt<br><br>M<em>t=\mu M</em>{t-1}+G_t<br>

      Here, $\mu$ is typically close to 1.

    3. Approximately orthogonalize $M_t$ to obtain an update matrix:

      <br>Ot≈UV⊤<br><br>O_t\approx UV^\top<br>

    4. Apply a shape-dependent scaling factor $s$ and update the weights:

      <br>W<em>t=W</em>t−1−ηs⋅Ot<br><br>W<em>t=W</em>{t-1}-\eta\,s\cdot O_t<br>

    A full SVD is expensive, so practical implementations commonly use Newton–Schulz iterations to approximate orthogonalization. These iterations consist of matrix multiplications, which are well suited to GPUs.

    The following illustrative implementation shows the basic process. It is not production-ready code.

    1. import torch
    2. def orthogonalize(G: torch.Tensor, steps: int = 5, eps: float = 1e-7) -> torch.Tensor:
    3. # Empirically chosen coefficients; values may differ across implementations.
    4. a, b, c = 3.4445, -4.7750, 2.0315
    5. X = G / (G.norm() + eps)
    6. transposed = X.size(0) > X.size(1)
    7. if transposed:
    8. X = X.T
    9. for _ in range(steps):
    10. A = X @ X.T
    11. B = b * A + c * A @ A
    12. X = a * X + B @ X
    13. return X.T if transposed else X
    14. @torch.no_grad()
    15. def muon_update(W: torch.Tensor, grad: torch.Tensor, buf: torch.Tensor,
    16. lr: float = 0.02, momentum: float = 0.95) -> None:
    17. buf.mul_(momentum).add_(grad) # Maintain a single momentum buffer.
    18. update = orthogonalize(buf) # Approximately orthogonalize the update.
    19. scale = max(1.0, W.size(0) / W.size(1)) ** 0.5
    20. W.add_(update, alpha=-lr * scale) # Update the weight matrix as a whole.

    Adam stores two states per parameter, whereas this procedure stores only one momentum buffer. For hidden-layer parameters assigned to Muon, optimizer-state storage is therefore approximately halved. The savings come from maintaining fewer states, not from an additional compression technique.

    5. Does Matrix-Level Orthogonalization Make Practical Sense?

    One objection to Muon is that real optimization is irregular: forcing updates into an orderly matrix structure can seem disconnected from how individual parameters need to change.

    This concern deserves consideration, but it conflates two different levels of the update. Muon does not require every matrix element to move by the same amount. Orthogonalization operates on the singular-value spectrum, bringing the magnitudes of updates along singular directions closer together. It does not force individual entries to have equal values. Element-wise differences remain, but they are redistributed through the matrix structure.

    A complete explanation of Muon’s effectiveness is still developing. One plausible hypothesis is that gradient singular-value spectra often have long tails. A few dominant directions can suppress updates along other directions, and orthogonalization reduces that imbalance. This is consistent with the small-scale results described above, but whether the same benefit holds at larger scales must be evaluated for the specific task and training configuration.

    Muon also has clear limitations:

    • Compute overhead: Iterative orthogonalization adds matrix multiplications, making the update more computationally expensive than simple element-wise operations.
    • Parameter coverage: The procedure targets two-dimensional matrices. One-dimensional parameters, such as biases and normalization parameters, cannot use it directly.
    • Distributed complexity: Orthogonalizing the complete update matrix requires access to the complete matrix. When parameters are sharded across devices, additional communication or specialized sharding strategies may be needed.

    6. Key Engineering Considerations

    6.1 Parameter Grouping

    In practice, Muon is generally not applied to every parameter. A common arrangement is:

    • Use Muon for two-dimensional hidden-layer weight matrices.
    • Use AdamW for token embeddings, the output layer or LM head, normalization parameters, and biases.

    This grouping reflects differences in parameter geometry. Rows or columns in embedding and output matrices often correspond to discrete vocabulary entries. The value of orthogonalizing those matrices as a whole is less clear, so retaining an adaptive optimizer is a more conservative choice.

    6.2 Distributed Training

    Distributed training often partitions parameters across devices through tensor parallelism or parameter sharding. Because full-matrix orthogonalization needs the complete matrix, an implementation must address several questions:

    • Should shards be gathered before orthogonalization, and how much communication would that require?
    • Can orthogonalization be approximated within each shard, and is the resulting approximation error acceptable?
    • How does the implementation interact with data, tensor, and pipeline parallelism?

    There is no single answer. These trade-offs depend on cluster bandwidth, model architecture, and the parallelization strategy.

    6.3 Hyperparameter Tuning

    Muon and AdamW learning rates generally should not be treated as interchangeable. Tune them separately.

    Weight decay, momentum, and the scaling factor also affect convergence. During tuning, keep other conditions fixed, change one variable at a time, and track loss against both the number of training tokens and elapsed wall-clock time.

    6.4 Validation

    Before committing to a large training run, validate the implementation in stages:

    1. Reproduce a baseline on a small model to check implementation correctness.
    2. Compare loss curves at a medium scale under the same token budget.
    3. Record optimizer-state memory usage and per-step time to assess end-to-end training efficiency.
    4. Evaluate downstream performance rather than relying only on training loss.

    7. Choosing Between Muon and AdamW

    The following comparison is qualitative. Quantitative results must be measured in the target environment.

    Dimension Adam / AdamW Muon for hidden-layer weights
    Optimizer states per parameter Two: first and second moments One: momentum
    Update granularity Element-wise Whole weight matrix
    Implementation complexity Low, with a mature ecosystem Higher; requires orthogonalization and parameter grouping
    Additional computation Relatively limited Extra matrix operations for iterative orthogonalization
    Distributed integration Mature, with straightforward state sharding Requires matrix-aware design
    Applicable parameters Broadly applicable Primarily two-dimensional hidden-layer weights

    Muon is worth evaluating in small-scale experiments when optimizer-state memory is a major bottleneck and the team can handle parameter grouping and distributed implementation work.

    If the training pipeline is already stable, memory capacity is sufficient, or implementation maturity and maintainability take priority, AdamW remains a conservative choice.

    In either case, the final decision should be based on measured training efficiency and downstream results—not on a single theoretical advantage.