-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Add get_stream_from_external API for XPU backend #141123
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
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/141123
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 36097ef with merge base d88a8c4 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
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!
Just a quick test to make sure it behaves as expected and why the Stream object constructor was changed!
@@ -390,6 +390,17 @@ static void initXpuMethodBindings(PyObject* module) { | |||
"torch.xpu.mem_get_info requires PyTorch to be built with SYCL compiler version 2025.0.0 or newer."); | |||
#endif | |||
}); | |||
m.def( |
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 for using pybind here for easier to read python binding! :)
torch/csrc/xpu/Stream.cpp
Outdated
if (!PyArg_ParseTupleAndKeywords( | ||
args, | ||
kwargs, | ||
"|iLLL", | ||
"|iLLLK", |
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.
Why did you add this to the base Stream constructor? We don't actually use it here?
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 originally wanted to align with the constructor of CUDA's base Stream. It is okay to remove it. And add it back if really needed in future.
It is hard to add a quick test to validate this API. Unlike cudart in PyTorch, XPU couldn't create an external sycl queue by PyTorch since it doesn't have the wrapper of sycl runtime. I have to test this API on my local machine. |
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.
Ok!
Pull Request resolved: #143799 Approved by: https://github.com/albanD, https://github.com/EikanWang ghstack dependencies: #142347, #141119, #141123
# Motivation As mentioned in pytorch#141119 (comment), we properly handle the priority value if it is outside of the priority range. # Additional Context If the value falls outside of the allowed priority range, it will automatically be mapped to the nearest valid priority(either lowest or highest). Pull Request resolved: pytorch#143849 Approved by: https://github.com/albanD, https://github.com/EikanWang ghstack dependencies: pytorch#142347, pytorch#141119, pytorch#141123, pytorch#143799
Stack from ghstack (oldest at bottom):
Motivation
This PR aims to introduce
torch.xpu.ExternalStream
to be used to wrap SYCL queue created in other libraries to PyTorch.Additional Context
cc @gujinghui @EikanWang @fengyuan14