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

Revisit usage of _MockOptimizer #11178

Closed
ananthsub opened this issue Dec 20, 2021 · 1 comment
Closed

Revisit usage of _MockOptimizer #11178

ananthsub opened this issue Dec 20, 2021 · 1 comment
Labels
design Includes a design discussion optimizer won't fix This will not be worked on

Comments

@ananthsub
Copy link
Contributor

ananthsub commented Dec 20, 2021

In #1279, support for returning None from configure_optimizers was added to Lightning. The use case was training without an optimizer. This preceded support for manual optimization, in which the user controls the backward & optimizer step directly inside of their training step.

The _MockOptimizer leaks out like this which could be very confusing for developers.

class MyLightningModule(LightningModule):
    def configure_optimizers():
        return None

    def training_step(batch, batch_idx):
        opt = self.optimizers()
        # opt is not None! what?!
  • Is training with no optimizer a valid use case Lightning supports? Are there examples/references one could share to learn more about these use cases?
  • If the Trainer creates a mock optimizer for users, should the mock optimizer ever be exposed back to the user?
  • If training with no optimizer is a valid use case, should we require users to use manual optimization for this, so we don't configure a mock optimizer instance for them?

Originally posted by @ananthsub in #11155 (comment)

cc @tchaton @justusschock @awaelchli @Borda @rohitgr7

@stale
Copy link

stale bot commented Jan 21, 2022

This issue has been automatically marked as stale because it hasn't had any recent activity. This issue will be closed in 7 days if no further activity occurs. Thank you for your contributions, Pytorch Lightning Team!

@stale stale bot added the won't fix This will not be worked on label Jan 21, 2022
@stale stale bot closed this as completed Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design Includes a design discussion optimizer won't fix This will not be worked on
Projects
None yet
Development

No branches or pull requests

1 participant