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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move logger and profiler finalization to trainer's teardown #8685

Merged
merged 8 commits into from Aug 5, 2021
Merged

Move logger and profiler finalization to trainer's teardown #8685

merged 8 commits into from Aug 5, 2021

Conversation

tangbinh
Copy link
Contributor

@tangbinh tangbinh commented Aug 2, 2021

What does this PR do?

Previously, profiler finalization was implemented in multiple places, including the evaluation loop, prediction loop, and fit loop. Logger finalization, however, was included in the fit loop only, leading to Issue #8333.

Here, we move the logger and profiler finalization to the _call_teardown_hook in the trainer and call the hook from each process in case of DDP or TPU training. See #8217 for more contexts and discussions (cc @ananthsub).

Does your PR introduce any breaking changes? If yes, please list them.

None

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 list all the breaking changes introduced by this pull request?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

PR review

Anyone in the community is welcome to review the PR.
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 Aug 2, 2021

Codecov Report

Merging #8685 (580c882) into master (963c267) will decrease coverage by 4%.
The diff coverage is 75%.

@@           Coverage Diff           @@
##           master   #8685    +/-   ##
=======================================
- Coverage      93%     89%    -4%     
=======================================
  Files         169     169            
  Lines       14072   14071     -1     
=======================================
- Hits        13043   12464   -579     
- Misses       1029    1607   +578     

Copy link
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.

be sure to update the changelog as well

pytorch_lightning/plugins/training_type/ddp_spawn.py Outdated Show resolved Hide resolved
pytorch_lightning/trainer/trainer.py Show resolved Hide resolved
pytorch_lightning/trainer/trainer.py Outdated Show resolved Hide resolved
@pep8speaks
Copy link

pep8speaks commented Aug 2, 2021

Hello @tangbinh! Thanks for updating this PR. We checked the lines you've touched for PEP聽8 issues, and found:

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

Comment last updated at 2021-08-04 22:00:03 UTC

@ananthsub ananthsub added this to the v1.5 milestone Aug 2, 2021
@ananthsub ananthsub linked an issue Aug 2, 2021 that may be closed by this pull request
Copy link
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.

please update the changelog with this fix as well: https://github.com/PyTorchLightning/pytorch-lightning/blob/master/CHANGELOG.md

Copy link
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.

@tangbinh - could you also add a test that confirms that the logger is finalized when calling trainer.fit, trainer.validate, trainer.test, and trainer.predict?

you can see tests/trainer/logging_/test_distributed_logging.py & https://github.com/PyTorchLightning/pytorch-lightning/pull/8608/files for examples of integration tests between the trainer and loggers.

you can create a dummy logger or mock and confirm that finalize is called

@ananthsub ananthsub added logger Related to the Loggers profiler labels Aug 3, 2021
@awaelchli awaelchli changed the title [refactor] Move logger and profiler finalization to trainer's teardown Move logger and profiler finalization to trainer's teardown Aug 3, 2021
@awaelchli awaelchli added the bug Something isn't working label Aug 3, 2021
Copy link
Member

@awaelchli awaelchli left a comment

Choose a reason for hiding this comment

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

overall LGTM :) thanks for working on it

pytorch_lightning/plugins/training_type/ddp_spawn.py Outdated Show resolved Hide resolved
Copy link
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.

LGTM, but please address @awaelchli 's comment on comments as well

pytorch_lightning/trainer/trainer.py Outdated Show resolved Hide resolved
@mergify mergify bot added the ready PRs ready to be merged label Aug 4, 2021
CHANGELOG.md Outdated Show resolved Hide resolved
@mergify mergify bot added the has conflicts label Aug 4, 2021
@mergify mergify bot removed the has conflicts label Aug 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working logger Related to the Loggers profiler ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Logger isn't finalized upon test/predict completion
7 participants