Adam

An optimizer is the rule that turns gradients into weight updates. Backpropagation tells you the direction of steepest descent for every parameter; the optimizer decides how far to step and how much to trust the raw gradient versus the history of gradients it has already seen. Everything about how fast a model trains, whether it converges at all, and how well it generalizes is downstream of this one choice. The whole field has converged on a small family of update rules, and understanding what each one does to the gradient is enough to reason about almost any training run.

Stochastic gradient descent is the baseline: step downhill by the gradient, scaled by the learning rate. Because the gradient is estimated on a mini-batch rather than the full dataset, the path is noisy — but that noise is a feature, acting as a regularizer that often helps generalization. Plain SGD is cheap in memory (no extra state) and still produces the best final accuracy on many vision benchmarks, at the cost of careful learning-rate tuning and slow progress through ravines in the loss surface.

Momentum fixes SGD's zig-zagging by accumulating a velocity. Instead of stepping by the current gradient, you keep an exponentially-decayed running average of past gradients and step by that. This damps the oscillation across a narrow valley and accelerates progress along its floor, the way a heavy ball rolls through small bumps. It is the single most cost-effective upgrade to SGD and costs just one extra copy of the parameters.

Adaptive methods give every parameter its own learning rate. RMSProp scales each update by a running average of that parameter's squared gradients, so frequently-updated weights take smaller steps and rarely-updated ones take larger steps. Adam combines the two ideas — it tracks a first moment (momentum) and a second moment (RMSProp-style variance), applies a bias correction so early steps are not too small, and has become the default optimizer for essentially all transformer training. Its price is memory: it stores two extra values per parameter, which for a large model is a substantial share of the training footprint.

AdamW is the version you actually want for large models. The original Adam folds weight decay into the gradient, which interacts badly with the adaptive scaling; AdamW *decouples* weight decay and applies it directly to the weights, which measurably improves generalization and is now the standard recipe for training LLMs. Newer optimizers such as Lion push further on memory efficiency by keeping only a sign-based momentum term, trading a little quality for a smaller optimizer state.

OptimizerExtra state / paramAdaptive per-param LRNoteTypical use
SGDnoneNoNoisy but generalizes wellVision, fine-tuning
SGD + momentum1xNoDamps oscillation, acceleratesCNNs, ResNets
RMSProp1xYesPer-parameter scalingRNNs, RL
Adam2xYesMomentum + variance + bias fixDefault for transformers
AdamW2xYesDecoupled weight decayLLM pretraining
Optimizers — How the Weights Actually Move the gradient only gives a direction; the optimizer decides how far, how smoothly, and how adaptively to step Descending a curved loss surface minimum start SGD — oscillates across the valley + Momentum — damps the zig-zag Adam — adaptive, steadier path The update rule, built up in layers SGD θ ← θ − η g one global step size η for every parameter + Momentum v ← βv + g   θ ← θ − η v a running velocity smooths and accelerates the trajectory Adam θ ← θ − η · m̂ / (√v̂ + ε) m̂, v̂ = bias-corrected EMAs of g and g² — a per-parameter adaptive rate AdamW θ ← θ − η ( m̂/(√v̂+ε) + λθ ) weight decay applied straight to θ, decoupled from the adaptive term Momentum: a heavy ball Instead of stepping on the raw gradient, accumulate a velocity over steps. It cancels the back- and-forth across a ravine and builds speed along directions the gradient keeps pointing. Adam: a rate per weight Track a running average of each gradient's magnitude. Parameters with large gradients take smaller steps; rarely-updated ones take bigger ones. Momentum + scaling = the default for transformers. AdamW: honest decay Classic L2 weight decay gets rescaled by Adam's per-parameter term, so big-gradient weights barely decay. AdamW shrinks the weights directly instead — the standard recipe for training modern LLMs.

The instinct is to treat the optimizer as a hyperparameter you inherit from whatever tutorial you started with — "use AdamW, it works." It is more useful to see each optimizer as a specific policy for spending the gradient: SGD trusts the raw noisy gradient, momentum trusts a smoothed history of it, and Adam reshapes it per-parameter using both the average and the variance it has observed. That reshaping is what buys robustness to bad learning rates, and its cost is the extra state you have to hold in memory. Read an optimizer through a how-it-reshapes-the-raw-gradient lens rather than a which-one-converges-fastest lens, and choices like SGD-for-vision, AdamW-for-LLMs, and Lion-when-memory-is-tight stop being lore and become a straight trade between robustness and the memory you can afford.

Take adam further

Ask the copilot about this term, or have our engineers assess it against your process.