What is the AI Adam optimiser?
The Adam optimiser is the most widely used optimisation algorithm in deep learning, adapting the step size per parameter by keeping moving averages of the gradient and of the squared gradient.
Its name comes from Adaptive Moment Estimation. Unlike stochastic gradient descent, which applies one learning rate to all parameters, Adam shrinks steps for parameters with large, frequent gradients and enlarges them for sparse ones. Adam with decoupled weight decay is a common variant that separates weight decay from this update.
- Topic
- Machine learning, models and training
- Also known as
- Adaptive Moment Estimation, Adam optimizer
- Origin
- 2014
How the AI Adam optimiser works
- For each parameter an exponential moving average of the gradient, the first moment, is kept; it acts as momentum.
- A moving average of the squared gradient, the second moment, shows how volatile the gradient is.
- Both averages start near zero, so bias correction is applied in early steps.
- The update divides the first moment by the square root of the second and multiplies by the learning rate.
In more detail
Core hyperparameters and LLM settings
Adam relies on three main hyperparameters alongside the learning rate: β1 (default 0.9) for the first moment decay, β2 (default 0.999, often lowered to 0.95 in LLM training) for the second moment decay and ε (typically 1e-8) in the denominator for numerical stability. Without ε, near-zero gradient variances would cause exploding updates.
Memory in mixed-precision training, ZeRO and FSDP
In standard BF16 or FP16 mixed-precision training, the optimiser typically stores an FP32 master copy of the weights (4 bytes per parameter) in addition to the two FP32 moments (8 bytes per parameter), bringing optimiser memory to 12 bytes per parameter (~84 GB for a 7B model) before activations. Distributed frameworks such as ZeRO and FSDP shard these states across multiple GPUs.
Convergence issues and the generalisation gap
On certain non-convex or synthetic objectives, Adam's exponential moving average of squared gradients can fail to converge to the optimal solution, motivating variants such as AMSGrad. Furthermore, because Adam scales steps per coordinate, its solutions can sometimes generalise slightly worse than well-tuned SGD with momentum on vision tasks.
Commonly confused terms
| Term | How it differs |
|---|---|
| RMSProp | RMSProp tracks only the second moment (squared gradient moving average) without momentum or bias correction, whereas Adam combines momentum (first moment) with RMSProp's adaptive scaling plus bias correction. |
| Adafactor | Adafactor factors the second-moment matrix into row and column statistics to cut optimiser memory from linear to sublinear in matrix size, trading some stability for large memory savings compared to standard Adam. |
Why the AI Adam optimiser matters for on-premises AI
Adam, usually as AdamW, is the default for language model training and fine-tuning and converges stably with little tuning. The price is memory: two moments are stored per parameter. For a 7 billion parameter model with moments in 32 bits, 7 billion × 2 × 4 bytes = 56 GB are needed for optimiser state alone, before weights and gradients. LoRA, training only small adapters, cuts this load sharply, as do 8-bit optimiser variants.
A telecom operator finds Adam's state alone will not fit its in-house GPU server for full fine-tuning, so it trains only adapters with LoRA on the same server.
Common questions
What is the difference between Adam and SGD?
SGD uses one learning rate for all parameters. Adam scales each parameter's step from its gradient history, usually converging faster with less tuning but needing more memory.
What is the difference between Adam and AdamW?
In Adam weight decay is added to the gradient and affected by adaptive scaling. AdamW applies it as a separate step and has become standard for training large language models.
Related terms
- AI stochastic gradient descent (SGD)
- Learning rate
- AI optimiser
- Adam with decoupled weight decay (AdamW)
- Weight decay
- AI graphics processing unit (GPU) memory
Sources
In the glossary: Glossary, A to D