-
Notifications
You must be signed in to change notification settings - Fork 25.7k
Update custom Function preserve torch function when inputs returned as-is #109825
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
…s-is [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/109825
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit b184a54 with merge base 255d1a7 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
| }; | ||
|
|
||
| auto view_as_fn = [](const at::Tensor& x, const at::Tensor& y) -> at::Tensor { | ||
| pybind11::gil_scoped_acquire gil; |
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.
I'm not actually sure we need this since we are calling from Python and we don't release the gil, but jvp_user_function does it.
| pybind11::gil_scoped_acquire gil; | ||
| py::object py_x = py::cast(x); | ||
| py::function py_view_as_method = py_x.attr("view_as"); | ||
| return py_view_as_method(y).cast<at::Tensor>(); |
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 do a quick local check with %timeit to make sure this is not making this case significantly slower please?
If it does, we should use our direct APIs via THPVariable_wrap and cie to avoid the pybind overhead.
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.
I did a quick test, and it seems that this PR adds 0.3-4 us of overhead, but avoiding use of pybind can cut 0.1 us of that away.
- Current: 2.66 us
- Without pybind: 2.95 us
- With pybind 3.05 us
I've updated this PR to avoid using pybind to avoid that overhead.
… returned as-is" Fixes #109805 [ghstack-poisoned]
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!
|
@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 |
Merge failedReason: 1 mandatory check(s) failed. The first few are: Dig deeper by viewing the failures on hud |
|
Failures look legit, going to investigate. |
… returned as-is" Fixes #109805 [ghstack-poisoned]
This failures is a expected result of the bug fix. The failure occurs in a test that tests that DDP properly fails when used with LazyModule. The difference is now that we now fail earlier with a different error message. When DDP tries to replicate the module it calls Broadcast, which is a custom Function that returns input as-is. LazyModules have parameters of instance UninitializedTensorMixin which has a |
… returned as-is" Fixes #109805 [ghstack-poisoned]
|
@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 |
|
@pytorchbot revert -m "causing a plethora of internal failures" -c ghfirst |
|
@pytorchbot successfully started a revert job. Check the current status here. |
|
@soulitzer your PR has been successfully reverted. |
…turned as-is (#109825)" This reverts commit 4e73eee. Reverted #109825 on behalf of https://github.com/PaliC due to causing a plethora of internal failures ([comment](#109825 (comment)))
…r… (pytorch#110679) Summary: …eturned as-is reland of pytorch#109825 (comment) Opening this without ghstack to do codev. In our PR, we changed the signature of `_wrap_outputs`. There is some internal code that calls `_wrap_outputs` directly, so we also need to update that callsite. Differential Revision: D49983654 Pulled By: soulitzer
#110679) …eturned as-is reland of #109825 (comment) Opening this without ghstack to do codev. In our PR, we changed the signature of `_wrap_outputs`. There is some internal code that calls `_wrap_outputs` directly, so we also need to update that callsite. Pull Request resolved: #110679 Approved by: https://github.com/albanD
…r… (pytorch#110679) Summary: …eturned as-is reland of pytorch#109825 (comment) Opening this without ghstack to do codev. In our PR, we changed the signature of `_wrap_outputs`. There is some internal code that calls `_wrap_outputs` directly, so we also need to update that callsite. Differential Revision: D49983654 Pulled By: soulitzer
Stack from ghstack (oldest at bottom):
Fixes #109805