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

[2/2] Remove outputs from evaluation epoch end hooks #7338

Merged
merged 26 commits into from
May 5, 2021

Conversation

ananthsub
Copy link
Contributor

@ananthsub ananthsub commented May 4, 2021

What does this PR do?

This addresses part of #6865 and undoes #6120.

This is inclusive of changes in #7339 .

Because outputs as part of the evaluation epoch end hooks were never part of a stable release, we can safely change the signature and remove the arguments without worrying about backwards compatibility or breaking changes.

We do so because we no longer have a mechanism to not store step outputs during training if any callback or module needs to run something at the end of the epoch which doesn't rely on the outputs. Traditionally, this was the differentiator between validation_epoch_end defined as a method on the LightningModule vs on_validation_epoch_end which takes no arguments and is available in both the callbacks and lightning module via hooks.

As a result, we see increased memory pressure which both slows down training and puts us at greater risk of OOMs, especially for large scale training.

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 🙃

@codecov
Copy link

codecov bot commented May 4, 2021

Codecov Report

Merging #7338 (c489e8b) into master (6104a63) will decrease coverage by 0%.
The diff coverage is 100%.

@@          Coverage Diff           @@
##           master   #7338   +/-   ##
======================================
- Coverage      88%     87%   -0%     
======================================
  Files         200     200           
  Lines       12985   12982    -3     
======================================
- Hits        11400   11357   -43     
- Misses       1585    1625   +40     

@ananthsub ananthsub changed the title Remove outputs from evaluation epoch end hooks [wip] Remove outputs from evaluation epoch end hooks May 4, 2021
@Borda Borda added the refactor label May 4, 2021
@Borda Borda marked this pull request as draft May 4, 2021 06:43
@ananthsub ananthsub force-pushed the fix-rm-outputs-eval-epoch-end branch from 48dfcd3 to f694c31 Compare May 4, 2021 06:55
@pep8speaks
Copy link

pep8speaks commented May 4, 2021

Hello @ananthsub! Thanks for updating this PR.

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

Comment last updated at 2021-05-05 15:29:06 UTC

@ananthsub ananthsub changed the title [wip] Remove outputs from evaluation epoch end hooks [2/2] Remove outputs from evaluation epoch end hooks May 4, 2021
@ananthsub ananthsub force-pushed the fix-rm-outputs-eval-epoch-end branch from f694c31 to 38a572d Compare May 4, 2021 07:09
@ananthsub ananthsub added this to the v1.3 milestone May 4, 2021
@ananthsub ananthsub added the design Includes a design discussion label May 4, 2021
@ananthsub ananthsub marked this pull request as ready for review May 4, 2021 07:56
@mergify mergify bot added the has conflicts label May 4, 2021
@ananthsub ananthsub linked an issue May 4, 2021 that may be closed by this pull request
@ananthsub ananthsub force-pushed the fix-rm-outputs-eval-epoch-end branch from 58450ba to 446b731 Compare May 4, 2021 15:22
@mergify mergify bot removed the has conflicts label May 4, 2021
@ananthsub ananthsub force-pushed the fix-rm-outputs-eval-epoch-end branch from 62a4327 to d3ef271 Compare May 4, 2021 23:23
@maximsch2
Copy link
Contributor

If you are doing deprecation anyway, would it make sense to also consolidate naming? Right now we have on_train_epoch_end, on_validation_epoch_end, on_test_epoch_end
training_step, validation_step, test_step

Would be nice if *_step and _epoch_end would match up?

@ananthsub
Copy link
Contributor Author

@maximsch2 I'd prefer to tackle naming separately: #6094 lays out a number of inconsistencies which we need to address

@Borda Borda added the _Will label May 5, 2021
@mergify mergify bot added the has conflicts label May 5, 2021
@ananthsub ananthsub force-pushed the fix-rm-outputs-eval-epoch-end branch from 876079e to 90db4c6 Compare May 5, 2021 15:25
@mergify mergify bot removed the has conflicts label May 5, 2021
Copy link
Contributor

@edgarriba edgarriba left a comment

Choose a reason for hiding this comment

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

LGTM. Just fix failing test

CHANGELOG.md Show resolved Hide resolved
@ananthsub
Copy link
Contributor Author

@awaelchli the faiilng test is related to the worker init fn check. I'm seeing if this was fixed in pytorch 1.9

@awaelchli
Copy link
Contributor

we added 1.9 just today. I'm sure it's not related to your PR.
Will take a look, I have 1.9 installed somewhere

@Borda Borda enabled auto-merge (squash) May 5, 2021 17:25
@Borda
Copy link
Member

Borda commented May 5, 2021

@ananthsub shall we add the docs about cache here?

@ananthsub
Copy link
Contributor Author

@ananthsub shall we add the docs about cache here?

Sent out #7389 for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design Includes a design discussion refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove duplicate epoch_end hooks in the Lightning Module
7 participants