LLM Optimizers from SGD to Muon: Evolution and Limits

    This article reviews the evolution of optimizers for large language models, from steepest descent and momentum to adaptive methods such as AdaGrad, RMSProp, Adam, and AdamW. It then explains how Muon orthogonalizes 2D gradient matrices with a Newton-Schulz approximation and why the method still has limited scope. The key takeaway is that AdamW remains the mainstream choice, while Muon is a new approach still under validation and gradual adoption.

    The short conclusion first: AdamW is still the mainstream optimizer for training large language models. Muon is a new method with a limited scope of application and is still in the validation and adoption stage. This article reviews the evolution of optimizers in chronological order, then explains Muon’s approach, its mathematical intuition, and the practical boundaries to watch when adopting it.

    Three Problems Optimizers Must Solve

    During training, the loss function gives the height at the current position, and the gradient gives the steepest uphill direction. The optimizer decides which direction to move in and how far to go. In practice, it has to handle three things:

    1. Learning rate control. If the step size is too large, parameters may oscillate around the optimum or even diverge. If the step size is too small, training takes too long.
    2. Handling complex terrain. The loss surface has narrow valleys, saddle points, and flat regions. Looking only at the local gradient can make progress very slow.
    3. Efficient descent within a limited number of steps. For large models, every forward and backward pass is expensive, so the optimizer needs to use historical information to improve each step.

    From Cauchy to Polyak: Introducing Momentum

    In 1847, Cauchy proposed steepest descent, which moves in the opposite direction of the gradient at each step. The method is mathematically simple, but it only looks at the current gradient. In a narrow valley, it bounces back and forth between the sides and advances slowly.

    In 1964, the Soviet mathematician Boris Polyak proposed the heavy ball method. This method adds a velocity term to the parameter update so that the direction of historical gradients can accumulate:

    1. v = mu * v - lr * grad
    2. w = w + v

    Here v is velocity, and mu is the momentum coefficient, often around 0.9. Components perpendicular to the valley mostly cancel between adjacent steps, while components along the valley accumulate gradually, making the path smoother.

    Adaptive Learning Rates: From AdaGrad to AdamW

    In large models, gradient scales vary greatly across parameters. Bias terms often have small gradients, while some weight matrices may have gradients that fluctuate sharply. A single learning rate can hardly serve all these parameters well.

    AdaGrad was published in JMLR in 2011 and was the first method to maintain an independent learning rate for each parameter. It continuously accumulates squared historical gradients, so the learning rate becomes smaller and smaller, and training may stop early in the later stage. RMSProp was proposed by Hinton in course materials and uses an exponential moving average instead of accumulation, alleviating this problem. Adam was proposed in 2014, maintaining both a first moment (gradient mean) and a second moment (squared gradient mean), with bias correction:

    1. m = beta1 * m + (1 - beta1) * grad
    2. v = beta2 * v + (1 - beta2) * grad**2
    3. m_hat = m / (1 - beta1**t)
    4. v_hat = v / (1 - beta2**t)
    5. param -= lr * m_hat / (sqrt(v_hat) + eps)

    In 2017, Loshchilov and Hutter pointed out that mixing the L2 regularization term into the gradient in Adam is not equivalent to true weight decay. They proposed AdamW, which decouples weight decay from the gradient. Today, AdamW is one of the most common choices for training large language models.

    The cost of Adam-style methods is memory. Each parameter needs to store two states, so the optimizer state of a 10-billion-parameter model can consume a large amount of memory.

    How Muon Improves Update Direction with Matrix Orthogonalization

    Adam scales gradients element by element. Each value is processed independently, without considering which weight matrix it belongs to. The weights of linear layers in large models are 2D matrices, and there is structure between rows and columns. Element-wise scaling cannot exploit this structure.

    Muon’s approach is to orthogonalize the 2D gradient matrix after momentum accumulation, pulling its singular values closer to 1. In this way, the update magnitude is more uniform across directions and is not dominated by a few large singular values.

    Directly computing the SVD is expensive, so Muon usually uses Newton-Schulz iteration to approximate orthogonalization. The iteration contains only matrix multiplications and is suitable for GPU computation. The following code is a teaching illustration, not a production implementation:

    1. def newton_schulz_orthogonalize(G, steps=5, eps=1e-7):
    2. a, b, c = 3.4445, -4.7750, 2.0315 # empirical coefficients commonly used in community implementations
    3. X = G / (G.norm() + eps)
    4. transposed = X.shape[0] > X.shape[1]
    5. if transposed:
    6. X = X.T
    7. for _ in range(steps):
    8. A = X @ X.T
    9. B = b * A + c * A @ A
    10. X = a * X + B @ X
    11. if transposed:
    12. X = X.T
    13. return X
    14. # Use Muon only for 2D hidden-layer weights
    15. for p in params:
    16. if p.ndim == 2 and is_hidden_weight(p):
    17. buf.mul_(momentum).add_(p.grad)
    18. O = newton_schulz_orthogonalize(buf)
    19. O = O * 0.2 * max(p.shape) ** 0.5 # scale so the update magnitude is close to AdamW
    20. p.data.add_(O, alpha=-lr)
    21. else:
    22. adamw_step(p) # embedding layers, output heads, normalization parameters, and the rest

    Practical Boundaries

    AdamW remains the mainstream choice for large language model training. Muon is a new method with limited applicability and is still being validated and promoted. In implementation, Muon is used only for 2D hidden-layer weights, while embedding layers, output heads, normalization parameters, and other parameters still use AdamW. Newton-Schulz iteration approximates orthogonalization to avoid the high cost of direct SVD. These are the boundaries to check before adopting Muon in practice.