-
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
Accelerator model state dict #7474
Accelerator model state dict #7474
Conversation
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags:
…oint_consolidate Update test_all_gather_grad.py
This reverts commit 9d4a2b8.
This reverts commit 0d23d75.
This reverts commit 70fe5da.
This reverts commit a9aae99.
This reverts commit ea74906.
This reverts commit bf70e43.
This reverts commit f172101.
This reverts commit 536c132.
This reverts commit 3a9fde9.
This reverts commit 7a369f4.
This reverts commit 8222dc9.
This reverts commit 6c095b2.
This reverts commit 250d0aa.
This reverts commit 8651d54.
This reverts commit dcdcd29.
Codecov Report
@@ Coverage Diff @@
## master #7474 +/- ##
=======================================
- Coverage 92% 88% -4%
=======================================
Files 199 199
Lines 13030 13057 +27
=======================================
- Hits 11989 11431 -558
- Misses 1041 1626 +585 |
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.
pytorch_lightning/plugins/training_type/training_type_plugin.py
Outdated
Show resolved
Hide resolved
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.
do you see a good way to unit test the state dict being exposed from the accelerator?
@@ -420,6 +420,12 @@ def optimizer_state(self, optimizer: Optimizer) -> Dict[str, Tensor]: | |||
""" | |||
return getattr(self.training_type_plugin, 'optimizer_state', lambda x: x.state_dict())(optimizer) | |||
|
|||
def state_dict(self) -> Dict[str, Union[Any, Tensor]]: |
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.
why the union with tensor? same for L429
def state_dict(self) -> Dict[str, Union[Any, Tensor]]: | |
def state_dict(self) -> Dict[str, Any]: |
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.
Oh, I just follow the same type defined below for on_save
, but I think you are right, Dict[str, Any]
should be enough
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.
@ananthsub I added the Union here originally, I think. This was done since it often is a tensor, but doesn't have to. And if you omit the tensor here, IDEs don't show the autocomplete-suggestions for Tensors
pytorch_lightning/plugins/training_type/training_type_plugin.py
Outdated
Show resolved
Hide resolved
will check if we already have some existing test for state dict, if not, i will come up with something. |
pytorch_lightning/plugins/training_type/training_type_plugin.py
Outdated
Show resolved
Hide resolved
@@ -420,6 +420,12 @@ def optimizer_state(self, optimizer: Optimizer) -> Dict[str, Tensor]: | |||
""" | |||
return getattr(self.training_type_plugin, 'optimizer_state', lambda x: x.state_dict())(optimizer) | |||
|
|||
def state_dict(self) -> Dict[str, Union[Any, Tensor]]: |
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.
@ananthsub I added the Union here originally, I think. This was done since it often is a tensor, but doesn't have to. And if you omit the tensor here, IDEs don't show the autocomplete-suggestions for Tensors
What does this PR do?
Fixes #7470
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 🙃