Learning Rate Scheduler Calculator
Plot the exact per-step learning rate for warmup, cosine, linear, constant, and Transformer (Noam) schedules — enter your peak LR, total steps, and warmup, then copy the matching Hugging Face code. Free, no signup, formulas cited below.
How it works
A learning rate schedule multiplies your optimizer's learning rate (LR) by a factor that changes at every training step. Almost every modern transformer recipe follows the same two-part shape: a short warmup where the LR ramps up from 0 to the peak, then a decay back down. Warmup exists because a fresh model with random weights produces large, noisy gradients; starting at full LR can destabilise training, so the LR is eased in gradually (Goyal et al., 2017, §2.2).
For the linear, cosine, and constant schedules this tool reproduces the exact lr_lambda factors used by Hugging Face transformers, so the numbers match what the Trainer applies during real training:
- Warmup (all schedules):
factor = step / max(1, warmup), so the LR reaches the peak exactly atstep = warmup. - Linear decay:
factor = max(0, (total − step) / (total − warmup))— a straight line from peak to 0. - Cosine decay: with
progress = (step − warmup) / (total − warmup),factor = ½(1 + cos(π · num_cycles · 2 · progress)). At the defaultnum_cycles = 0.5this is a single half-cosine from peak to 0, matching the SGDR annealing form of Loshchilov & Hutter (2017). - Constant with warmup: the LR holds at the peak after warmup (
factor = 1).
You can add a floor with the Min LR field: the LR then follows lr = min_lr + (peak_lr − min_lr) · factor, so cosine and linear decay to your floor instead of 0. The Transformer (Noam) schedule is different — it is absolute rather than a multiple of a peak you choose. From Vaswani et al. (2017, §5.3): lr = d_model^(-0.5) · min(step^(-0.5), step · warmup^(-1.5)). It rises during warmup, peaks at step = warmup with value d_model^(-0.5) · warmup^(-0.5), then decays as the inverse square root of the step. The tool derives and shows that computed peak so you can compare schedules on the same axis.
Worked examples
Frequently asked questions
Sources & references
- Vaswani et al. 2017 — Attention Is All You Need (§5.3, Noam schedule)
- Loshchilov & Hutter 2017 — SGDR: cosine annealing with warm restarts
- Hugging Face transformers — optimizer schedule reference (get_*_schedule_with_warmup)
- Goyal et al. 2017 — Accurate, Large Minibatch SGD (§2.2, gradual warmup)
The factors on this page were last cross-checked against the Hugging Face transformers source and the Vaswani formula on 2026-07-08. They are reviewed whenever the reference schedule implementations change.
Related tools
Comments & feedback
Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.
Found a bug, edge case, or want another schedule added?
Email me at [email protected] — most fixes ship within 24 hours.