Optimizers for Large Language Model Training: Mechanisms, Selection, and Stability Controls
This article explains how optimizers turn gradients into parameter updates in large language model training, why they matter beyond being a simple configuration choice, and how momentum, adaptive scaling, and matrix-aware updates address different training problems. It also covers practical controls such as warmup, scheduling, gradient clipping, mixed precision, and monitoring, then proposes a step-by-step selection order. Readers will learn how to diagnose instability using loss, gradient norm, parameter norm, and clipping frequency, and how to choose and tune an optimizer based on evidence rather than name recognition.
An optimizer is not an accessory switch beside the loss function. It is the decision module that turns the current gradient into the next set of parameters. Large models routinely have billions or tens of billions of parameters, and their loss surfaces include flat regions, narrow ravines, and noisy estimates from random mini-batches. If training updated parameters based only on the sign of a single-step gradient, it would either oscillate across a valley or barely move in flat regions. Understanding an optimizer means understanding what it does with three things: direction, step size, and historical information.
Loss, Gradients, and the Update Loop
In supervised learning, the loss measures the gap between predictions and labels under the current parameters, and backpropagation gives the partial derivative of the loss with respect to each parameter. The gradient points in the direction of the steepest local increase in loss, so the parameter update moves in the opposite direction. A single step can be written as multiplying the learning rate by the gradient and subtracting that term from the current parameter. The learning rate is the step size. If the step is too large, the update overshoots the descending region, and the loss curve becomes jagged or suddenly spikes. If the step is too small, the same descent distance requires too many iterations, increasing wall-clock time and compute cost.
Random mini-batches make the gradient a noisy estimate of the true full-batch gradient. The noise can sometimes help parameters escape shallow pits, but it can also distort the update direction. The value of an optimizer lies in making trade-offs among noise, differing coordinate scales, and ill-conditioned curvature, not in pursuing a formula that is always fastest.
Steepest Descent Without Inertia and Its Limits
The simplest stochastic gradient descent uses only the current mini-batch gradient. It behaves like a particle with no mass: the velocity of this step is determined entirely by the slope at this step, and the trend from the previous step is forgotten immediately. Near a nearly spherical valley, this approach is simple and effective. Once the contour lines become long, narrow ellipses, meaning curvature differs greatly across directions, the particle repeatedly hits the walls of the steep direction and advances slowly in the shallow direction. A common symptom in training logs is slow loss reduction while the gradient norm fluctuates sharply; a slight increase in learning rate then causes divergence.
Early theory traces standard gradient methods to nineteenth-century steepest descent ideas. Its assumptions are clean, but it does not write inertia into the update rule. In large models, linear layers, embedding layers, and normalization layers often differ in gradient scale by several orders of magnitude, making pure steepest descent less able to accommodate all these coordinates at once.
Momentum: Adding Mass to Updates
The intuition behind momentum comes from a heavy ball: it looks not only at the current slope but also retains the velocity from the previous moment. In implementation, a decay coefficient first shrinks the historical velocity, then the current gradient is added, with the sign convention determining whether it is the gradient or its negative, and the resulting velocity updates the parameters. The decay coefficient is usually close to 1, for example on the order of 0.9, indicating greater trust in the recent trajectory than in a single noisy step.
This has three direct consequences. First, gradients that agree in direction accumulate, increasing the effective step size in flat directions. Second, gradients that reverse back and forth cancel each other, suppressing oscillation across the sides of a ravine. Third, the parameter trajectory becomes smoother, and the loss curve is no longer completely dominated by an anomalous sample from a single batch. Momentum is not a guarantee of escaping every local minimum. In non-convex losses, the real difficulties are often saddle points, flat regions, and sharp minima; momentum only reduces the probability of wasting steps in ill-conditioned directions and makes the trajectory less likely to be turned back by noise.
In practice, note that momentum and learning rate are coupled. Historical velocity already amplifies the update, so setting the learning rate very high as well can make the effective step too large. After changing the momentum coefficient, re-examine the loss during warmup instead of reusing the old learning-rate schedule.
Adaptive Scaling: Changing Step Size by Coordinate
The gradient magnitudes of different parameters can differ widely. With a single global learning rate, coordinates with large gradients tend to oscillate, while coordinates with small gradients barely update. Adaptive methods maintain a sliding statistic of squared gradients for each coordinate and normalize by its square root, making the update magnitude less sensitive to gradient scale. Common forms also add a very small constant to prevent division by zero and combine momentum with this scaling.
These methods often make early training easier to tune: there is no need to manually set a learning rate for every layer. The cost is that the statistics lag, and on some tasks later generalization may not outperform carefully tuned steepest descent with momentum. Selection should therefore not rely on names but on the loss surface and evaluation metrics: if gradient scales differ greatly across layers and early training is unstable, adaptive scaling often saves tuning effort; if training is already stable and later generalization matters more, a fixed learning rate with momentum and a good schedule is also common.
In either case, weight decay should be clearly distinguished from the semantics of gradient updates. If decay is inserted directly into the gradient and then scaled by an adaptive denominator, the actual penalty strength changes with gradient statistics. Many implementations separate decay from the adaptive denominator so that it behaves more like a stable shrinkage of the parameters themselves. This is not a new “magic term”; it lets regularization and step size each do their own job.
Momentum and Orthogonalization on Matrix Parameters
The weights of fully connected layers and attention projections are matrices, not a set of unrelated scalars. If they are still scaled independently element by element, the update may be too strong in some singular directions and too weak in others. Numerically, this can show up as a skewed weight spectrum and worsened dynamic range in activations and gradients. A newer class of methods first accumulates momentum on the matrix gradient, then pulls the update back toward a more balanced direction in the matrix sense, for example by iteratively pushing the momentum matrix toward approximate orthogonality or controlling its singular values, rather than performing only element-wise division.
This can be understood as two layers of information: momentum handles smoothing over time, while orthogonalization or spectral constraints handle the spatial goal of preventing a few directions from monopolizing the update. It does not replace the learning rate, nor does it automatically fix errors in data or objective design. Computationally, iterative orthogonalization is more expensive than element-wise adaptive scaling, so it is usually applied only to large matrix weights; vector parameters such as biases and normalization scales still use cheaper adaptive or momentum updates. Engineering attention should go to extra memory, since momentum state is often on the same order as the parameters, and to numerical stability of iterations under low precision: excessive scaling or too many iterations can overflow in half precision.
Training Controls That Pair With the Optimizer
The optimizer formula only determines how to move given a gradient. Running training stably also requires several controls that are tightly coupled to the optimizer.
Warmup: In the initial phase, gradient statistics and activation scales are unreliable, so the learning rate is raised linearly from a very small value to the target value, avoiding a first step that throws the parameters off course. Warmup steps should be considered together with batch size and model width, not copied as a fixed number.
Scheduling: After the target learning rate is reached, a common approach is cosine decay or piecewise constant decay. Decaying too early causes underfitting, while staying at a high learning rate for too long makes it difficult for the loss to decrease in later stages. The schedule curve should be aligned with the total number of steps; when changing batch size or parallelism, recheck it by the number of samples seen rather than by the step index in the log.
Gradient clipping: After backpropagation and before the optimizer step, limit the global gradient norm. This suppresses occasional loss spikes, but a threshold that is too small is equivalent to permanently reducing the learning rate, while a threshold that is too large provides no protection. Record the clipping trigger frequency: if clipping occurs on almost every step, learning rate, initialization, or loss scaling deserve more investigation.
Mixed precision: Using lower precision for the forward pass and some gradients while keeping master parameters and optimizer states in higher precision is a common combination in large-model training. If the second-order statistics and momentum buffers of adaptive methods lack precision, they can underflow to zero or overflow to infinity, appearing as a loss that stops moving for a long time or suddenly becomes NaN. When NaN appears, first check loss scaling, clipping, and master-weight precision before suspecting the optimizer formula itself.
Monitoring: At minimum, watch training loss, gradient norm, parameter norm, learning rate, and task metrics on the validation set together. If only training loss decreases while validation metrics worsen, the issue is likely generalization or data, not something a more “aggressive” optimizer can solve. If only the gradient norm is huge while the loss does not decrease, check the learning rate, clipping, and whether specific layers are abnormal first.
A Practical Selection Order
First, make a momentum-based update stably reproduce a baseline in a small-scale configuration: fix the data order and record whether the initial loss is reproducible. Next, enable per-coordinate adaptive scaling for layers with clearly different gradient scales, or try momentum updates with spectral constraints for large matrices, while keeping the other hyperparameters comparable. Then scan the learning rate by orders of magnitude separately, and test only a small number of momentum candidates, avoiding simultaneous random changes with weight decay and batch size. Finally, add warmup, decay scheduling, and gradient clipping, and use validation metrics rather than training loss alone to decide whether to keep the combination.
If the loss oscillates, first reduce the learning rate or strengthen clipping, then consider lowering momentum. If the loss stays on a long plateau, first confirm that gradients are not being clipped away and that the learning rate has not decayed too early to near zero, then consider slightly increasing the learning rate or reducing overly strong weight decay. If only individual matrix layers explode numerically, first check that layer’s initialization, normalization, and whether updates involve too many low-precision iterations, rather than replacing the optimizer globally.
A schematic update, with notation intended only to show data flow rather than a framework interface, can be summarized as follows: obtain the gradient from the mini-batch loss; clip by global norm; accumulate historical direction with momentum; apply scale normalization for vector parameters or finite spectral shaping to matrix momentum; write parameters with the current learning rate and slightly shrink weights with separated weight decay. Each step should correspond in the logs to learning rate, gradient norm, and parameter norm; otherwise, problems cannot be attributed when they occur.
Summary
The technical substance of an optimizer is not in its name but in three testable questions: whether it uses historical direction to suppress noise and ravine oscillation, whether it adjusts step size according to parameter scale, and whether it prevents a few singular directions from dominating matrix updates. Momentum provides inertia, adaptive scaling handles coordinate imbalance, and matrix-oriented orthogonalization or spectral constraints further account for directions within a layer. All of these must be designed together with learning-rate warmup, scheduling, gradient clipping, and precision strategy. When training is unstable, use loss, gradient norm, and clipping frequency to locate whether the problem is step size, statistics, or numerical behavior in a specific layer, then adjust the corresponding knob. That is more reliable than blindly switching algorithms.
