pytorch-lightning icon indicating copy to clipboard operation
pytorch-lightning copied to clipboard

Profile batch transfer and gradient clipping hooks

Open rohitgr7 opened this issue 3 years ago • 2 comments

What does this PR do?

Fixes #14028

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

Before submitting

  • [x] Was this discussed/approved via a GitHub issue? (not for typos and docs)
  • [x] Did you read the contributor guideline, Pull Request section?
  • [x] 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)
  • [x] Did you write any new necessary tests? (not for typos and docs)
  • [x] Did you verify new and existing tests pass locally with your changes?
  • [x] Did you list all the breaking changes introduced by this pull request?
  • [x] Did you update the CHANGELOG? (not for typos, docs, test updates, or minor internal changes/refactors)

PR review

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

  • [x] Is this pull request ready for review? (if not, please submit in draft mode)
  • [x] Check that all items from Before submitting are resolved
  • [x] Make sure the title is self-explanatory and the description concisely explains the PR
  • [x] 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 🙃

cc @carmocca @kaushikb11 @ninginthecloud @rohitgr7 @nbcsm @guotuofeng @awaelchli @borda @akihironitta

rohitgr7 avatar Aug 06 '22 20:08 rohitgr7

any suggestions for the test here?

I am thinking of extending these with profilers since they cover all the cases with hooks. https://github.com/Lightning-AI/lightning/blob/master/tests/tests_pytorch/models/test_hooks.py

rohitgr7 avatar Aug 08 '22 09:08 rohitgr7

Codecov Report

Merging #14069 (708dca5) into master (e53c4e8) will increase coverage by 25%. The diff coverage is 100%.

@@            Coverage Diff            @@
##           master   #14069     +/-   ##
=========================================
+ Coverage      51%      76%    +25%     
=========================================
  Files         329      329             
  Lines       26640    26687     +47     
=========================================
+ Hits        13657    20277   +6620     
+ Misses      12983     6410   -6573     

codecov[bot] avatar Aug 08 '22 10:08 codecov[bot]

Added the missing chlog entry

awaelchli avatar Aug 11 '22 22:08 awaelchli

Why did we include this in the bug-fix release? Technically this just added a feature (profiling)

carmocca avatar Aug 18 '22 17:08 carmocca

I included it because it was labelled as 1.7.x and also the linked issue had a bug label. This was evidence enough for me that it is correct and intended. If I'm not sure (for example, when linked issue is not also labelled accordingly), I usually ask (https://github.com/Lightning-AI/lightning/pull/9938#issuecomment-1215369656). It also didn't have the breaking change label at the time I cherry picked it

awaelchli avatar Aug 18 '22 17:08 awaelchli

It was totally unintentional. The hook was missing from the logging FxValidator that enabled logging in this hook. The real intention was just to ensure these hooks are profiled, so I added it as a bug, but logging is part of the trainer._call_lightningmodule_hook.

rohitgr7 avatar Aug 18 '22 18:08 rohitgr7