AI State of the Art
SOTA/Training: Modern Training Techniques/21 min
Section 96

Learning Rate Scheduling: Warmup, Cosine, WSD

Listen as a podcast →

The Problem: What Learning Rate at Each Step?

The learning rate (LR) is the step size the model takes at each weight update. Too large, it jumps over good solutions. Too small, it moves at a snail's pace.

But the thing is, the right LR changes during training. Imagine you're descending a mountain in fog. At the start, you don't know the terrain: you take small, cautious steps. Once you have a feel for the landscape, you speed up. And when you're approaching the bottom of the valley, you slow down so you don't overshoot and go back up the other side.

That's exactly what learning rate scheduling does: it adapts the step size based on where you are in training.

Linear Warmup: Let the Optimizer Calibrate

Simple Idea

You start with an LR of zero (or very small) and increase linearly during the first iterations:

lr(t)=lrmax⁡×tTwarmuplr(t) = lr_{\max} \times \frac{t}{T_{\text{warmup}}}

Concrete example: with lr_max=3e-4 and warmup of 1000 iterations:

  • Iteration 0: lr = 0
  • Iteration 500: lr = 1.5e-4
  • Iteration 1000: lr = 3e-4 (switch to cosine)

Why It's Necessary

Optimizer calibration

Adam maintains internal statistics (momentum and variance) of gradients to decide the direction and amplitude of updates. At the very beginning, these statistics are based on a single batch, so they're very imprecise. It's like trying to estimate a whole country's weather by looking out the window. The warmup gives Adam time to collect enough data for its estimates to become reliable, while keeping updates small and safe during this period of uncertainty.

Typical Duration

Model sizeWarmup
< 1B500-1000 iterations
1-10B1000-2000 iterations
> 10B2000-5000 iterations
Huge batchLonger warmup

Rule of thumb: warmup ≈ 0.5% to 2% of total iterations. The larger the batch size, the longer the warmup needs to be, since each update has a bigger impact on the weights.

Cosine Decay: The Elegant Curve

After warmup, the LR follows a cosine shape:

lr(t)=lrmin⁡+0.5×(lrmax⁡−lrmin⁡)×(1+cos⁡(π×t−TwarmupTtotal))lr(t) = lr_{\min} + 0.5 \times (lr_{\max} - lr_{\min}) \times \left(1 + \cos\left(\pi \times \frac{t - T_{\text{warmup}}}{T_{\text{total}}}\right)\right)

Visually, it's an inverted bell curve: it decreases slowly at first, accelerates in the middle, then slows down as it approaches the end.

Learning rate plotted against training steps: a near-vertical rise from 0 to 0.0003 over the first 2,000 steps (the highlighted warmup band), then a cosine decay down to a floor value at step 100,000.
The standard schedule in one picture, with exactly the numbers from the example above: lr_max of 3e-4 and 2,000 warmup steps. The orange band on the left is the warmup, barely visible at this scale because it is so short. Everything else is the cosine: flat at the top, steepest in the middle, flat at the bottom.Source : Michael Brenndoerfer

Why This Shape Works So Well

  • Slow start: you keep a high LR to broadly explore the parameter space and find the right "regions" of the loss
  • Fast middle: the loss decreases less quickly, a sign you're approaching a minimum, you reduce the LR to refine
  • Gentle end: you converge very softly toward a flatter local minimum, which favors generalization (a flat minimum is more robust than a narrow one)

The sculptor analogy works well here: at the start, you roughly shape the marble block. In the middle, you sculpt the main forms. And at the end, you polish the details with tiny movements.

The de facto standard

Warmup + cosine is used by LLaMA, GPT-3, Chinchilla, Mistral, and virtually all large LLMs. It's the gold baseline, if you don't know what to choose, go with this one.

WSD: Warmup-Stable-Decay

An increasingly popular alternative that divides training into three distinct phases:

  1. Warmup: linear increase (as before)
  2. Stable: constant LR during the majority of training
  3. Decay: rapid decrease (linear or exponential) at the end

Major Advantage: Flexibility

With cosine, you have to declare the total number of iterations T_total before starting. The entire curve is calculated based on this duration. Want to extend training because the loss keeps going down? Bad news: the entire schedule has to be recalculated.

With WSD, the stable phase has an arbitrary duration. You can train for 100K, 500K, or 2 million iterations in this phase, when you're satisfied, you simply trigger the decay. It's like a faucet you can turn off whenever you want, instead of a timer you have to program in advance.

WSD for continuation

Classic scenario: you finish training with cosine, and realize the model could still improve. Problem: the LR is already at its minimum. Raising the LR risks destabilizing the model. With WSD, you're in the stable phase (constant LR), so you can simply continue and launch a new decay whenever you want. It's much more pragmatic.

Comparison

AspectCosineWSD
Total duration required in advanceYesNo
Training continuationDifficultEasy
PerformanceReferenceComparable

DeepSeek, MiniCPM, and recent models increasingly choose WSD for this flexibility, especially when the compute budget isn't fixed in advance.

Training loss curves plotted against token count: six WSD runs with different stable-phase lengths, each ending in an abrupt drop in loss, compared against a cosine run shown in orange.
Six WSD runs with stable phases of different lengths, plus a cosine run in orange as the reference. Each green curve plateaus through the stable phase, then plunges the moment the decay is triggered, that is where the model picks up most of its quality, and you get to choose when it happens.Source : MiniCPM paper by Hu et al. (Figure 5), via Linsight

Other Less Common Strategies

Linear Decay

The LR decreases linearly from lr_max to lr_min. Simple and intuitive, but slightly suboptimal compared to cosine: the transition is too uniform and doesn't adapt to the different training phases.

Two schedules overlaid after a shared warmup: a straight descending line for linear decay and an S-shaped curve for cosine decay, which sits above the line early in the decay and below it at the end.
Both decays start from the same warmup and land at the same point. The blue line drops at a constant rate from start to finish; the orange curve stays high for longer to keep exploring, then dips below the line over the final stretch to refine. That difference in how the budget is spread is the cosine advantage.Source : Michael Brenndoerfer

Inverse Square Root

lr(t)=lrmax⁡×Twarmuptlr(t) = lr_{\max} \times \sqrt{\frac{T_{\text{warmup}}}{t}}

Used in the original Transformer (Vaswani et al., 2017) and T5. The LR decreases quickly at first, then very slowly. No need to declare T_total, which was an advantage before WSD came along. Less popular for modern LLMs, but still useful for exploratory projects without a fixed duration.

Cosine with Restarts

The LR oscillates in cosine with periodic restarts: when it reaches the minimum, it jumps back up. The idea is to let the model explore new regions. Rarely used for large-scale LLMs since restarts introduce instability.

Choosing the Maximum Learning Rate: Depends Heavily on the Model

Model sizeTypical LR (Adam)
100M5e-4 to 1e-3
1B3e-4 to 5e-4
7B1e-4 to 3e-4
70B1e-5 to 3e-5

Counter-intuitive trend: larger models require lower learning rates. Why? Because a larger model has more parameters interacting with each other. An LR that's too high causes updates that propagate and amplify through the layers, leading to instability. The deeper and wider the network, the gentler you need to be.

Scaling with Batch Size

When you increase batch size, each gradient is estimated on more examples and therefore more stable. You can afford a bigger step. This is the linear scaling rule:

lrnew=lrbase×new_batchbase_batchlr_{\text{new}} = lr_{\text{base}} \times \frac{\text{new\_batch}}{\text{base\_batch}}

Example: batch x8 => LR x8, but with a longer warmup to give the optimizer time to adjust.

The LR is the most sensitive hyperparameter

2x too high = catastrophic divergence (the loss explodes and never comes back). 2x too low = training 2x slower (you're wasting GPU for nothing).

That's why LR grid searches on small proxy models (1-3B) before launching expensive runs on large models are absolutely essential. A 70B run that diverges after 3 days is tens of thousands of dollars lost.

Advanced Practices

Batch Size Ramp-Up with LR Adjustment

You start with a small batch (2M tokens) and a high LR, then gradually increase the batch (2M -> 4M -> 8M) while adjusting the LR accordingly. The advantage: at the start, you make many updates with little data per step (fast but noisy learning), then you switch to more stable and compute-efficient updates with large batches.

Fine-Tuning: Much Lower LR

Fine-tuning uses LRs 10-100x lower than pre-training. Example: if pre-training uses 1e-4, fine-tuning uses 1e-5 to 1e-6. The logic is simple: the model has already learned solid representations, you want to adjust them delicately, not overwrite them. Little to no warmup needed.

Continuation: WSD > Cosine

If you're resuming training, WSD makes continuation trivial: just resume in the stable phase. With cosine, you have to hack together a new schedule, often by "rewarming" the LR, which can introduce instability.

Summary

Warmup + cosine = the standard and reliable combination for pre-training. WSD = the pragmatic alternative for flexibility. The maximum LR is the most critical hyperparameter, it depends heavily on model size and batch size. Always do a grid search before investing heavily.

The big rules to remember: always warmup, adjust the LR with the batch size, and bigger model = smaller LR.

Check your understanding0 / 5

1. Why does training start with a learning rate near zero, ramped up gradually during warmup?

2. A cosine-scheduled run just ended, and the loss was still going down. Why would WSD have made the situation more comfortable?

3. Before launching a 70-billion-parameter run that will cost tens of thousands of dollars, what does the page recommend for picking the maximum learning rate?

4. A 70-billion-parameter model trains with a learning rate roughly ten times lower than a 1-billion one. Why?

5. For fine-tuning an already pre-trained model, what learning rate should you use?