Schedules

Dive into Deep Learning · §9.7

Learning-Rate Schedules: Warmup, Cosine Decay, and WSD
cumulative budget B_T & terminal rate η_T · frozen noise · linear warmup · cosine decay · warmup–stable–decay & branching

Why the Learning Rate Must Rise Early and Fall Late

Motivation

  • Opening hazard (t = 1..W): Under cold-start AdamW, step 1 moves every coordinate by \pm\eta_0 from a single noisy minibatch before (\mathbf{m}_t, \mathbf{v}_t) fill and before entering a flat basin (\lambda_{\max} \le 2/\eta_0).
  • Terminal hazard (t \to T): Constant \eta_0 traps SGD in a noise ball \frac{\eta\sigma^2}{2\lambda b} and forces AdamW/Muon to keep taking O(\eta_0) steps.
  • Schedule remedy: Ramp linearly 0 \to \eta_0, hold a high travel plateau B_T, and decay \eta_T \to 0.

Bias–Variance Decomposition Under a Schedule η_t

Analytical Model on the Noisy Valley

  • Time-varying noisy quadratic recursion: \mathbb{E}\big[x_t^2\big] \approx \underbrace{e^{-2\lambda B_t}\,x_0^2}_{\text{Travel term}} + \underbrace{\frac{\eta_t\,\sigma^2}{2\lambda}}_{\text{Noise ball}}, \quad B_t = \sum_{s=0}^{t-1} \eta_s
  • Cumulative budget B_T = \sum_{t<T} \eta_t: Area under the LR curve erases initial bias exponentially as e^{-2\lambda B_T}.
  • Terminal rate \eta_T: Sets the final noise floor \frac{\eta_T\sigma^2}{2\lambda} provided \eta_t decays slowly enough (R_s \gtrsim 1/\lambda_{\min}).

Classical Parametric Decay Families and Their Budgets

Four Schedules on the Valley

  • Comparing four schedules over T = 3{,}000 noisy valley steps (\lambda_1 = 0.2, \lambda_2 = 4.0, \sigma^2 = 1):
    • Constant (\eta_t = 0.1): Huge budget (B = 300), stalls at stationary noise ball (\approx 0.27\text{--}0.29).
    • Polynomial \alpha = 1/2 and \alpha = 1: Budgets 200.2 and 48.2; cleanly track the instantaneous noise ball down to \approx 0.09\text{--}0.10 and \approx 0.011\text{--}0.012.
    • Exponential (0.4 \times 0.98^t): Finite budget B_\infty = 20 erases x_0, yet freezes at variance 0.125 despite \eta_T \approx 10^{-27}.

1,000 Valley Runs: Why Exponential Decay Freezes

Empirical Verification

  • Averaging 1{,}000 independent noisy valley trajectories over T = 3{,}000 steps:
    • Constant (\eta = 0.1): Plateaus at its stationary noise ball (\approx 0.27\text{--}0.29).
    • Polynomial \alpha = 1/2 and \alpha = 1: Track the instantaneous noise ball cleanly down to 0.09\text{--}0.10 and 0.011\text{--}0.012, respectively.
    • Exponential (\gamma = 0.98): Despite reaching \eta_T \approx 10^{-27}, the iterate freezes at a mean-squared distance of 0.12\text{--}0.13 from step 250 onward.

constant        budget  300.0, final rate 0.1, mean squared distance 0.286
exponential     budget   20.0, final rate 1.9e-27, mean squared distance 0.118
polynomial 1/2  budget  200.2, final rate 0.036, mean squared distance 0.089
polynomial 1    budget   48.2, final rate 0.0033, mean squared distance 0.012

Noise Is Removed Only by Budget Still to Come (R_s)

The Frozen-Noise Mechanism

  • Remaining budget after step s (R_s = \sum_{u > s} \eta_u): \mathbb{E}\big[x_T^2\big] \approx e^{-2\lambda B_T}x_0^2 + \sigma^2 \sum_{s=0}^{T-1} \eta_s^2\,e^{-2\lambda R_s}
  • Geometric tail starvation: Under \eta_s = \eta_0\gamma^s, R_s \approx \frac{\eta_s}{1-\gamma}. Once \eta_s < \frac{1-\gamma}{2\lambda_1} = 0.05, 2\lambda_1 R_s < 1 and all subsequent contraction stops.
  • Exact frozen variance: \mathbb{E}[x_\infty^2]_{\text{exp}} \approx \frac{(1-\gamma)\sigma^2}{4\lambda^2} = 0.125.

