8000 Add get_stream_from_external API for XPU backend by guangyey · Pull Request #141123 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

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

Closed
wants to merge 42 commits into from

Conversation

guangyey
Copy link
Collaborator
@guangyey guangyey commented Nov 20, 2024

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

Copy link
pytorch-bot bot commented Nov 20, 2024

🔗 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 Failures

As of commit 36097ef with merge base d88a8c4 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@guangyey guangyey changed the title Support ExternalStream for XPU backend [WIP] Support ExternalStream for XPU backend Nov 20, 2024
guangyey added a commit that referenced this pull request Nov 20, 2024
ghstack-source-id: 48cddef
Pull Request resolved: #141123
@guangyey guangyey marked this pull request as draft November 20, 2024 11:36
[ghstack-poisoned]
[ghstack-poisoned]
@guangyey guangyey added ciflow/xpu Run XPU CI tasks release notes: xpu release notes category module: xpu Intel XPU related issues labels Nov 21, 2024
@guangyey guangyey marked this pull request as ready for review November 21, 2024 04:29
@guangyey guangyey changed the title [WIP] Support ExternalStream for XPU backend Support ExternalStream for XPU backend Nov 21, 2024
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
guangyey added a commit that referenced this pull request Nov 21, 2024
ghstack-source-id: 6ddeb54
Pull Request resolved: #141123
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
@guangyey guangyey changed the title Support ExternalStream for XPU backend Add get_stream_from_external API for XPU backend Dec 24, 2024
@guangyey guangyey requested a review from albanD December 24, 2024 10:20
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
Copy link
Collaborator
@albanD albanD left a 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(
Copy link
Collaborator

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! :)

if (!PyArg_ParseTupleAndKeywords(
args,
kwargs,
"|iLLL",
"|iLLLK",
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

@guangyey
Copy link
Collaborator Author

Thanks! Just a quick test to make sure it behaves as expected and why the Stream object constructor was changed!

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.

[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
Copy link
Collaborator
@albanD albanD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok!

[ghstack-poisoned]
[ghstack-poisoned]
pytorchmergebot pushed a commit that referenced this pull request Dec 31, 2024
pull bot pushed a commit to mcx/pytorch that referenced this pull request Dec 31, 2024
# 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
@github-actions github-actions bot deleted the gh/guangyey/100/head branch February 1, 2025 02:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/trunk Trigger trunk jobs on your pull request ciflow/xpu Run XPU CI tasks Merged module: xpu Intel XPU related issues open source release notes: xpu release notes category
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

6 participants
0