Repository navigation
Releases
v0.5.0
Add warmup_stable_decay (WSD / trapezoidal schedule, Hu et al. 2024): three phases (linear warmup, stable plateau at base_lr, then linear or 1-sqrt decay to final_lr). The modern LLM-pretraining schedule. 57 tests; new 'wsd' CLI subcommand.
lrsched v0.4.0
What is new
Three standard decay schedules are now in the library.
polynomial_decay
from lrsched import polynomial_decay
s = polynomial_decay(start_lr=1e-3, end_lr=1e-5, total_steps=1000, power=2.0)Follows (start_lr - end_lr) * (1 - t/T)**power + end_lr, then holds end_lr. power must be positive; both rates must be finite.
exponential_decay
from lrsched import exponential_decay
s = exponential_decay(base_lr=1e-3, decay_rate=0.96, decay_steps=100)Computes base_lr * decay_rate ** (t / decay_steps). Continuous (fractional exponent), so the decay is smooth rather than stepped. decay_rate must satisfy 0 < decay_rate < 1.
step_decay (updated)
The gamma parameter is renamed to drop, and the factory now validates 0 < drop <= 1 and base_lr > 0. Formula is unchanged: base_lr * drop ** floor(t / step_size).
The CLI lrsched step subcommand now takes --drop instead of --gamma.
Migration
Replace step_decay(base_lr=..., gamma=0.5, step_size=10) with step_decay(base_lr=..., drop=0.5, step_size=10).
Full changelog
See CHANGELOG.md.
lrsched v0.3.0
What's new
Adds scale_by_group(schedule, *, multipliers) for per-parameter-group learning-rate multipliers.
The base schedule produces one learning rate per step; each named group scales it by a fixed positive multiplier. Returns a GroupSchedule (callable from step to dict[str, float]), exported alongside the new GroupSchedule type alias.
Typical use for discriminative/layer-wise learning rates:
from lrsched import cosine, scale_by_group
base = cosine(base_lr=1e-3, min_lr=1e-5, total_steps=1000)
group_lr = scale_by_group(base, multipliers={"backbone": 0.1, "head": 1.0})
lrs = group_lr(250) # {"backbone": ..., "head": ...}Multipliers must be positive and finite; an empty mapping raises ValueError.
Changelog
See CHANGELOG.md for full history.
v0.2.0
Adds the Smith (2017) cyclical learning rates (triangular, triangular2, exp_range) and a lrsched command-line tool that samples any schedule to one value per step or a sparkline (cosine, linear, exponential, step, triangular, one-cycle). 26 tests.
v0.1.0
First release of lrsched, a zero-dependency, framework-agnostic learning-rate schedule library.
Each schedule is a pure function from step to learning rate, usable in any training loop or framework. Includes constant, step, multi-step, exponential, linear, polynomial, cosine, cosine with warm restarts (SGDR), inverse square root (Transformer), and one-cycle, plus composable warmup, phase chaining, and sampling. Verified by exact reference values and Hypothesis invariants. 19 tests.