Skip to content

Add sycl examples #114

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

ZhaoqiongZ
Copy link
Contributor

Add the example to implement muladd op with SyclExtension

Copy link

@dvrogozh dvrogozh left a comment

Choose a reason for hiding this comment

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

LGTM

@ZhaoqiongZ
Copy link
Contributor Author

Hi @goldsborough @zou3519 , could you help review this PR? Thank you!

@zou3519
Copy link
Contributor

zou3519 commented Jun 12, 2025

What is Sycl?

@dvrogozh
Copy link

What is Sycl?

Sycl is a C++ abstraction for heterogeneous programming allowing to write and execute code (kernels) on GPU devices. That's the way Intel uses to wrote kernels for Intel GPUs. A number of PyTorch aten operators are written using Sycl. And writing Sycl kernels is exposed to PyTorch users thru CPP Extension API. We are trying to update PyTorch tutorials/examples to demonstrate and encourage users to use Sycl to write custom kernels. See https://www.khronos.org/sycl/. Should we add a note on what is SYCL in the project readme?

Copy link
Contributor

@zou3519 zou3519 left a comment

Choose a reason for hiding this comment

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

extension-cpp is supposed to be the "base repository" that people clone to do C++/CUDA extensions. Any special hardwares (or other workflows) is out of scope

@dvrogozh
Copy link

dvrogozh commented Jun 13, 2025

@zou3519, xpu is now one of the official backends included in pytorch. It's backed by SYCL to generate device specific code and pytorch API to allow users create custom operators. Further, pytorch tutorial educates on usage of this API for C++ and CUDA (https://github.com/pytorch/tutorials/blob/main/advanced_source/cpp_custom_ops.rst). The SYCL cpp extension API we've added to pytorch extends this functionality adding SYCL into existing landscape. Obvious step to consider is to extend existing C++ and CUDA tutorial and example to also cover SYCL. It seems you are against this proposal. Can you, please, provide your reasoning to avoid adding SYCL in this tutorial and example and suggest alternative approach which will help to extend pytorch ecosystem to cover devices other than CUDA and other vendors?

fyi, proposal to change tutorial is here:

It's currently draft as it depends on this PR in extension-cpp repository.

@zou3519
Copy link
Contributor

zou3519 commented Jun 25, 2025

and suggest alternative approach which will help to extend pytorch ecosystem to cover devices other than CUDA and other vendors?

I would recommend having a separate extension-sycl repository showing users how to do a sycl extension for XPU. The main reasons are:

  1. if we end up supporting "all backends" in this repository, then this repo will get pretty bloated and difficult to work with. It'll be easier and faster for users to just clone an extension-sycl repo instead of having them clone extension-cpp and deleting the e.g. TPU and CUDA code.
  2. There's no code that is being reused between the SYCL and the CUDA extensions, so I don't see a good reason for putting all the code into one repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants