A PyTorch Lightning extension that enhances model experimentation with flexible fine-tuning schedules.
FinetuningScheduler is simple to use yet powerful, offering a number of features that facilitate model research and exploration:
- easy specification of flexible fine-tuning schedules with explicit or regex-based parameter selection
- implicit schedules for initial/naive model exploration
- explicit schedules for performance tuning, fine-grained behavioral experimentation and computational efficiency
- automatic restoration of best per-phase checkpoints driven by iterative application of early-stopping criteria to each fine-tuning phase
- composition of early-stopping and manually-set epoch-driven fine-tuning phase transitions
Starting with version 2.10, uv is the preferred installation approach for Fine-Tuning Scheduler.
# Install uv if you haven't already (one-time setup)
curl -LsSf https://astral.sh/uv/install.sh | sh
# Install Fine-Tuning Scheduler
uv pip install finetuning-schedulerAdditional installation options
uv pip install finetuning-scheduler['examples']uv pip install finetuning-scheduler['all']The build_fts_env.sh script automatically handles Lightning commit pinning and optional PyTorch nightly installation:
git clone https://github.com/speediedan/finetuning-scheduler.git
cd finetuning-scheduler
# Standard development build (handles Lightning pin automatically and builds with PyTorch nightly (if configured in requirements/ci/torch-nightly.txt)
./scripts/build_fts_env.sh --repo_home=${PWD} --target_env_name=fts_latest --venv-dir=/path/to/.venvs
# Activate (use your venv base path)
export FTS_VENV_BASE=~/.venvs # or /mnt/cache/${USER}/.venvs
export FTS_VENV_NAME=fts_latest
source ${FTS_VENV_BASE}/${FTS_VENV_NAME}/bin/activategit clone https://github.com/speediedan/finetuning-scheduler.git
cd finetuning-scheduler
# Set UV_OVERRIDE to use the pinned Lightning commit
export UV_OVERRIDE=${PWD}/requirements/ci/overrides.txt
uv pip install -e ".[all]"When torch-nightly.txt is configured, use a two-step installation approach:
git clone https://github.com/speediedan/finetuning-scheduler.git
cd finetuning-scheduler
# Step 1: Install PyTorch nightly (adjust version and CUDA target as needed)
uv pip install --prerelease=if-necessary-or-explicit torch==2.10.0.dev20251124 \
--index-url https://download.pytorch.org/whl/nightly/cu128
# Step 2: Install FTS with Lightning commit pin (torch already installed, will be skipped)
export UV_OVERRIDE=${PWD}/requirements/ci/overrides.txt
uv pip install -e ".[all]"The nightly version is specified in requirements/ci/torch-nightly.txt and documented in
requirements/ci/torch_override.txt for reference.
export FTS_VERSION=2.6.0
export PACKAGE_NAME=pytorch
git clone -b v${FTS_VERSION} https://github.com/speediedan/finetuning-scheduler
cd finetuning-scheduler
export UV_OVERRIDE=${PWD}/requirements/ci/overrides.txt
uv pip install -e ".[all]"Note, publishing of new finetuning-scheduler version-specific docker images was paused after the 2.0.2 patch release. If new version-specific images are required, please raise an issue.
import lightning as L
from finetuning_scheduler import FinetuningScheduler
trainer = L.Trainer(callbacks=[FinetuningScheduler()])Get started by following the Fine-Tuning Scheduler introduction which includes a CLI-based example or by following the notebook-based Fine-Tuning Scheduler tutorial.
applicable to versions >= 2.0.0
Now that the core Lightning package is lightning rather than pytorch-lightning, Fine-Tuning Scheduler (FTS) by default depends upon the lightning package rather than the standalone pytorch-lightning. If you would like to continue to use FTS with the standalone pytorch-lightning package instead, you can still do so as follows:
Install a given FTS release (for example v2.0.0) using standalone pytorch-lightning:
export FTS_VERSION=2.0.0
export PACKAGE_NAME=pytorch
wget https://github.com/speediedan/finetuning-scheduler/releases/download/v${FTS_VERSION}/finetuning-scheduler-${FTS_VERSION}.tar.gz
uv pip install finetuning-scheduler-${FTS_VERSION}.tar.gzFTS (as of version 2.6.0) now enables dynamic versioning both at installation time and via CLI post-installation. Initially, the dynamic versioning system allows toggling between Lightning unified and standalone imports. The two conversion operations are individually idempotent and mutually reversible.
FTS provides a simple CLI tool to easily toggle between unified and standalone import installation versions post-installation:
# Toggle from unified to standalone Lightning imports
toggle-lightning-mode --mode standalone
# Toggle from standalone to unified Lightning imports (default)
toggle-lightning-mode --mode unifiedNote: If you have the standalone package (
pytorch-lightning) installed but not the unified package (lightning), toggling to unified mode will be prevented. You must install thelightningpackage first before toggling.
This can be useful when:
- You need to adapt existing code to work with a different Lightning package
- You're switching between projects using different Lightning import styles
- You want to test compatibility with both import styles
- Notebook-based Tutorial
- CLI-based Tutorial
- FSDP Scheduled Fine-Tuning
- LR Scheduler Reinitialization (advanced)
- Optimizer Reinitialization (advanced)
Fine-Tuning Scheduler is rigorously tested across multiple CPUs, GPUs and against major Python and PyTorch versions.
Versioning Policy (Updated in 2.9): Starting with the 2.9 minor release, Fine-Tuning Scheduler is pivoting from tight Lightning version alignment to core PyTorch version alignment. This change:
- Provides greater flexibility to integrate the latest PyTorch functionality increasingly important in research
- Reduces maintenance burden while continuing to support the stable Lightning API and robust integration
- Officially supports at least the latest 4 PyTorch minor releases (e.g., when PyTorch 2.9 is released, FTS supports >= 2.6)
This versioning approach is motivated by Lightning's evolving release cadence (see Lightning Issue #21073 and PR #21107) and allows FTS to adopt new PyTorch capabilities more rapidly while maintaining clear deprecation policies.
See the versioning documentation for complete details on compatibility policies and migration guidance.
Prior Versioning (< 2.9): Each Fine-Tuning Scheduler minor release (major.minor.patch) was paired with a Lightning minor release (e.g., Fine-Tuning Scheduler 2.0 depends upon Lightning 2.0). To ensure maximum stability, the latest Lightning patch release fully tested with Fine-Tuning Scheduler was set as a maximum dependency in Fine-Tuning Scheduler's requirements.txt (e.g., <= 1.7.1).
Current build statuses for Fine-Tuning Scheduler
| System / (PyTorch/Python ver) | 2.6.0/3.9 | 2.10.0/3.9, 2.10.0/3.12 |
|---|---|---|
| Linux [GPUs**] | - | |
| Linux (Ubuntu 22.04) | ||
| OSX (14) | ||
| Windows (2022) |
- ** tests run on one RTX 4090 and one RTX 2070
Fine-Tuning Scheduler is developed and maintained by the community in close communication with the Lightning team. Thanks to everyone in the community for their tireless effort building and improving the immensely useful core Lightning project.
PR's welcome! Please see the contributing guidelines (which are essentially the same as Lightning's).
Please cite:
@misc{Dan_Dale_2022_6463952,
author = {Dan Dale},
title = {{Fine-Tuning Scheduler}},
month = Feb,
year = 2022,
doi = {10.5281/zenodo.6463952},
publisher = {Zenodo},
url = {https://zenodo.org/record/6463952}
}Feel free to star the repo as well if you find it useful or interesting. Thanks 😊!
