-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Add prepend argument to nn.Module hooks #87370
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
Conversation
[ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/87370
Note: Links to docs will display an error until the docs builds have been completed. ✅ No Failures, 3 PendingAs of commit 510d0aa: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
[ghstack-poisoned]
[ghstack-poisoned]
|
What is the exact use case for which you want this? cc @soulitzer related to hook ordering questions we were having. |
cc ezyang gchanan [ghstack-poisoned]
We are working on converting some distributed features to hook-based solutions, so that we won't mess up FQNs as module wrapper did. To maintain the similar behavior as today DDP/FSDP, we plan to split their forward into top and bottom halves and install those as pre and post forward hooks. And the pre hook needs to be called before any existing hooks on the local module.
This should be OK for now, as we expect DDP logic is added after local model preparations. |
cc ezyang gchanan [ghstack-poisoned]
cc ezyang gchanan [ghstack-poisoned]
Sure, but I'm not sure how to convey that to the end user of this flag in the doc :p (btw docs need updating). |
|
For hooks in general it feels like provide guarantees about ordering is something we'd want to do as long as it doesn't complicate the implementation, so the idea sounds OK. For this case in particular though, communicating to the user about what "prepend" does can be tricky because hooks registered globally will still execute before those prepend, and I'm not sure we even document that anywhere currently? |
|
Hey @albanD @soulitzer, thanks a lot for the comments!
Would I be correct that global hooks are mainly for debugging/profiling purposes. Or have we seen cases where program relies on global hooks to produce correct results?
Any suggestions on which of the following might be better?
Edit: chatted with @albanD offline, since private args will still render in the doc, it's not really private. So let's avoid that. |
cc ezyang gchanan [ghstack-poisoned]
cc ezyang gchanan [ghstack-poisoned]
cc ezyang gchanan [ghstack-poisoned]
cc ezyang gchanan [ghstack-poisoned]
|
Thanks for the updated documentation, looks great.
To explain the ordering of hooks fully, we may also want to think about the interaction of full_backward_pre_hooks with hooks registered to module outputs (but that might be out of the scope of this PR)
We might want to have some documentation regarding module hooks in general now, but that can be done in a follow up. |
cc ezyang gchanan [ghstack-poisoned]
This PR needs a labelIf your changes are user facing and intended to be a part of release notes, please use a label starting with If not, please add the For more information, see https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work. |
cc ezyang gchanan [ghstack-poisoned]
ghstack-source-id: 2c2800e Pull Request resolved: pytorch#87370
|
@pytorchbot merge -g |
Merge startedYour change will be merged once all checks on your PR pass since you used the green (-g) flag (ETA: 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
cc @ezyang @gchanan Pull Request resolved: pytorch#87370 Approved by: https://github.com/soulitzer
cc @ezyang @gchanan Pull Request resolved: pytorch#87370 Approved by: https://github.com/soulitzer




Stack from ghstack (oldest at bottom):
cc @ezyang @gchanan