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
[dispatcher] avoid autograd fixup step on non-backend keys #46135
Conversation
[ghstack-poisoned]
ghstack-source-id: c0139a203e9684dea35c9dd22487d06f641a325a Pull Request resolved: #46135
💊 CI failures summary and remediationsAs of commit cb02402 (more details on the Dr. CI page):
This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions on the GitHub issue tracker or post in the (internal) Dr. CI Users group. This comment has been revised 16 times. |
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.
Thanks!!
Previously we were unconditionally running the autograd fixup post-processing step in `updateDispatchTable_()`, even when the key being updated wasn't a backend key. This wasn't failing because `getAutogradKeyFromBackend()` would default to `AutogradOther` for non-backend keys. (So the extra call wasn't doing any damage, just resynching AutogradOther a bit more than necessary :P). Reviewer notes: here's everything in the diff: 1. Main change is just the `isBackendDispatchKey()` guard on the fixup step 2. ...along with that new helper function. 3. With this change I was able to tighten the definition of `getAutogradKeyFromBackend()` to avoid leaking `AutogradOther`. 4. This actually led me to another such leak: `UndefinedTensorImpl` was adding `AutogradOther` to its `key_set_` as a result of calling `getAutogradKeyFromBackend(DispatchKey::Undefined)`. Avoided this with a guard in `TensorImpl`'s constructor. The new overhead seems tolerable; I think the only hygienic alternative would be to refactor the key_set initialization so TensorImpl and UndefinedTensorImpl have different paths. Didn't seem worth it? 5. The rest is some minor code movement to get things in the right header files for the new predicate functions, and autofixing some whitespace errors from the comments PR. Differential Revision: [D24235974](https://our.internmc.facebook.com/intern/diff/D24235974) [ghstack-poisoned]
Previously we were unconditionally running the autograd fixup post-processing step in `updateDispatchTable_()`, even when the key being updated wasn't a backend key. This wasn't failing because `getAutogradKeyFromBackend()` would default to `AutogradOther` for non-backend keys. (So the extra call wasn't doing any damage, just resynching AutogradOther a bit more than necessary :P). Reviewer notes: here's everything in the diff: 1. Main change is just the `isBackendDispatchKey()` guard on the fixup step 2. ...along with that new helper function. 3. With this change I was able to tighten the definition of `getAutogradKeyFromBackend()` to avoid leaking `AutogradOther`. 4. This actually led me to another such leak: `UndefinedTensorImpl` was adding `AutogradOther` to its `key_set_` as a result of calling `getAutogradKeyFromBackend(DispatchKey::Undefined)`. Avoided this with a guard in `TensorImpl`'s constructor. The new overhead seems tolerable; I think the only hygienic alternative would be to refactor the key_set initialization so TensorImpl and UndefinedTensorImpl have different paths. Didn't seem worth it? 5. The rest is some minor code movement to get things in the right header files for the new predicate functions, and autofixing some whitespace errors from the comments PR. Differential Revision: [D24235974](https://our.internmc.facebook.com/intern/diff/D24235974) [ghstack-poisoned]
ghstack-source-id: e5ba3f793a9f885b0df82c7d8259eb2dc089a269 Pull Request resolved: #46135
Codecov Report
@@ Coverage Diff @@
## gh/bhosmer/53/base #46135 +/- ##
=====================================================
Coverage ? 68.26%
=====================================================
Files ? 410
Lines ? 53608
Branches ? 0
=====================================================
Hits ? 36593
Misses ? 17015
Partials ? 0 Continue to review full report at Codecov.
|
Stack from ghstack:
Previously we were unconditionally running the autograd fixup post-processing step in
updateDispatchTable_()
, even when the key being updated wasn't a backend key. This wasn't failing becausegetAutogradKeyFromBackend()
would default toAutogradOther
for non-backend keys. (So the extra call wasn't doing any damage, just resynching AutogradOther a bit more than necessary :P).Reviewer notes: here's everything in the diff:
isBackendDispatchKey()
guard on the fixup stepDifferential Revision: D24235974