-
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 ShardedDataParallel has no attribute require_backward_grad_sync #6915
Conversation
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.
Neat !
Hello @awaelchli! Thanks for updating this PR. There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2021-04-10 14:58:35 UTC |
@@ -33,6 +36,7 @@ def configure_ddp(self): | |||
self._model = ShardedDataParallel( | |||
LightningShardedDataParallel(self.model), sharded_optimizer=self.lightning_module.trainer.optimizers | |||
) | |||
setattr(self._model, "require_backward_grad_sync", False) |
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.
nit: why setattr
instead of self._model.require_backward_grad_sync = False
?
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.
because the model here is ShardedDataParallel
and this attribute is only available for the DistributedDataParallel
.
We check for this attribute in manual optmization.
unrelated (?) tests are failing now for unknown reason :( |
Codecov Report
@@ Coverage Diff @@
## master #6915 +/- ##
======================================
- Coverage 92% 92% -0%
======================================
Files 194 194
Lines 12336 12346 +10
======================================
+ Hits 11322 11328 +6
- Misses 1014 1018 +4 |
What does this PR do?
Fixes #6804
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 🙃