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
Add non-recursive module.to_empty option #104197
Add non-recursive module.to_empty option #104197
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/104197
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit a0116cd: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
ghstack-source-id: c3ce9b2281a8b659f8a59c459f622b38ece572c1 Pull Request resolved: #104197
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.
SGTM
Note that this will break any Module that re-defines _apply
with the current signature. No one should be doing that but there is a non-zero probability it is happening in the wild.
@pytorchbot merge |
@albanD ah that is true, hm is there any way to workaround this? (just to check it only breaks those overrides of Upon looking it seems like we do override |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
The merge job was canceled. If you believe this is a mistake,then you can re trigger it through pytorch-bot. |
ghstack-source-id: 1391e6aedd6ab492d9d4551af095cd3203b811e2 Pull Request resolved: #104197
ghstack-source-id: e6e4edb7410125ed07c53e24cc47bc35625afb4e Pull Request resolved: #104197
@@ -65,7 +65,7 @@ def __init__(self, cpp_module): | |||
if not attr.startswith("_"): | |||
setattr(self, attr, getattr(self.cpp_module, attr)) | |||
|
|||
def _apply(self, fn): | |||
def _apply(self, fn, recurse=True): |
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.
this override technically already has the recurse=False behavior and never calls super()._apply
, but adding the kwarg here just so nn.ModuleWrapper
can compose with nn.Module.to_empty()
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
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.
(just to check it only breaks those overrides of _apply that don't define *args and **kwargs is that correct?)
Correct!
Should we change these to *args, **kwargs
btw?
@albanD should we also make that change for other methods other than I can do this in a follow up if that makes sense! |
Yes that can be a follow up for sure. |
Hmm true, does that mean we should have hooks for private |
Fixes #97049, related to #104187
Stack from ghstack: