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

Bugfix/5487 auto lr ordering #5638

Merged
merged 35 commits into from
Feb 1, 2021

Conversation

noamzilo
Copy link
Contributor

@noamzilo noamzilo commented Jan 24, 2021

What does this PR do?

before: auto learning rate finder fails AFTER optimization due to misconfiguration
after: auto learning rate finder fails BEFORE optimization due to misconfiguration, and user can fail faster.

Fixes #5487

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
  • Check that target branch and milestone match!

Did you have fun?

Make sure you had fun coding 🙃

@pep8speaks
Copy link

pep8speaks commented Jan 24, 2021

Hello @noamzilo! Thanks for updating this PR.

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

Comment last updated at 2021-02-01 13:09:50 UTC

@noamzilo
Copy link
Contributor Author

To the maintainers:

I have added a test that requires pip install pytest-timeout

Currently, I am getting the error

_______________ ERROR collecting tests/trainer/test_lr_finder.py _______________
'timeout' not found in markers configuration option
_______________ ERROR collecting tests/trainer/test_lr_finder.py _______________
'timeout' not found in markers configuration option

Will it be possible to install this library so the test will pass?

If not, please recommend what I should use instead so I will be able to change the code.

@carmocca
Copy link
Contributor

test that requires pip install pytest-timeout

why is it required?

If you are just changing the order of the check, we probably don't need a test for it. Usually you want to test your changes but there's no need to test the call order. And if there was, you could do it by mocking the called functions and checking the order.

@noamzilo
Copy link
Contributor Author

noamzilo commented Jan 25, 2021

test that requires pip install pytest-timeout

why is it required?

If you are just changing the order of the check, we probably don't need a test for it. Usually you want to test your changes but there's no need to test the call order. And if there was, you could do it by mocking the called functions and checking the order.

actually the call order that wasn't tested is what is PR is about. I could just delete the test... should I do that? I think this tests that the user experience is such that no waiting for errors can occur, not just that the calls happen in order.

About the code comment - will commit the str return soon.

@Borda Borda added the bug Something isn't working label Jan 25, 2021
@Borda Borda added this to the 1.1.x milestone Jan 25, 2021
@Borda Borda requested a review from carmocca January 26, 2021 23:40
Copy link
Contributor

@tchaton tchaton left a comment

Choose a reason for hiding this comment

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

LGTM !

rohitgr7
rohitgr7 previously approved these changes Jan 29, 2021
tests/trainer/test_lr_finder.py Outdated Show resolved Hide resolved
pytorch_lightning/tuner/lr_finder.py Outdated Show resolved Hide resolved
pytorch_lightning/tuner/lr_finder.py Outdated Show resolved Hide resolved
tests/trainer/test_lr_finder.py Outdated Show resolved Hide resolved
tests/trainer/flags/test_fast_dev_run.py Show resolved Hide resolved
pytorch_lightning/tuner/lr_finder.py Outdated Show resolved Hide resolved
pytorch_lightning/tuner/lr_finder.py Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Jan 30, 2021

Codecov Report

Merging #5638 (042bfda) into master (d71659b) will decrease coverage by 0%.
The diff coverage is 92%.

@@           Coverage Diff           @@
##           master   #5638    +/-   ##
=======================================
- Coverage      93%     93%    -0%     
=======================================
  Files         134     134            
  Lines       10056    9919   -137     
=======================================
- Hits         9399    9241   -158     
- Misses        657     678    +21     

@rohitgr7 rohitgr7 enabled auto-merge (squash) February 1, 2021 13:52
@rohitgr7 rohitgr7 merged commit 9174fab into Lightning-AI:master Feb 1, 2021
tchaton pushed a commit that referenced this pull request Feb 5, 2021
* started to write failing test. just getting into the framework...

* started to write failing test. just getting into the framework...

* added failing test for misconfiguration of lr finder

* made test startup quickly. making sure without the fix it also fails slowly

* improved test

* fixed for linter

* fixed for linter

* yet another fix for the linter

* yet another fix for the linter

* fixed comment by @carmocca

