PyTorch's XPU backend skips CUDA stream codegen for SYCL
Four code paths patched to rely on SYCL in-order queues, fixing two GitHub issues.
PyTorch's AOTI (Ahead-of-Time Inductor) compiler now properly excludes CUDA stream event code when generating C++ wrapper code for Intel's XPU accelerators. The change, submitted by xuhancn, targets the CppWrapperGpu class where a recent user-streams PR (#182971) introduced helper classes like AOTIPerThreadEventCache and AOTIPerThreadStreamCache, along with cudaEventRecord/cudaEventSynchronize calls. These were being emitted unconditionally, even on XPU hardware that uses SYCL in-order queues instead of CUDA streams.
The fix modifies four specific codegen paths: codegen_stream_info_prologue, _emit_stream_op_inline, codegen_enter_cuda_stream_context, and codegen_exit_cuda_stream_context. All now skip CUDA-specific stream helper emission when targeting XPU. The PR was validated on Intel's Ponte Vecchio (PVC) with driver 1.6.33578 and on the Intel Arc Pro B60 (BMG), with D2H (device-to-host) copies passing. The change resolves two open issues, #189327 and #189326, making PyTorch's XPU backend more reliable and reducing unnecessary CUDA-isms in generated code.
- Skips AOTIPerThreadEventCache and AOTIPerThreadStreamCache helper generation on XPU
- Patches four code paths in CppWrapperGpu, including stream context enter/exit
- Verified on Intel PVC and Arc Pro B60, fixing issues #189327 and #189326
Why It Matters
Cleaner XPU support in PyTorch reduces maintenance overhead and fixes runtime failures for Intel GPU users.