Lightning-AI / Lightning-AI/pytorch-lightning

How to rollback optimizer step (i.e. reload best checkpoint) during training?

Open
#13,099 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

won't fix
Dominant language
Python
Stars
31.4k
Forks
3.8k
Avg merge
6d 7h
Merged PRs (30d)
6

Description

### Discussed in https://github.com/PyTorchLightning/pytorch-lightning/discussions/13093

Originally posted by **xsys-technology** May 17, 2022
During training, if the optimizer takes a really bad step that sends validation loss through the roof, how can one rollback the step and reload best model checkpoint (and reset logging/pbar results/metrics so that _val_loss_ remains accurate)?

I imagine the preferred way to do this is through a callback function (e.g. '_on_train_epoch_start_') but I'm not sure how to do this properly/safely when the model is dispatched and sharded across gpu's.

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 with the linked discussion #13093 and the callback and checkpoint behavior described in the issue. Determine the required handling for model, optimizer, logging, progress-bar, and validation metrics during sharded multi-GPU training. Done means the rollback behavior and its scope are clearly defined and safely supported.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
distributed-systems, machine-learning
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.