* fixed comment by @carmocca

* Fix test

* chlog

* Apply suggestions from code review

* Fix test

* Update pytorch_lightning/tuner/lr_finder.py

Co-authored-by: Rohit Gupta <rohitgr1998@gmail.com>

* Update pytorch_lightning/tuner/lr_finder.py

Co-authored-by: Rohit Gupta <rohitgr1998@gmail.com>

* Update tests/trainer/test_lr_finder.py

* Update pytorch_lightning/tuner/lr_finder.py

Co-authored-by: Rohit Gupta <rohitgr1998@gmail.com>

* Update pytorch_lightning/tuner/lr_finder.py

Co-authored-by: Rohit Gupta <rohitgr1998@gmail.com>

* Update pytorch_lightning/tuner/lr_finder.py

* Update tests/trainer/test_lr_finder.py

Co-authored-by: Carlos Mocholí <carlossmocholi@gmail.com>
Co-authored-by: Jirka Borovec <jirka.borovec@seznam.cz>
Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Rohit Gupta <rohitgr1998@gmail.com>
Borda added a commit that referenced this pull request Feb 5, 2021
* started to write failing test. just getting into the framework...

* started to write failing test. just getting into the framework...

* added failing test for misconfiguration of lr finder

* made test startup quickly. making sure without the fix it also fails slowly

* improved test

* fixed for linter

* fixed for linter

* yet another fix for the linter

* yet another fix for the linter

* fixed comment by @carmocca

* fixed comment by @carmocca

* Fix test

* chlog

* Apply suggestions from code review

* Fix test

* Update pytorch_lightning/tuner/lr_finder.py

Co-authored-by: Rohit Gupta <rohitgr1998@gmail.com>

* Update pytorch_lightning/tuner/lr_finder.py

Co-authored-by: Rohit Gupta <rohitgr1998@gmail.com>

* Update tests/trainer/test_lr_finder.py

* Update pytorch_lightning/tuner/lr_finder.py

Co-authored-by: Rohit Gupta <rohitgr1998@gmail.com>

* Update pytorch_lightning/tuner/lr_finder.py

Co-authored-by: Rohit Gupta <rohitgr1998@gmail.com>

* Update pytorch_lightning/tuner/lr_finder.py

* Update tests/trainer/test_lr_finder.py

Co-authored-by: Carlos Mocholí <carlossmocholi@gmail.com>
Co-authored-by: Jirka Borovec <jirka.borovec@seznam.cz>
Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Rohit Gupta <rohitgr1998@gmail.com>
Borda added a commit that referenced this pull request Feb 5, 2021
* started to write failing test. just getting into the framework...

* started to write failing test. just getting into the framework...

* added failing test for misconfiguration of lr finder

* made test startup quickly. making sure without the fix it also fails slowly

* improved test

* fixed for linter

* fixed for linter

* yet another fix for the linter

* yet another fix for the linter

* fixed comment by @carmocca

* fixed comment by @carmocca

* Fix test

* chlog

* Apply suggestions from code review

* Fix test

* Update pytorch_lightning/tuner/lr_finder.py

Co-authored-by: Rohit Gupta <rohitgr1998@gmail.com>

* Update pytorch_lightning/tuner/lr_finder.py

Co-authored-by: Rohit Gupta <rohitgr1998@gmail.com>

* Update tests/trainer/test_lr_finder.py

* Update pytorch_lightning/tuner/lr_finder.py

Co-authored-by: Rohit Gupta <rohitgr1998@gmail.com>

* Update pytorch_lightning/tuner/lr_finder.py

Co-authored-by: Rohit Gupta <rohitgr1998@gmail.com>

* Update pytorch_lightning/tuner/lr_finder.py

* Update tests/trainer/test_lr_finder.py

Co-authored-by: Carlos Mocholí <carlossmocholi@gmail.com>
Co-authored-by: Jirka Borovec <jirka.borovec@seznam.cz>
Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Rohit Gupta <rohitgr1998@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

auto learning rate finder fails AFTER optimization due to misconfiguration
7 participants