Skip to content

[refactor] Add state_dict to loops#8197

Merged
carmocca merged 18 commits intomasterfrom
add_loop_state_dicts
Jul 1, 2021
Merged

[refactor] Add state_dict to loops#8197
carmocca merged 18 commits intomasterfrom
add_loop_state_dicts

Conversation

@tchaton
Copy link
Copy Markdown
Contributor

@tchaton tchaton commented Jun 29, 2021

What does this PR do?

This PR adds the templating logic for loops state. This would be used by Fault Tolerant Logic.

Before submitting

  • Was this discussed/approved via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

PR review

Anyone in the community is free to review the PR once the tests have passed.
Before you start reviewing make sure you have read Review guidelines. In short, see the following bullet-list:

  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

Did you have fun?

Make sure you had fun coding 🙃

@tchaton tchaton self-assigned this Jun 29, 2021
@tchaton tchaton added this to the v1.4 milestone Jun 29, 2021
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 29, 2021

Codecov Report

Merging #8197 (342853c) into master (3e6f884) will decrease coverage by 5%.
The diff coverage is 96%.

@@           Coverage Diff           @@
##           master   #8197    +/-   ##
=======================================
- Coverage      93%     88%    -5%     
=======================================
  Files         212     212            
  Lines       13679   13695    +16     
=======================================
- Hits        12720   12052   -668     
- Misses        959    1643   +684     

@tchaton tchaton marked this pull request as ready for review June 29, 2021 12:41
Comment thread pytorch_lightning/loops/fit_loop.py Outdated
Comment thread pytorch_lightning/loops/fit_loop.py Outdated
Comment thread pytorch_lightning/loops/epoch/training_epoch_loop.py
Comment thread pytorch_lightning/loops/dataloader/evaluation_loop.py Outdated
Comment thread pytorch_lightning/loops/base.py
Comment thread pytorch_lightning/loops/dataloader/evaluation_loop.py Outdated
Comment thread pytorch_lightning/loops/fit_loop.py Outdated
Copy link
Copy Markdown
Contributor

@ananthsub ananthsub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you have examples of what types of state the loop needs to save/load?

@carmocca
Copy link
Copy Markdown
Contributor

carmocca commented Jun 29, 2021

do you have examples of what types of state the loop needs to save/load?

Namely progress (dataclasses) and results (ResultCollection)

trainer
    loops:
        fit_loop:
            epoch_loop:
                batch_loop:
                val_loop:
                    ...
        validate_loop:
            ...
        test_loop:
            ...
------
and each loop has:
a_loop:
    progress
    results

Comment thread pytorch_lightning/loops/base.py Outdated
Comment thread pytorch_lightning/loops/base.py Outdated
Comment thread pytorch_lightning/loops/batch/training_batch_loop.py Outdated
Comment thread pytorch_lightning/loops/batch/training_batch_loop.py Outdated
Comment thread pytorch_lightning/loops/epoch/training_epoch_loop.py
Comment thread pytorch_lightning/loops/epoch/training_epoch_loop.py Outdated
Comment thread pytorch_lightning/loops/fit_loop.py
Comment thread pytorch_lightning/trainer/properties.py Outdated
Comment thread pytorch_lightning/trainer/properties.py Outdated
Comment thread pytorch_lightning/loops/fit_loop.py Outdated
@tchaton tchaton requested a review from carmocca June 30, 2021 16:43
@carmocca carmocca force-pushed the add_loop_state_dicts branch from 113c569 to 3d748cb Compare June 30, 2021 16:53
Copy link
Copy Markdown
Contributor

@ananthsub ananthsub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you describe how the trainer will resume the states? at what point is the loop's load_state_dict called?

also does what requirements does this impose on composition of loops?

Comment thread pytorch_lightning/loops/base.py
Comment thread tests/loops/test_loops.py
Comment thread pytorch_lightning/trainer/properties.py Outdated
Comment thread tests/loops/ test_loop_state_dict.py
@tchaton tchaton enabled auto-merge (squash) July 1, 2021 09:23
@tchaton tchaton disabled auto-merge July 1, 2021 09:23
@tchaton tchaton enabled auto-merge (squash) July 1, 2021 09:24
Comment thread pytorch_lightning/trainer/properties.py Outdated
@carmocca carmocca disabled auto-merge July 1, 2021 09:53
@carmocca carmocca enabled auto-merge (squash) July 1, 2021 09:54
@carmocca carmocca disabled auto-merge July 1, 2021 14:08
@carmocca carmocca enabled auto-merge (squash) July 1, 2021 14:08
@carmocca carmocca merged commit d51b0ae into master Jul 1, 2021
@carmocca carmocca deleted the add_loop_state_dicts branch July 1, 2021 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants