Schedule-Free is a PyTorch library that provides optimizers designed for 'schedule-free' learning, eliminating the need for traditional learning rate schedules. It aims to achieve faster training times without requiring users to specify the stopping time or steps in advance. The library, currently at version 1.4.1, offers variants of popular optimizers like SGD, AdamW, and RAdam, and is actively maintained by Facebook Research.
pip install schedulefreeVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to integrate `AdamWScheduleFree` into a basic PyTorch training loop. Key steps include initializing the optimizer, performing forward/backward passes, and crucially, calling `optimizer.train()` and `optimizer.eval()` alongside `model.train()` and `model.eval()` for correct parameter buffer handling during training and evaluation/checkpointing.
Ensure `optimizer.train()` is called before the training step and `optimizer.eval()` before any evaluation or checkpoint saving. Alternatively, use `ScheduleFreeClosure` versions if your code supports PyTorch Optimizer step closures, as these do not require explicit `train()`/`eval()` calls.
If replicating results from versions prior to 1.3, use `AdamWScheduleFreePaper` which retains the older weight decay implementation.
Consult the official documentation or examples for specific guidance on handling BatchNorm layers with Schedule-Free optimizers. Using PreciseBN is also suggested to avoid this issue.
Experiment with `beta` values like `0.95` or `0.98`, especially for extended training sessions, if initial results are suboptimal.
Begin hyperparameter tuning with higher learning rates for Schedule-Free optimizers compared to what you would use for their traditional counterparts.
Add `optimizer.train()` at the beginning of your training epoch or step, similar to how `model.train()` is used.
Implement explicit handling for BatchNorm layers during evaluation to ensure statistics are correctly updated from the `x` sequence, or use `PreciseBN` if applicable.
Tune the learning rate (often higher than traditional optimizers, e.g., 10x-50x for SGD, 1x-10x for AdamW) and regularization parameters. Consider increasing the `beta` value for very long training runs (e.g., to 0.95 or 0.98).