Lightning-AI / Lightning-AI/pytorch-lightning

Allow `extra_epochs` flag in `Trainer.fit` to control finetuning time

Open
#13,273 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question trainer: argument
Dominant language
Python
Stars
31.4k
Forks
3.8k
Avg merge
6d 7h
Merged PRs (30d)
6

Description

## 🚀 Feature

`Trainer(max_epochs=100).fit(model, train_dl, ckpt_path=ckpt_path, extra_epochs=True)` would finetune for 100 epochs

### Motivation

Finetuning for N epochs requires knowing the previous number of epochs M and setting `Trainer(max_epochs=M+N)`. Google did not tell me how to achieve this.

### Pitch

Finetuning training time or number of epochs should be configurable.

### Alternatives

Setting many epochs and manually stopping

### Additional context

It would be cool with `max_time` too. I hope this is already solved and this issue is unnecessary.
______________________________________________________________________

cc @justusschock @kaushikb11 @awaelchli @borda @rohitgr7

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Trainer.fit entry point and inspect how ckpt_path restores the previous epoch and how max_epochs is interpreted. Define the expected behavior for extra_epochs=True, including the max_time idea only if it is in scope, and add or update tests showing that finetuning runs for the requested additional epochs.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.