-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Move code from TrainerOptimizersMixin
into TrainingTypePlugin
#10681
Comments
Thanks for the initiative. I propose to only move the contents of the |
@awaelchli Sounds good!! |
@awaelchli do you mean in |
Yes, basically in core/lightning.py or core/optimizer.py or somewhere there where it's close to the hook that retrieves the optimizers and schedulers from the user ( |
@awaelchli is something like this what you had in mind? class LightningModule(...):
@abstractmethod
def configure_optimizers(self):
....
def init_optimizers_and_lr_schedulers(self) -> TypedDict[...]:
output = self.configure_optimizers()
# parse & validate output
# return components then we could also schematize/add typing for |
@ananthsub it sounds like what you are saying is to move |
I think the caller of |
Proposed refactor
Move all the code from this class to TTP:
https://github.com/PyTorchLightning/pytorch-lightning/blob/2036dfb5df2a48056d1c043ee311aed793187070/pytorch_lightning/trainer/optimizers.py#L28
Motivation
After #10596 the TTP will own the optimizer related logic previously owned by Accelerator. It makes sense for the TTP to also own the optimizer related code in
TrainerOptimizersMixin
. This would allow us to avoid this type of circuitous logic: https://github.com/PyTorchLightning/pytorch-lightning/blob/dcafc95f2b0fd3f176d425139ca99676ce943a12/pytorch_lightning/plugins/training_type/training_type_plugin.py#L244-L245We in general want to reduce the number of mixins (#10417)
cc @justusschock @awaelchli @akihironitta
The text was updated successfully, but these errors were encountered: