Replace unwrapping logic in strategies
What does this PR do?
Fixes #13502 (main RFC) Fixes #8593 Fixes #13500
The PR looks big, but most complexity turns out to be in the deprecation. The rest of the changes are very thinly spread across multiple files, but are not complex by themselves.
Before, you would do
lightning_module = unwrap_lightning_module(self.model)
Now, directly access it:
lightning_module = self.lightning_module
Terminology:
self.model: refers to a LightningModule that is potentially wrapped
self.lightning_module: is always the pure LightningModule as it gets passed to Trainer.fit by the user. This attribute is read-access only.
TODOs:
- [x] backward compatibility in wrappers/deprecation
Does your PR introduce any breaking changes? If yes, please list them.
No.
Before submitting
- [x] Was this discussed/approved via a GitHub issue? (not for typos and docs)
- [x] Did you read the contributor guideline, Pull Request section?
- [x] Did you make sure your PR does only one thing, instead of bundling different changes together?
- [x] Did you make sure to update the documentation with your changes? (if necessary)
- [x] Did you write any new necessary tests? (not for typos and docs)
- [x] Did you verify new and existing tests pass locally with your changes?
- [x] 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:
- [x] Is this pull request ready for review? (if not, please submit in draft mode)
- [x] Check that all items from Before submitting are resolved
- [x] Make sure the title is self-explanatory and the description concisely explains the PR
- [x] Add labels and milestones (and optionally projects) to the PR so it can be classified
Did you have fun?
I made sure I had fun coding 🙃
Do these changes also suggest we should do some refactor with the _LiteModule? Now that the APIs match.
Do these changes also suggest we should do some refactor with the _LiteModule? Now that the APIs match.
I think this is doesn't have anything to do with the LiteModule. At the moment I don't see more refactors in this direction. But open to suggestions.