[Schedule][replace] Transfer hooks when replacing modules#27
Merged
szhengac merged 2 commits intoawslabs:mainfrom Jan 30, 2023
Merged
[Schedule][replace] Transfer hooks when replacing modules#27szhengac merged 2 commits intoawslabs:mainfrom
szhengac merged 2 commits intoawslabs:mainfrom
Conversation
szhengac
reviewed
Jan 30, 2023
| HOOK_TYPE_TO_ATTR = { | ||
| "fwd_pre": ("_forward_pre_hooks", "register_forward_pre_hook"), | ||
| "fwd_post": ("_forward_hooks", "register_forward_hook"), | ||
| "bwd_post": ("_backward_hooks", "register_backward_hook"), |
Contributor
There was a problem hiding this comment.
why don't we also include bwd_pre?
Contributor
Author
There was a problem hiding this comment.
I don't think there's a backward pre-hook in PyTorch?
Contributor
There was a problem hiding this comment.
just found this: https://github.com/pytorch/pytorch/blob/b90496eef5665bc39828f6c1c522f399bcc62f3f/torch/nn/modules/module.py#L92. and it seems it does not appear in 1.12
szhengac
approved these changes
Jan 30, 2023
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The current
.tracedid the following two steps:However, the traced GraphModule won't include any hooks in the original module, so the
.syncprimitives specified before tracing, including.traceand.trace_for_pipelineare dropped. This PR fixes this issue by transferring all hooks from the original module to the new one. For example, a hook registered to broadcast inputs will be transferred 2 times during scheduling:Checklist
cc @szhengac @chhzh123