Stop guessing your learning rate
A PyTorch port of the fastai learning-rate finder that automates the "start at 1e-5 and pray" workflow.

What it does Wraps a short pre-training run that ramps the learning rate from tiny to huge while tracking loss. You inspect the resulting curve and pick a sane value before your real training begins. It also supports cyclical learning rates by identifying the boundaries where loss starts descending and where it goes ragged.
The interesting bit The library implements two variants: fastai’s exponential training-loss approach (quick, plots against log LR) and Leslie Smith’s original linear evaluation-loss approach (slower but sharper, since eval loss diverges more cleanly). Both restore your model and optimizer state afterward, so the probe is non-destructive.
Key highlights
- One-liner API:
range_test()→plot()→reset() - Gradient accumulation support for simulating larger batch sizes
- Mixed precision via both
apex.ampandtorch.amp - Handles non-standard DataLoader output shapes through
TrainDataLoaderIter/ValDataLoaderIterwrappers - ~1,000 stars, actively maintained with CI and codecov
Caveats
- The linear/evaluation mode can be “significantly longer” with a large validation set
- Your optimizer must not already have an LR scheduler attached
- Data must arrive
(input, label)-ready; anything else needs the iterator workaround
Verdict Useful if you’re training PyTorch models from scratch and tired of grid-searching learning rates. Skip it if you’re already in the Hugging Face ecosystem or using fastai directly, which bundles similar functionality.