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

Provide access to unwrapped model in Lite #12597

Merged
merged 17 commits into from
May 11, 2022
Merged

Conversation

awaelchli
Copy link
Contributor

@awaelchli awaelchli commented Apr 3, 2022

What does this PR do?

Fixes #12596

This PR enables attribute pass-through on the _LiteModule wrapper. When an attribute is not found on the wrapper, it tries to look it up on the original model that was passed into the setup method.

The _LiteModule wrapper now takes an optional argument original_module, which is the one passed in to the Lite.setup method. If we didn't do this, we wouldn't be able to access it, because the forward_module is potentially already wrapped by something like DistributedDataParallel.

Breaking change

This is a breaking change if you previously relied on LiteModule.state_dict() to save or load checkpoints. The old checkpoint won't load after this PR because of missing keys (_original_module, _forward_module).

Before submitting

  • Was this discussed/approved via a GitHub issue? (not for typos and docs)
  • 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?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • 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:

  • 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

Did you have fun?

I made sure I had fun coding 🙃

cc @Borda @tchaton @rohitgr7 @carmocca @justusschock @awaelchli

@awaelchli awaelchli added feature Is an improvement or enhancement fabric lightning.fabric.Fabric labels Apr 3, 2022
@awaelchli awaelchli marked this pull request as ready for review April 6, 2022 03:31
@carmocca carmocca added this to the 1.6.x milestone Apr 12, 2022
pytorch_lightning/lite/wrappers.py Show resolved Hide resolved
pytorch_lightning/lite/wrappers.py Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@mergify mergify bot added the ready PRs ready to be merged label Apr 12, 2022
@mergify mergify bot added has conflicts and removed ready PRs ready to be merged labels Apr 21, 2022
@mergify mergify bot added ready PRs ready to be merged and removed has conflicts ready PRs ready to be merged labels Apr 25, 2022
@awaelchli awaelchli marked this pull request as ready for review May 8, 2022 20:44
Copy link
Contributor

@akihironitta akihironitta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm 🚀

@mergify mergify bot added has conflicts and removed ready PRs ready to be merged labels May 9, 2022
@awaelchli awaelchli enabled auto-merge (squash) May 10, 2022 04:01
@mergify mergify bot added ready PRs ready to be merged has conflicts and removed has conflicts ready PRs ready to be merged labels May 10, 2022
@awaelchli
Copy link
Contributor Author

Gatekeeper merge

@mergify mergify bot added ready PRs ready to be merged and removed has conflicts ready PRs ready to be merged labels May 11, 2022
@awaelchli awaelchli merged commit d243617 into master May 11, 2022
@awaelchli awaelchli deleted the feature/lite-module-access branch May 11, 2022 18:28
@carmocca carmocca modified the milestones: 1.6.x, 1.7 May 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fabric lightning.fabric.Fabric feature Is an improvement or enhancement priority: 0 High priority task ready PRs ready to be merged
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Provide access to unwrapped module in Lite
7 participants