-
Notifications
You must be signed in to change notification settings - Fork 24.3k
[dynamo] Emit warning on global module hooks when calling using output of torch.compile(module)
#152740
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
[dynamo] Emit warning on global module hooks when calling using output of torch.compile(module)
#152740
Changes from all commits
2d239dc
2d177d8
1f6e933
355780d
f8c4dc1
File filter
Filter by extension
8000 Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,6 +118,18 @@ def __setstate__(self, state: dict): | |
_global_forward_hooks_always_called: dict[int, bool] = OrderedDict() | ||
_global_forward_hooks_with_kwargs: dict[int, bool] = OrderedDict() | ||
|
||
|
||
def _has_any_global_hook(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure why you want from this but if you want minimal overhead, you want boolean conversions here: return not(_global_backward_pre_hooks or _global_backward_hooks ...) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I always found implicit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is a bit confusing sometimes I agree. But in this case, we saw in other cases that is a few orders of magnitude faster... So I guess worth it... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. perf is worth it given that these checks are called in the hotpath There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (it's not clear to me if you resolved this already or not) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Already updated:). |
||
return ( | ||
_global_backward_pre_hooks | ||
or _global_backward_hooks | ||
or _global_forward_pre_hooks | ||
or _global_forward_hooks | ||
or _global_forward_hooks_always_called | ||
or _global_forward_hooks_with_kwargs | ||
) | ||
|
||
|
||
_EXTRA_STATE_KEY_SUFFIX = "_extra_state" | ||
|
||
|
||
|
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.
could you figure out the right int to as stacklevel?
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.
Updated