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

[FEAT] Add lambda closure to manual_optimizer_step #4618

Merged
merged 22 commits into from
Nov 12, 2020

Conversation

tchaton
Copy link
Contributor

@tchaton tchaton commented Nov 11, 2020

What does this PR do?

This PR adds the possibility for the user to add its own lambda_closure.

Resolving #4485

Before submitting

  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
  • 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? Otherwise, we ask you to create a separate PR for every change.
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?
  • Did you verify new and existing tests pass locally with your changes?
  • If you made a notable change (that affects users), did you update the CHANGELOG?

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 in short, see 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; Bugfixes should be including in bug-fix release milestones (m.f.X) and features should be included in (m.X.b) releases.

Did you have fun?

Make sure you had fun coding 🙃

@tchaton tchaton added the design Includes a design discussion label Nov 11, 2020
@tchaton tchaton added this to the 1.0.7 milestone Nov 11, 2020
@tchaton tchaton self-assigned this Nov 11, 2020
@pep8speaks
Copy link

pep8speaks commented Nov 11, 2020

Hello @tchaton! Thanks for updating this PR.

Line 724:64: E261 at least two spaces before inline comment
Line 784:64: E261 at least two spaces before inline comment
Line 861:34: E203 whitespace before ':'

Comment last updated at 2020-11-12 17:19:35 UTC

@codecov
Copy link

codecov bot commented Nov 11, 2020

Codecov Report

Merging #4618 (2c4cd1c) into master (bacabae) will increase coverage by 0%.
The diff coverage is 94%.

@@          Coverage Diff           @@
##           master   #4618   +/-   ##
======================================
  Coverage      93%     93%           
======================================
  Files         117     117           
  Lines        8898    8906    +8     
======================================
+ Hits         8267    8275    +8     
  Misses        631     631           

@tchaton tchaton changed the title [WIP] Add lambda closure to manual_optimizer_step Add lambda closure to manual_optimizer_step Nov 11, 2020
@tchaton tchaton changed the title Add lambda closure to manual_optimizer_step [FEAT] Add lambda closure to manual_optimizer_step Nov 11, 2020
@tchaton tchaton modified the milestones: 1.0.7, 1.1 Nov 11, 2020
@tchaton tchaton added the bug Something isn't working label Nov 11, 2020
@Borda Borda added this to the 1.0.x milestone Nov 11, 2020
@SeanNaren
Copy link
Contributor

@tchaton Could you expose the args/kwargs also within the accelerator optimizer steps? There are a few places where the optimizer_step is overridden in our acceleartors.

Copy link
Member

@Borda Borda 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 still reading the tests... :]

pytorch_lightning/accelerators/accelerator.py Show resolved Hide resolved
.gitignore Show resolved Hide resolved
pytorch_lightning/core/lightning.py Show resolved Hide resolved
pytorch_lightning/core/lightning.py Show resolved Hide resolved
pytorch_lightning/core/lightning.py Show resolved Hide resolved
pytorch_lightning/core/lightning.py Outdated Show resolved Hide resolved
tests/trainer/optimization/test_manual_optimization.py Outdated Show resolved Hide resolved
tests/trainer/optimization/test_manual_optimization.py Outdated Show resolved Hide resolved
tests/trainer/optimization/test_manual_optimization.py Outdated Show resolved Hide resolved
tests/trainer/optimization/test_manual_optimization.py Outdated Show resolved Hide resolved
@tchaton tchaton merged commit 4018237 into master Nov 12, 2020
@tchaton tchaton deleted the fix/manual_optimizer_step branch November 12, 2020 19:22
Borda pushed a commit that referenced this pull request Nov 12, 2020
* added lambda_closure

* move to types

* add 2 new tests

* make example more complex

* add complex example to doc

* added more tests

* resolve doc

* typo

* update

* update tpu optimizer_step

* Apply suggestions from code review

* Update pytorch_lightning/core/lightning.py

Co-authored-by: Jirka Borovec <[email protected]>

* update

Co-authored-by: Jirka Borovec <[email protected]>

(cherry picked from commit 4018237)
Borda pushed a commit that referenced this pull request Nov 12, 2020
* added lambda_closure

* move to types

* add 2 new tests

* make example more complex

* add complex example to doc

* added more tests

* resolve doc

* typo

* update

* update tpu optimizer_step

* Apply suggestions from code review

* Update pytorch_lightning/core/lightning.py

Co-authored-by: Jirka Borovec <[email protected]>

* update

Co-authored-by: Jirka Borovec <[email protected]>

(cherry picked from commit 4018237)
Borda pushed a commit that referenced this pull request Nov 12, 2020
* added lambda_closure

* move to types

* add 2 new tests

* make example more complex

* add complex example to doc

* added more tests

* resolve doc

* typo

* update

* update tpu optimizer_step

* Apply suggestions from code review

* Update pytorch_lightning/core/lightning.py

Co-authored-by: Jirka Borovec <[email protected]>

* update

Co-authored-by: Jirka Borovec <[email protected]>

(cherry picked from commit 4018237)
tchaton added a commit that referenced this pull request Nov 17, 2020
* added lambda_closure

* move to types

* add 2 new tests

* make example more complex

* add complex example to doc

* added more tests

* resolve doc

* typo

* update

* update tpu optimizer_step

* Apply suggestions from code review

* Update pytorch_lightning/core/lightning.py

Co-authored-by: Jirka Borovec <[email protected]>

* update

Co-authored-by: Jirka Borovec <[email protected]>
rohitgr7 pushed a commit that referenced this pull request Nov 21, 2020
* added lambda_closure

* move to types

* add 2 new tests

* make example more complex

* add complex example to doc

* added more tests

* resolve doc

* typo

* update

* update tpu optimizer_step

* Apply suggestions from code review

* Update pytorch_lightning/core/lightning.py

Co-authored-by: Jirka Borovec <[email protected]>

* update

Co-authored-by: Jirka Borovec <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working design Includes a design discussion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants