-
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
[bugfix] Prevent deepcopy of dataloaders / Trainer in SWA Callback #8472
Conversation
Codecov Report
@@ Coverage Diff @@
## master #8472 +/- ##
======================================
Coverage 92% 92%
======================================
Files 217 217
Lines 14342 14367 +25
======================================
+ Hits 13236 13260 +24
- Misses 1106 1107 +1 |
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.
Pushed a few commits with some changes
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.
LGTM!
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.
If I understand this PR correctly, all the changes are specific to the pruning etc. callbacks. can you confirm the following:
- pickling behavior unchanged
- deepcopy(model) still does a real deepcopy unless the context manager is used
- the context manager is not meant to be used by the user, or is it? any other use cases for deepcopying a lightnignmodule?
Yes, exactly ! |
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.
Great!
Excluding the dataloaders here may not be necessary in the future if we avoid this weird patching of LightningModule methods: #6030
What does this PR do?
This PR introduces a context manager to prevent deecopying trainer / dataloaders from the LightningModule.
This PR uses this context manager to prevent with stochastic weight averaging
This PR improve ModelPruning save_checkpoint to avoid a deepcopy.
Fixes #7089
Does your PR introduce any breaking changes ? If yes, please list them.
No.
Before submitting
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:
Did you have fun?
Make sure you had fun coding 🙃