-
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
Fix LightningCLI saving hyperparameters breaking change #20068
Fix LightningCLI saving hyperparameters breaking change #20068
Conversation
… breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick fix @mauvilsa. This seems very specific to I also seem to be missing many class parameters with default values that are not listed in the YAML file, and/or optional values that default to None.init_args
and ignores dict_kwargs
.
EDIT: It's possible no special handling is needed for dict_kwargs
.
Steps to reproduce are identical to #19977 (comment), but replace from lightning.pytorch import LightningModule
class Model(LightningModule):
def __init__(self, learning_rate, step_size=None):
super().__init__()
self.save_hyperparameters()
assert 'learning_rate' in self.hparams
assert 'step_size' in self.hparams
def training_step(*args):
pass
def configure_optimizers(*args):
pass The code will fail because |
Indeed, there was a bug.
It is needed. It is now fixed and I added a new unit test based on your code snippet which includes @adamjstewart please check again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passes all TorchGeo tests now, thanks for the quick fix!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @mauvilsa, very appreciated!
Thanks @mauvilsa @adamjstewart for the help here 🚀 |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #20068 +/- ##
=========================================
- Coverage 90% 82% -9%
=========================================
Files 266 263 -3
Lines 22942 22891 -51
=========================================
- Hits 20722 18670 -2052
- Misses 2220 4221 +2001 |
What does this PR do?
Changes the
LightningCLI
'sload_from_checkpoint
support such that the hparams are not saved with theclass_path
andinit_args
structure, since this constitutes a breaking change which we failed to notice in #18105.Fixes #19977
Before submitting
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:
Reviewer checklist
📚 Documentation preview 📚: https://pytorch-lightning--20068.org.readthedocs.build/en/20068/