Modern Finite-Horizon Schedule Shapes

Constant, Cosine, and Late Decay

On a fixed budget of T = 2{,}000 steps with peak learning rate \eta_0 = 3 \times 10^{-3}, we compare three finite-horizon profiles:

  • 1. Constant (\eta_t = \eta_0): Rectangular area B_T = \eta_0 T = 6.0, terminal rate \eta_T = 3 \times 10^{-3}.
  • 2. Cosine decay (Loshchilov & Hutter, 2016): \eta_t = \frac{\eta_0}{2}\left(1 + \cos\frac{\pi t}{T}\right) Symmetric half-wave with half the budget (B_T = 0.5\,\eta_0 T = 3.0) and \eta_T = 0.
  • 3. Stable–then–decay (late linear decay): Holds \eta_0 until t_{\text{decay}} = 0.8\,T = 1{,}600, then decays linearly to 0 (90\% budget B_T = 5.4, \eta_T = 0).
def constant(t, eta=3e-3):
    return eta

def cosine(t, eta=3e-3, T=2000):
    return eta * (1 + math.cos(math.pi * t / T)) / 2

def stable_decay(t, eta=3e-3, decay_start=1600, T=2000):
    """eta until decay_start, then a linear decay to zero at step T."""
    return eta * min(1, (T - t) / (T - decay_start))

def warmup(schedule, num_steps):
    """schedule, ramped up linearly over its first num_steps steps."""
    return lambda t: min(1, (t + 1) / num_steps) * schedule(t)

Evaluating Decay Shapes on TinyLM

Step 1,500 vs. Step 2,000

  • Training TinyLM with AdamW (\lambda = 0) across two seeds and evaluating validation loss at step 1{,}500 and step 2{,}000:
    • At step 1{,}500 (before late decay starts): Cosine decay leads (1.58\text{--}1.59 vs. 1.61) because \eta_{1500} has already fallen to 15\% of \eta_0, damping step noise.
    • At step 2{,}000 (after late decay completes): Between steps 1{,}600 and 2{,}000, stable_decay drops sharply by \sim 0.10 nats to 1.51 nats, beating the constant run by 0.05\text{--}0.06 nats and cosine decay by \sim 0.05 nats.

schedule             budget  validation loss at step 1500, 2000
constant               6.00   1.609 1.609    1.568 1.564
cosine                 3.00   1.584 1.578    1.558 1.554
stable, then decay     5.40   1.609 1.609    1.507 1.507

Why Late Decay Wins and Mid-Run Comparisons Mislead

Budget vs. Noise Floor

  • Why late decay beats cosine on compute-bound runs: Holding \eta_0 for 80\% of steps preserves 90\% of the travel budget (B_T = 5.4 vs. cosine’s 3.0) while still finishing at \eta_T = 0 (1.51 vs. 1.56 nats).
  • Never rank schedules mid-run before cooldown: At step 1{,}500, uncooled plateau weights carry O(\eta_0) step jitter that vanishes as soon as the 400-step linear cooldown drops \eta_t \to 0 (Wen et al., 2025).

Why High Peak Rates Fail Cold: Adam’s First Step

The Mechanics of Learning-Rate Warmup

  • Unaveraged step-1 sign jump: At t = 1, Adam moves every weight by \pm\eta_0 from a single batch. On TinyLM (\text{RMS}(\mathbf{W}_0) \approx 0.045), cold \eta_0 = 0.03 jumps by 67\% of initial weight magnitude on step 1.
  • 20-step linear ramp (\eta_t = \eta_0\min(1, \frac{t+1}{W})): Starts at \eta_0/20 = 0.0015 (3.3\% step), letting \mathbf{m}_t, \mathbf{v}_t fill over \tau_1 = 10 steps while steering below 2/\eta_t.

A 20-Step Warmup Rescues Training at η₀ = 0.03

Cold Start vs. Linear Ramp

  • Comparing a cold start against a 20-step linear warmup (1\% of 2{,}000 steps) at \eta_0 = 0.03 from identical initial weights:
    • Cold start: Relative weight change \|\Delta\mathbf{W}\|_{\text{RMS}}/\|\mathbf{W}\|_{\text{RMS}} is 0.67 (67\%) on step 1; the network stalls near 2.8\text{--}2.9 nats.
    • 20-step linear ramp: Caps relative weight change at 0.03 on step 1 and \le 0.10 at steps 5–20, lowering final validation loss by more than a full nat (\approx 1.77 nats).
step size / weight size at steps 1, 5, 20, 100; final loss
cold start     0.67 0.15 0.02 0.01   training 2.862, validation 2.865
20-step ramp   0.03 0.10 0.05 0.01   training 1.809, validation 1.769

Practical Rules for Warmup Length and Peak-Rate Tuning

Configuring the Opening Ramp

Warmup rescues an aggressive peak learning rate \eta_0 = 0.03 from cold-start failure, but notice that \eta_0 = 0.03 with warmup (\approx 1.77 nats) still finishes higher than \eta_0 = 0.003 (1.56 nats):

Design Parameter Engineering Rule of Thumb Quantitative Justification
Warmup duration W 1\%\text{--}5\% of total steps T (and always W \ge \frac{2}{1-\beta_1} = 20 steps) Gives Adam’s first-moment buffer \mathbf{m}_t (\tau_1 = 10) and early second-moment scale \mathbf{v}_t time to accumulate multi-batch statistics
Budget given up by warmup \Delta B = \frac{W}{2}\,\eta_0 (<0.5\%\text{--}2.5\% of B_T) For W = 20, T = 2{,}000, \eta_0 = 0.03, the triangle deficit is 9.5\eta_0 = 0.285 out of B_T = 60 (0.48\%)
Peak learning rate \eta_0 Sweep \eta_0 in factors of 2\text{--}3\times with warmup active Expect the optimal \eta_0^\star to sit 3\text{--}10\times below the highest rate that warmup can stabilize

Cosine Decay vs. Warmup–Stable–Decay (WSD)

Fixed Horizon vs. Anytime Stopping

  • Cosine decay requires fixing T at step 0: Spends 50\% of peak travel budget (B_T = 0.5\eta_0 T) and cannot be extended without LR re-warming.
  • Warmup–Stable–Decay (WSD, Hu et al., 2024):
    • Holds constant plateau \eta_0 (horizon-free, 85\text{--}90\% travel budget).
    • Forks a short 10\text{--}20\% cooldown branch from any plateau checkpoint to produce finished models across multiple token budgets from one run.

The River-Valley Geometry of Warmup–Stable–Decay

Landscape Interpretation

  • Wen et al. (2024) explain WSD’s efficiency via a river-valley loss surface:
    • High-rate plateau (\eta_t = \eta_0): The iterate oscillates rapidly across the steep transverse valley walls (\lambda_{\text{steep}}) while making fast downstream progress along the flat longitudinal river bed (\lambda_{\text{flat}} \ll \lambda_{\text{steep}}).
    • Short cooldown branch (\eta_t \to 0): Because the transverse oscillations sit along high-curvature directions (\lambda_{\text{steep}} \gg 1), they need only a small remaining budget R \gtrsim 1/\lambda_{\text{steep}} (10\text{--}20\% of T) to damp out and drop onto the valley floor.

Implementing Checkpoint Branching: Cloning Adam’s State

Preserving Optimizer Moments

When branching a short cooldown off a plateau checkpoint at step s, we must clone both the model parameters and the optimizer state (\mathbf{m}_s, \mathbf{v}_s, s):

def branch(model, optimizer, schedule):
    """Copies of model and optimizer that continue under schedule."""
    model, adam = copy.deepcopy((model, optimizer.optimizer))  # With moments
    return model, Scheduled(adam, schedule, optimizer.scheduler.last_epoch)

Common checkpoint bug: Starting a cooldown branch with a freshly initialized AdamW (\mathbf{m}_0 = \mathbf{v}_0 = \mathbf{0}) triggers unaveraged step-1 sign jumps \pm\eta_s that corrupt the plateau weights.

Multi-Horizon Models from a Single Plateau Run

Anytime Cooldown Verification

  • We run a single 2{,}000-step constant-rate plateau (\eta_0 = 3 \times 10^{-3}) on TinyLM and branch 250-step linear cooldowns at steps 500, 1{,}000, and 1{,}500:
    • Every 250-step cooldown drops validation loss sharply below the continuing plateau (0.05\text{--}0.06 nats at steps 1{,}250 and 1{,}750).
    • The branch at 1{,}000 \to 1{,}250 (1.58\text{--}1.60 nats) matches a dedicated 1{,}250-step run planned from step 0 to within <0.01 nats, delivering 3 finished models in 2{,}250 steps instead of 3{,}750.

step  plateau  branch
 750    1.791   1.766
1250    1.655   1.604
1750    1.588   1.534
planned run of 1250 steps: 1.604

Concept Check: Frozen Noise, Warmup, and WSD Branching

Check Your Understanding

Solve each scheduling design question quantitatively:

  1. Frozen noise under exponential decay: On a 1D quadratic of curvature \lambda = 0.2 and noise variance \sigma^2 = 1, exponential decay \eta_t = 0.4 \times \gamma^t with \gamma = 0.98 froze at variance \frac{(1-\gamma)\sigma^2}{4\lambda^2} = 0.125. What happens to the frozen variance if we slow the decay to \gamma = 0.995?
  2. Cosine vs. late decay on a fast quadratic: On TinyLM (2{,}000 steps), late linear decay beat cosine decay because TinyLM needed the extra travel budget (B_T = 5.4 vs. 3.0). Which schedule finishes lower on a 1D noisy quadratic that already reaches its noise ball in 20 steps?
  3. Compute savings of WSD branching: You want evaluated, cooled checkpoints at horizons T_1 = 1{,}000, T_2 = 2{,}000, and T_3 = 3{,}000 steps, each ending with a 300-step linear cooldown. How many total training steps do three separate cosine runs require versus one WSD plateau with three branches?

Concept Check: Frozen Noise, Warmup, and WSD Branching (answers)

Check Your Understanding

Answers:

  1. At \gamma = 0.995, 1 - \gamma = 0.005 (4\times smaller than 0.02), so the asymptotic frozen variance drops 4\times to \frac{0.005}{4 \times 0.04} = 0.03125.
  2. Cosine decay. Once initial bias e^{-2\lambda B_t}x_0^2 has vanished (after 20 steps), only late-stage noise damping matters, and cosine decay spends far more steps at small learning rates near the end of the run.
  3. Three separate cosine runs cost 1{,}000 + 2{,}000 + 3{,}000 = 6{,}000 steps; one WSD plateau to step 2{,}700 plus three 300-step cooldown branches at steps 700, 1{,}700, 2{,}700 costs 2{,}700 + 3 \times 300 = 3{,}600 steps (40\% compute saved).

Summary: Learning-Rate Schedules, Warmup, and WSD

Key Takeaways

Schedule Concept Mathematical Form / Invariant Budget & Terminal Behavior Practical Guideline
Bias–Noise Decomposition \mathbb{E}[x_t^2] \approx e^{-2\lambda B_t}x_0^2 + \frac{\eta_t\sigma^2}{2\lambda} Budget B_t = \sum_{s<t}\eta_s erases start; \eta_T sets floor Requires both large B_T and slow decay (R_s \gtrsim 1/\lambda)
Exponential Decay Hazard \eta_t = \eta_0\gamma^t,\quad R_s \approx \frac{\eta_s}{1-\gamma} Freezes noise at \frac{(1-\gamma)\sigma^2}{4\lambda^2} once \eta_s \lesssim \frac{1-\gamma}{2\lambda} Avoid fast geometric decay without a floor or polynomial tail
Linear Warmup \eta_t = \eta_0\min\!\left(1, \frac{t+1}{W}\right) Prevents 67\% step-1 weight jump under AdamW Ramp over W \sim 1\%\text{--}5\% of steps (always > \frac{1}{1-\beta_1} = 10)
Cosine Decay \eta_t = \eta_T + \frac{\eta_0-\eta_T}{2}\left(1 + \cos\frac{\pi t}{T}\right) Budget B_T = 0.5\,\eta_0 T (for \eta_T = 0) Standard for fixed-horizon runs where T is known in advance
Warmup–Stable–Decay (WSD) Constant plateau \eta_0, then linear/cosine cooldown Budget B_T \approx 0.9\,\eta_0 T; supports anytime branching Fork 10\text{--}20\% cooldown branches (copying weights + \mathbf{m}, \mathbf{v})