Skip to content
mlmentorship

Learning rate schedules: warmup and cosine decay

Why almost every modern training run linearly warms up the LR over a few hundred steps and then decays it on a cosine to near zero.

Published · 4 min read ·Core ·Intermediate

Visual quick review

Visual first · depth when needed

Read a linear-warmup-plus-cosine schedule at its three defining checkpoints: the peak at warmup end W, 55% of peak halfway through the decay interval, and the 10% floor at training end T.

Preparing the visual…

Summary

A learning-rate schedule is a function that varies the optimizer’s step size over training. The dominant 2026 default for LLMs is linear warmup for a few hundred to a few thousand steps, followed by cosine decay down to ~10% of the peak LR.

Why warmup

Early training can combine poorly estimated optimizer moments, high curvature near initialization, and rapidly changing activations. Jumping immediately to the target LR can make those transient updates unstable. Warmup limits the initial step size while the model and optimizer state enter a regime that can support the peak LR.

Typical warmup: to steps for pretraining; ~100 steps is enough for fine-tuning.

Why cosine

After warmup, decay from the peak LR toward a lower floor over the remaining horizon. Cosine decay,

starts and ends with a shallow slope while changing fastest near the middle of the decay interval (Loshchilov & Hutter, 2017).

Common practice: cosine to over the full training horizon .

Learning objective

Where are the three defining checkpoints of warmup plus cosine decay?

Linear warmup followed by cosine decay to ten percent of peak A normalized learning-rate plot rises linearly from zero to the peak at warmup end W. It then follows a cosine curve over the separate interval from W to training end T. A circle marks one hundred percent of peak at W, a diamond marks fifty-five percent halfway between W and T, and a square marks the ten-percent floor at T. Labels, marker shapes, and guide lines identify every checkpoint without relying on color. LINEAR WARMUP COSINE OVER W → T peak: 1.00 ηmax midpoint: 0.55 ηmax floor: 0.10 ηmax 1.00 0.55 0.10 start W (W + T) / 2 T training step → learning rate / ηmax
Read it this way: follow the line to the circle at W, where warmup reaches the peak. Only then does the cosine fraction start: halfway from W to T, the diamond is at 0.1 + ½(1 − 0.1) = 0.55 of peak. At T, the square reaches the 0.10 floor. The three marker shapes and labels carry the meaning independently of color. Original normalized plot checked against the SGDR cosine equation and PyTorch scheduler documentation.

How to set the peak LR

For Adam/AdamW on transformer training, the default starting point is (Karpathy’s “magic constant”) for moderate batch sizes. Larger batches scale up roughly linearly until the LR-batch tradeoff breaks ( for very large batch).

For SFT or task-specific fine-tuning of a pretrained model: 10–100× lower than pretraining ( to ).

A LR range test (Smith, 2017): sweep from to over a few hundred steps, plot loss vs. LR. Pick the point at the steepest descent (typically ~10× below where the loss diverges).

Other schedules

  • Constant: useful for online learning / RL where the data distribution shifts.
  • Inverse square root (original transformer paper): after warmup. Largely superseded by cosine.
  • One-cycle (Smith, 2018): warmup to a high peak, then decay aggressively. Used in some vision training; uncommon in LLMs.
  • WSD (Warmup-Stable-Decay): warmup, hold constant for most of training, decay sharply at the end. Used in some recent LLM training (Hu et al., 2024) for easier checkpoint resumption.

Common pitfalls

  • Skipping warmup. Adam without warmup on a transformer routinely diverges.
  • Decaying too fast. Aggressive decay limits how far the model can move; cosine-to-10% is a reliable default.
  • Forgetting LR scales with batch. Doubling the batch usually requires roughly doubling the LR.
  • Resuming a cosine schedule from a checkpoint. If the cosine is parameterized over total steps, resuming with a different total breaks the schedule. Save schedule state with the checkpoint.