Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Refactor] Improve loops API 1/n #8334

Merged
merged 30 commits into from
Jul 12, 2021
Merged

[Refactor] Improve loops API 1/n #8334

merged 30 commits into from
Jul 12, 2021

Conversation

tchaton
Copy link
Contributor

@tchaton tchaton commented Jul 8, 2021

What does this PR do?

This PR adds functionalities to the loop similar to torch nn.Module for checkpointing.

Next PR: #8362

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)
  • Did you list all the breaking changes introduced by this pull request?

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 added this to the v1.4 milestone Jul 8, 2021
@tchaton tchaton requested a review from awaelchli as a code owner July 8, 2021 10:42
@tchaton tchaton self-assigned this Jul 8, 2021
@codecov
Copy link

codecov bot commented Jul 8, 2021

Codecov Report

Merging #8334 (350abea) into master (e9d0fe8) will decrease coverage by 5%.
The diff coverage is 100%.

@@           Coverage Diff           @@
##           master   #8334    +/-   ##
=======================================
- Coverage      93%     88%    -5%     
=======================================
  Files         214     216     +2     
  Lines       13914   14097   +183     
=======================================
- Hits        12897   12404   -493     
- Misses       1017    1693   +676     

pytorch_lightning/loops/base.py Outdated Show resolved Hide resolved
pytorch_lightning/loops/base.py Outdated Show resolved Hide resolved
Copy link
Member

@justusschock justusschock left a comment

Choose a reason for hiding this comment

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

TBH: I am not sure why we really need most of the stuff here. I left some comments, but IMO all the information about parents and children is not really required.

pytorch_lightning/loops/base.py Outdated Show resolved Hide resolved
pytorch_lightning/loops/base.py Outdated Show resolved Hide resolved
pytorch_lightning/loops/base.py Outdated Show resolved Hide resolved
pytorch_lightning/loops/base.py Outdated Show resolved Hide resolved
pytorch_lightning/loops/base.py Outdated Show resolved Hide resolved
pytorch_lightning/loops/base.py Outdated Show resolved Hide resolved
pytorch_lightning/loops/base.py Outdated Show resolved Hide resolved
pytorch_lightning/loops/base.py Outdated Show resolved Hide resolved
pytorch_lightning/loops/base.py Outdated Show resolved Hide resolved
@edenlightning edenlightning modified the milestones: v1.4, v1.5 Jul 9, 2021
@tchaton tchaton mentioned this pull request Jul 10, 2021
12 tasks
@tchaton tchaton modified the milestones: v1.5, v1.4 Jul 10, 2021
@tchaton tchaton changed the title [Refactor] Improve loops API [Refactor] Improve loops API 1/n Jul 11, 2021
pytorch_lightning/loops/base.py Outdated Show resolved Hide resolved
pytorch_lightning/loops/base.py Outdated Show resolved Hide resolved
@pep8speaks
Copy link

pep8speaks commented Jul 12, 2021

Hello @tchaton! Thanks for updating this PR.

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2021-07-12 09:47:46 UTC

CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Member

@justusschock justusschock left a comment

Choose a reason for hiding this comment

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

Looks good to me overall. Just some comments

CHANGELOG.md Outdated Show resolved Hide resolved
pytorch_lightning/loops/base.py Outdated Show resolved Hide resolved
pytorch_lightning/loops/base.py Show resolved Hide resolved
pytorch_lightning/loops/base.py Outdated Show resolved Hide resolved
@tchaton tchaton enabled auto-merge (squash) July 12, 2021 10:01
@tchaton tchaton merged commit 370fa67 into master Jul 12, 2021
@tchaton tchaton deleted the loop_improvement branch July 12, 2021 11:13
tests/loops/test_loop_state_dict.py Show resolved Hide resolved
@@ -88,11 +102,7 @@ def run(self, *args: Any, **kwargs: Any) -> Optional[Any]:
if self.skip:
return self.on_skip()

if self.restarting:
Copy link
Contributor

Choose a reason for hiding this comment

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

So why do we not want the restarting property anymore?

And why did you leave it in the __init__?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is still used in reset self.restarting. Check #8364.

Adrian convinced me it was cleaner to make it manual.

self.restarting is automatically set to True by the Trainer when calling loop load_state_dict function.

Copy link
Contributor

Choose a reason for hiding this comment

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

Where exactly is that PR setting restarting on the loops?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tests/loops/test_loops.py Show resolved Hide resolved
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.

7 participants