[SYCL] Adding SYCL backend to support for Intel XPUs - #215
abagusetty wants to merge 12 commits into
Conversation
|
Great feature, thanks! This will take some time to review and test - so bear with us, but with some back and forth we'll see where we land. |
Kernels are generated as SYCL free functions and compiled at runtime through the oneAPI kernel compiler. The Jinja templates are shared with CUDA and HIP via templates/sycl_compat.cuh; the backend is now a string rather than an is_hip boolean, and JITKernel::execute also takes argument sizes.
Mirrors the CUDA job. GitHub offers no Intel GPU runner, so only the build is exercised.
The stable-ABI headers the extension includes are not all present before 2.10, which the precompiled-extension check in extlib has required all along. The SYCL guard now enforces the same floor.
Upstream PASSIONLab#217 replaced HIP's __threadfence_block() with the amdgcn wave barrier, so no template emits the token any more.
69ae39e to
b7381ce
Compare
|
Got a review in progress for this, about 20/50 files in; thanks for the patience, it's going |
Thanks @vbharadwaj-bk Appreciate for going through this. Not a small PR! |
vbharadwaj-bk
left a comment
There was a problem hiding this comment.
@abagusetty I read every one of the + 1375 -270 line diff 😅 actually, I think this will work nicely with our current setup and I have left comments in the files. Much of this is mechanical; high-level, so you can have an LLM take care of some of this
-
LLMs tend to leave a lot of inline / block comments. Let's remove 99% of them, I think there were only one or two comments throughout the entire diff that I felt were necessary to understand something.
-
Let's roll back the changes to group_mm / symmetric contraction, as there is another PR in the queue to address the BLAS dependency and this should no longer be required. Or worst case, we won't support symmetric contraction on SYCL just yet.
-
There are just a few requests for code logic changes in certain files.
-
Let's hold off on the README / changelog things for now, we'll work with you on those once this batch of changes is in.
I didn't see any big logical gaps, but I also haven't tested this for regression on the existing backends; I will do that once this round of edits is done. In case there are bugs filed specifically for the SYCL backend, we will probably refer them to you to address, since we don't have Intel hardware. Are you ok with this, at least for a little while?
^^ Once this round of edits is done, and if we can refer bugs to you for some period of time, then I think with one more review, we can merge this.
| Builds the Jinja environment used to render the kernel templates. | ||
|
|
||
| :param backend: one of ``"cuda"``, ``"hip"`` or ``"sycl"``. | ||
| :param warp_size: size of a warp / wavefront / sub-group. Only consulted by |
There was a problem hiding this comment.
Hmm - warp size is needed by HIP as well.. but maybe that's a separate bug we need to address.
There was a problem hiding this comment.
Thanks for the thorough revision @abagusetty - things look good, added just a couple more --nodocuments (pesky, sorry), but there are no more logic changes remaining so I started the CUDA / HIP regression testing on our end.
Remaining items:
- CUDA / HIP regression testing
- Resolution of these last --nodocuments (in parallel)
- (strictly after the last two) CI-ready label
- Merge
|
|
||
| class GroupMM: | ||
| def __init__(self, dtype, num_elements, batch_size): | ||
| # group_gemm is not built for SYCL, so the operator does not exist there. |
|
|
||
|
|
||
| if extlib.BUILT_EXTENSION: | ||
| # group_gemm is not built for SYCL, so the operator does not exist there. |
| else: | ||
| from torch.profiler import ProfilerActivity, profile, record_function | ||
|
|
||
| # Profiler activity is per-accelerator. |
| namespace syclex = sycl::ext::oneapi::experimental; | ||
| namespace twi = sycl::ext::oneapi::this_work_item; | ||
|
|
||
| // The sub-group size is fixed to the warp size the schedule was generated |
|
|
||
| #define __launch_bounds__(...) | ||
|
|
||
| // All generated kernels are launched as 1D nd_ranges, so only .x is meaningful. |
| return ref.fetch_add(val); | ||
| } | ||
|
|
||
| // Templated on both operands to keep the mixed-width call sites working. |
| } | ||
|
|
||
| /* | ||
| * Registered after the first compile, not at static init: libsycl-jit is |
There was a problem hiding this comment.
--nodocument, got it, I think this actually becomes pretty clear just reading the code.
|
Update: regression tests pass; with the short round of edits above, should be good to go. |
|
Appreciate for the keen eye @vbharadwaj-bk, will go through rest of them. I was sure, I didnt address all of your comments :) Happy to take on any bugs related to SYCL and `ll try to host a CI on intel hardware on our end or will just fall back to manual testing |
|
@vbharadwaj-bk Thanks again for your time. I did manage to resolve most, please let me know if anything get missed |
Major changes: