Skip to content

Conversation

@ZhiweiYan-96
Copy link
Collaborator

@ZhiweiYan-96 ZhiweiYan-96 commented Jul 4, 2024

Motivation

copy, cdist, index_put_impl operators use op_stub for runtime dispatching inside operators. Extra device list is inside them to assure the accuracy, while XPU is not in them. This PRs make them allow XPU as a supported device.

Stack from ghstack (oldest at bottom):

cc @gujinghui @EikanWang @fengyuan14 @guangyey

[ghstack-poisoned]
@pytorch-bot
Copy link

pytorch-bot bot commented Jul 4, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/130088

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 89c3b89 with merge base 6cbb143 (image):
💚 Looks good so far! There are no failures yet. 💚

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

ZhiweiYan-96 added a commit that referenced this pull request Jul 4, 2024
ghstack-source-id: 7eedcd5
Pull Request resolved: #130088
@ZhiweiYan-96 ZhiweiYan-96 reopened this Jul 4, 2024
@ZhiweiYan-96 ZhiweiYan-96 marked this pull request as draft July 4, 2024 03:17
[ghstack-poisoned]
[ghstack-poisoned]
ZhiweiYan-96 added a commit that referenced this pull request Jul 4, 2024
ghstack-source-id: 5274ff1
Pull Request resolved: #130088
[ghstack-poisoned]
ZhiweiYan-96 added a commit that referenced this pull request Jul 5, 2024
ghstack-source-id: b7186b9
Pull Request resolved: #130088
@ZhiweiYan-96 ZhiweiYan-96 added ciflow/xpu Run XPU CI tasks ciflow/trunk Trigger trunk jobs on your pull request labels Jul 5, 2024
[ghstack-poisoned]
[ghstack-poisoned]
ZhiweiYan-96 added a commit that referenced this pull request Jul 9, 2024
ghstack-source-id: 7b7f255
Pull Request resolved: #130088
@ZhiweiYan-96 ZhiweiYan-96 requested a review from EikanWang July 10, 2024 06:01
[ghstack-poisoned]
@ZhiweiYan-96 ZhiweiYan-96 added the module: xpu Intel XPU related issues label Jul 11, 2024
@ZhiweiYan-96 ZhiweiYan-96 marked this pull request as ready for review July 12, 2024 06:17
[ghstack-poisoned]
ZhiweiYan-96 added a commit that referenced this pull request Jul 26, 2024
ghstack-source-id: 21876e0
Pull Request resolved: #130088

Add XPU into device list of cdist_impl

ghstack-source-id: 21876e0
Pull Request resolved: #130412
[ghstack-poisoned]
[ghstack-poisoned]
ZhiweiYan-96 added a commit that referenced this pull request Jul 26, 2024
ghstack-source-id: e657758
Pull Request resolved: #130088

Add XPU into device list of cdist_impl

ghstack-source-id: e657758
Pull Request resolved: #130412
@EikanWang
Copy link
Collaborator

@ZhiweiYan-96 , please add test cases.

@ZhiweiYan-96
Copy link
Collaborator Author

ZhiweiYan-96 commented Jul 30, 2024

hi @EikanWang The test case depends on the structure codegen change in torch-xpu-ops repo. We may add test case accompanied with xpu-ops commit change after PR in torch-xpu-ops merged.

@EikanWang
Copy link
Collaborator

hi @EikanWang The test case depends on the structure codegen change in torch-xpu-ops repo. We may add test case accompanied with xpu-ops commit change after PR in torch-xpu-ops merged.

Thanks for the information. @atalman FYI

device_type = kHIP;
} else if (iter.device_type(1) == kMPS) {
device_type = kMPS;
} else if (iter.device_type(1) == kXPU){
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we make this accelerator device check?

Copy link
Collaborator Author

@ZhiweiYan-96 ZhiweiYan-96 Aug 2, 2024

Choose a reason for hiding this comment

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

hi @albanD We may need keep this device check as this code is intended to use accelerator kernel once any of tensor(src/dst) is on accelerator device. I think XPU logic also should have same logic like cuda/mps here. Otherwise, we may fail to propagate the device into copy_stub following. If my understanding here is wrong, could you please correct me? Thanks.

Copy link
Collaborator

@EikanWang EikanWang Aug 3, 2024

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

From a closer look, I retract my statemnet. The only difference with handling any accelerator here would be that PrivateUse1 would be handled as well. But that mens that this would force the copy kernel to be done via copy_stub for privateuse1 as opposed to today where _copy_from() is being called and can be overwritten as any other dispatcher op.

at::OptionalIntArrayRef dim, const std::optional<Scalar>& correction_opt,
bool keepdim, bool take_sqrt) {
TORCH_CHECK(self.device().is_cpu() || self.device().is_cuda(),
TORCH_CHECK(self.device().is_cpu() || self.device().is_cuda() || self.device().is_xpu(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Update error message here and below

Copy link
Collaborator Author

@ZhiweiYan-96 ZhiweiYan-96 Aug 2, 2024

Choose a reason for hiding this comment

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

Thanks for your kindly reminding! I would add the XPU into error messages

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Has updated the error message, thank you so much for the comments!

[ghstack-poisoned]
ZhiweiYan-96 added a commit that referenced this pull request Aug 3, 2024
ghstack-source-id: 36a7439
Pull Request resolved: #130088

Add XPU into device list of cdist_impl

ghstack-source-id: 36a7439
Pull Request resolved: #130412
TORCH_CHECK(self.device().is_cpu() || self.device().is_cuda(),
"std and var only supports tensors on a CPU or CUDA device, but got: ",
TORCH_CHECK(self.device().is_cpu() || self.device().is_cuda() || self.device().is_xpu(),
"std and var only supports tensors on a CPU or CUDA/XPU device, but got: ",
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about?

Suggested change
"std and var only supports tensors on a CPU or CUDA/XPU device, but got: ",
"std and var supports tensors on CPU, CUDA, or XPU devices only, but got: ",

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 have modified the message here, thanks for the suggestions!

[ghstack-poisoned]
ZhiweiYan-96 added a commit that referenced this pull request Aug 5, 2024
ghstack-source-id: 7fed97a
Pull Request resolved: #130088

Add XPU into device list of cdist_impl

ghstack-source-id: 7fed97a
Pull Request resolved: #130412
@EikanWang EikanWang requested a review from albanD August 5, 2024 03:24
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!
Thanks for the update

@ZhiweiYan-96
Copy link
Collaborator Author

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: This PR needs a release notes: label
If your changes are user facing and intended to be a part of release notes, please use a label starting with release notes:.

If not, please add the topic: not user facing label.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "topic: not user facing"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

Details for Dev Infra team Raised by workflow job

@ZhiweiYan-96
Copy link
Collaborator Author

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

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 topic: not user facing topic category

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

7 participants