How to Choose an Optimizer for Large Language Model Training: From SGD to Muon
Choosing the right optimizer is one of the most consequential engineering decisions in large-scale model training. This article explains what optimizers actually do, traces their evolution from plain SGD through momentum and adaptive methods like AdamW to matrix-oriented optimizers such as Muon, and gives a practical starting point: prefer AdamW with decoupled weight decay. It covers learning-rate control, the real structure of high-dimensional non-convex loss surfaces, per-parameter updates, weight decay and parameter grouping, plus how to run baselines, ablations, monitoring, and rollbacks. It also includes a comparison table, an engineering checklist for selection and tuning, and answers to common questions.
1. The Short Answer: How Do You Choose an Optimizer for LLM Training?
If you just want a solid engineering starting point, the answer is not complicated: prefer AdamW with decoupled weight decay, combined with warmup, cosine learning-rate decay, gradient clipping, and parameter grouping. Only after small- and mid-scale ablation studies show stable gains should you consider trying a matrix-orthogonalization optimizer like Muon on the two-dimensional weight matrices of hidden layers.
But one point must be emphasized: there is no universally optimal optimizer. Large-model training is not a single-point problem. It is simultaneously affected by model architecture, data distribution, batch size, learning-rate scheduling, numerical precision, and memory and communication costs. Choosing an optimizer is not about “switching to a more advanced-sounding name”; it is an engineering decision that revolves around three things:
- Direction stability: Is the update direction being pulled off course by noise, gradient spikes, or ill-conditioned curvature?
- Step-size control: Do different layers and different parameters get an appropriately scaled step?
- System recoverability: When a loss spike, gradient-norm explosion, or NaN occurs, can you quickly locate the problem and recover?
So this article does not aim to pile up concepts. Instead, it follows one clear thread to answer: what an optimizer is, how it evolved, how to choose one, how to tune it, and how to debug it.
2. What Problem Is an Optimizer Actually Solving?
When training a neural network, we typically hold two pieces of core information:
- The loss function: something like the “altitude” of your current position, indicating how far the model still is from the target;
- The gradient: obtained through backpropagation, like the slope detected under your feet, telling you which way might lead downhill.
The optimizer is the “walking strategy”: it decides which way to step next, how big the step should be, and whether to keep moving along the historical direction.
At minimum, a competent optimizer has to handle three types of problems.
1. Dynamic control of the learning rate
Too large a step can overshoot the valley, causing the loss to oscillate or even diverge; too small a step makes convergence slow and wastes compute. The ideal state is to take big strides in flat regions and careful small steps in steep regions or near the valley bottom.
2. Ill-conditioned structure in high-dimensional non-convex training
Early popular explanations often said the loss surface is full of “small pits” of local minima. But in high-dimensional deep-network training, a more accurate statement is: local minima are usually not the main bottleneck; saddle points, plateau regions, and ill-conditioned curvature are far more common.
- Saddle points: some directions look like uphill, others like downhill;
- Plateau regions: gradients are tiny and parameters barely move;
- Ill-conditioned curvature: curvature varies drastically across directions, so a uniform step size tends to trade one problem for another.
Mechanisms such as momentum, stochastic noise, and adaptive scaling can help the model pass through these regions faster, but they are not mathematical theorems that guarantee escape. If the stochastic noise is too small, the model may stay stuck near a saddle point for a long time; if it is too large, it can break convergence stability.
3. Differentiated updates for parameters
The gradient scales of different layers and parameters can differ by several orders of magnitude. Embedding layers, normalization layers, the weights of attention and MLP, and the output layer do not have the same sensitivity to learning rate and regularization strength. A single global learning rate is often not optimal.
3. From Gradient Descent to SGD: The Physical Flaw of Naive Updates
The idea of gradient descent can be traced back to optimization research in the 19th century; the “stochastic approximation” idea in stochastic gradient descent (SGD) was mainly established by mid-20th-century work such as Robbins-Monro. The “mini-batch SGD” used to train large models today is, in essence, using sampling noise to approximate the full-batch gradient.
The most naive SGD update can be written as:
param = param - learning_rate * grad
Its strengths are that it is simple, intuitive, and easy to implement. But it also has clear weaknesses.
You can understand standard gradient descent as a massless, inertia-free particle sliding over a surface. It can accelerate instantly and stop instantly. That is not physically natural, and it makes training tend to bounce back and forth repeatedly in canyon-like terrain.
Specific problems include:
- Easy oscillation along steep directions;
- No ability to accelerate along flat directions;
- Using the same learning rate for different parameters, making it hard to adapt to scale differences;
- Higher sensitivity to mini-batch gradient noise, which easily produces a jittery training curve.
SGD is still the foundation for understanding optimizers, but in the engineering practice of large-model training, pure SGD is often not the first-choice baseline, especially when the model structure is complex and hyperparameter tuning is expensive.
4. The Next Step in Evolution: Momentum, Giving the Optimizer “Inertia”
One of the key people to break the “massless particle” assumption was the mathematician Boris Polyak. In 1964, in his optimization research, he proposed the Heavy Ball Method: if you give the particle “mass” and “inertia”, it will not turn around immediately because of a sudden change in local slope, but will keep moving along the historical trend.
This is the origin of the modern idea of Momentum.
A common formulation is:
velocity = beta * velocity + gradparam = param - learning_rate * velocity
Here beta is the momentum coefficient, commonly around 0.9, meaning it retains about 90% of the historical velocity.
The main benefits of momentum include:
- Suppressing oscillation: In the transverse direction of a canyon, positive and negative gradients tend to cancel each other, while along the longitudinal true-descent direction, gradients keep accumulating;
- Accelerating through flat regions: If multiple batches point in a consistent direction, the velocity keeps growing;
- Helping cross shallow pits and saddle points: The impulse from inertia can sometimes carry parameters past a brief low-gradient region.
But momentum is not a cure-all. It can also overshoot the valley because the historical velocity becomes too large, making training unstable. In practice, it is therefore often combined with gradient clipping:
if grad_norm > max_norm:grad = grad * (max_norm / grad_norm)
The role of gradient clipping is to limit abnormal amplification of a single-step update. It is especially important with large batches, mixed precision, and in the early training stage.
Note that the momentum coefficient and the learning rate are coupled. If you increase beta, more historical velocity accumulates and the effective step size changes; in that case you usually cannot change only the momentum and must re-tune the learning rate. Otherwise you easily get the ambiguous situation where “the config changed, but training did not clearly get worse or better.”
5. The Next Step in Evolution: Adaptive Learning Rates and AdamW
Momentum solved the direction-smoothing problem of “which way to go”, but it did not answer “how far should each parameter go?” Adaptive-learning-rate methods give the answer: dynamically adjust the step size for each parameter based on its own historical gradient scale.
Adam is a representative of this class of methods. It maintains both a first moment and a second moment:
- First moment: the exponentially weighted moving average of the gradient, used to smooth the direction;
- Second moment: the exponentially weighted moving average of the squared gradient, used to estimate the scale of that parameter and thereby scale its learning rate individually.
The conceptual update is as follows:
m = beta1 * m + (1 - beta1) * gradv = beta2 * v + (1 - beta2) * grad * gradm_hat = m / (1 - beta1 ** t)v_hat = v / (1 - beta2 ** t)param = param - learning_rate * m_hat / (v_hat.sqrt() + eps)
A few key points here:
tis the update step count1 - beta ** tis used for bias correction. Becausemandvare initialized to 0, the estimates are too small early in training; bias correction makes the early updates more reasonable.epsis for numerical stability
It prevents the division from blowing up when the second moment is close to 0. The common value is1e-8. In mixed-precision training, if the gradient or second moment underflows or overflows, too small anepscan cause abnormal updates; in that case you can evaluate whether to adjustepsto a safer range, for example near1e-6, but this must be confirmed through experiments.Adam is relatively robust to hyperparameters
Common defaults arebeta1=0.9,beta2=0.999,eps=1e-8. This makes it very practical for prototype validation and small- and mid-scale training.
But in large-model training, Adam is often further evolved into AdamW. The key difference lies in weight decay.
In the original Adam, L2 regularization is usually added to the gradient:
grad_with_l2 = grad + weight_decay * param
and then scaled by the second moment. This means the effective strength of weight decay is affected by the historical gradient scale and is not necessarily equivalent to truly decoupled weight decay.
AdamW instead decouples weight decay from the gradient update and applies it directly to the parameters:
param = param - learning_rate * adam_updateparam = param - learning_rate * weight_decay * param
This formulation makes the regularization strength more controllable and better aligned with modern large-model training practice. So large-model training usually prefers AdamW over a simple Adam + L2.
Parameter grouping also needs engineering attention. A common approach is:
- Embedding layers: usually a lower learning rate or weaker weight decay;
- Output layer: decided by the task; a classification head or a language-model output layer may need its own learning rate;
- Normalization layers: such as LayerNorm and RMSNorm, usually with weight decay disabled;
- Bias parameters: usually with weight decay disabled;
- Hidden-layer matrix weights: the main target for tuning learning rate and regularization strength.
These recommendations cannot be copied blindly; they must be validated with ablation studies that account for model scale and data volume.
6. The Next Step in Evolution: Matrix-Oriented Optimizers, Using Muon as an Example
A direction worth watching in recent years is re-examining “how to apply structural processing to the update itself”. Optimizers in the class represented by Muon propose: for two-dimensional weight-matrix parameters, first orthogonalize the momentum or update matrix, then use it for the parameter update.
A simplified sketch is as follows:
momentum = beta * momentum + gradupdate = newton_schulz_orthogonalize(momentum)param = param - learning_rate * update
Here newton_schulz_orthogonalize is usually approximated through Newton-Schulz iterations, with the goal of making the orthogonal structure of the update matrix closer to the ideal state.
Intuitively, orthogonalization flattens the singular values in the update matrix, making the update more balanced across directions and avoiding domination by a few principal directions. This differs from Adam’s “element-wise scaling”: Adam mainly looks at each coordinate’s own historical gradient scale, whereas Muon-type methods try to regulate the update direction at the level of matrix structure.
These methods are worth attention, but engineering use requires caution. You generally need to follow these boundaries:
Usually used only for two-dimensional weight matrices in hidden layers
For example, weight matrices in attention layers and MLP layers. Embedding layers, output layers, normalization layers, and one-dimensional parameters usually remain better served by element-wise methods.The learning rate needs to be re-tuned
Muon’s update scale differs from Adam’s, so you cannot directly reuse AdamW’s learning rate. You need a grid search based on matrix dimensions, parameter count, or empirical scaling rules.The number of orthogonalization iterations needs experimental validation
Too few Newton-Schulz iterations gives an insufficient approximation; too many increases the compute overhead. A common approach is to compare different iteration counts on a small model and observe convergence speed, stability, and additional compute cost.Numerical stability deserves close attention
Under mixed precision, matrix operations can produce numerical errors. It is advisable to monitor update norm, gradient norm, weight norm, and loss spikes, and if necessary keep fp32 master weights or compute key statistics in higher precision.Do not blindly replace everything
Muon is better suited as a local experimental component, used in combination with AdamW or as a replacement in some layers, rather than a default replacement for all optimizers.
7. Engineering Checklist: Selection, Tuning, and Debugging
The table below can serve as a scan-style checklist.
| Optimizer | Typical use cases | Key hyperparameters | What to monitor | Risks and rollback strategy |
|---|---|---|---|---|
| SGD | Simple models, small data, clear convergence curves | Learning rate, momentum, weight decay | Gradient norm, loss curve | If convergence is slow or oscillating, lower the learning rate and add warmup |
| Momentum | Vision models, tasks with relatively stable gradient directions | Learning rate, beta, gradient-clipping threshold | Gradient norm, update norm | If overshooting or oscillating, lower beta or the learning rate |
| Adam | Fast prototyping, small- and mid-scale experiments | beta1, beta2, eps | Gradient norm, loss spike | If decay behaves abnormally, switch to AdamW or use parameter grouping |
| AdamW | Mainstream baseline for large-model training | Learning rate, weight decay, beta, eps | Gradient norm, update norm, loss spike | Check parameter grouping, learning-rate scheduling, and gradient clipping |
| Muon | Experiments on two-dimensional hidden-layer weight matrices | Iteration count, learning-rate scaling, eps | Update norm, gradient norm, loss spike | If numerically unstable or gains are insufficient, roll back to AdamW |
In practice, you can follow this action list:
1. Baseline stage
First fix the data, model structure, batch size, learning-rate schedule, and random seed, and get a baseline running with AdamW. You need to record:
- Final loss and validation metrics;
- Learning-rate curve;
- Gradient norm;
- Update norm;
- Weight norm;
- Whether loss spikes occurred;
- Whether weight decay is correctly configured per parameter group.
2. Ablation stage
Change only one key variable at a time. For example:
- With model and data fixed, compare AdamW and Muon;
- With the optimizer fixed, compare different learning rates;
- With the learning rate fixed, compare different gradient-clipping thresholds;
- With structure fixed, compare parameter-grouping strategies.
Each set of experiments should record at least: config, learning rate, warmup steps, weight decay, gradient-clipping threshold, training curves, peak memory, and time per step.
3. Monitoring stage
In large-model training, looking only at loss is not enough. It is advisable to monitor at the same time:
- Gradient norm: whether it suddenly increases;
- Update norm: whether parameter updates are abnormally amplified;
- Loss spike: whether a spike appears and fails to recover;
- Learning rate: whether it is consistent with the scheduler;
- Weight decay: whether it is wrongly applied to layers that should not be regularized;
- Numerical state: whether inf, nan, or mixed-precision overflow appears.
4. Rollback stage
Keep a stable checkpoint before training. If any of the following occurs, prioritize rollback or scaled-down investigation:
- A loss spike persists for several consecutive steps without recovery;
- Gradient norm exceeds its historical average by several times;
- Update norm is abnormally amplified;
- Validation metrics keep deteriorating;
- Weight norms of some layers rapidly inflate or collapse.
Rollback is not a failure; it is a basic discipline of large-model training.
8. FAQ: Common Questions About Optimizers
1. Does the optimizer have to be changed?
Not necessarily. If AdamW can already converge stably, reach the target metrics, and keep training cost acceptable, there is no need to switch optimizers just for the sake of “new”. An optimizer change should be based on a clear benefit: faster convergence, lower memory use, better stability, or higher metrics under the same compute.
2. How do the learning rate and the optimizer work together?
Changing the optimizer almost certainly requires re-tuning the learning rate. AdamW’s learning rate cannot be copied directly to Muon, because the two differ in update scale, second-moment scaling, and matrix handling. At the same time, the learning-rate scheduler should be designed together:
- Use warmup early in training to reduce instability;
- Maintain a reasonable decay in the middle;
- Use cosine decay or another scheduling strategy in the later stage.
3. What are the most common mistakes?
- Changing only the optimizer without re-tuning the learning rate;
- Not distinguishing parameter groups and applying the same weight decay to all layers;
- Ignoring gradient clipping, so a loss spike appears early in training;
- Looking only at the final loss, without monitoring gradient norm and update norm;
- Blindly copying paper defaults without running small-scale ablations;
- Ignoring eps, gradient scaling, and numerical-stability issues under mixed precision.
9. Conclusion
From naive gradient descent, to the inertia of the momentum method, to the adaptive scaling and decoupled weight decay of Adam and AdamW, and to matrix-orthogonalization optimizers represented by Muon, the evolution of optimizers has essentially been dealing with the same set of problems:
- Whether the update direction is stable;
- Whether the learning step size is appropriate;
- Whether different parameters need differentiated updates;
- Whether the update can be made more balanced at the matrix-structure level;
- Whether the engineering system is monitorable, reproducible, and rollback-capable.
Understanding this thread matters more than memorizing the name of any single optimizer. What is truly scarce in large-model training is not a “new algorithm slogan”, but a complete understanding of the training system: optimizer, learning-rate scheduling, parameter grouping, gradient clipping, numerical stability, and experimental discipline together determine the final result.
