Repository navigation
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/190637
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit eea3a8d with merge base fdd065a ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
|
1e08653 to
fa37277
Compare
1b52b19 to
282bed4
Compare
|
@pytorchbot rebase |
|
@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here |
|
Successfully rebased |
282bed4 to
e7d38a6
Compare
|
@claude please review this PR. |
|
Claude finished @xuhancn's task in 3m 5s —— View job PR Review: #190637Summary: Skips the CUDA-specific AOTI stream/event codegen for XPU in two Full reviewCode Quality / Correctness1. Asymmetric multi-stream guard leaves downstream codegen referencing an undeclared cache. If multi-stream is genuinely unsupported on XPU, prefer making that explicit: raise 2. API Design3. Duplicated hardcoded TestingNo in-tree test change accompanies the fix; it relies on the auto-disabler closing #189327/#189326 to re-enable RecommendationNeeds Discussion — the |
|
Please pend this PR for a bit. I need to understand why we need to skip stream event codegen in a situation where we should support it as well. |
2e28408 to
25b6425
Compare
| self, code: IndentedBuffer, stream_idx: int | ||
| ) -> None: | ||
| if stream_idx == 0: | ||
| if stream_idx == 0 or V.graph.device_type == "xpu": |
There was a problem hiding this comment.
Don't change this code. It is not necessary and not reasonable.
| ) | ||
|
|
||
| def codegen_exit_cuda_stream_context(self, code: IndentedBuffer) -> None: | ||
| if V.graph.device_type == "xpu": |
There was a problem hiding this comment.
Don't change this code. It is not necessary and not reasonable.
guangyey
left a comment
There was a problem hiding this comment.
Only two device guard code change is needed.
_emit_stream_op_inline_ensure_aoti_stream_helpers_emitted
| if V.graph.device_type == "xpu": | ||
| return # SYCL in-order queue handles events implicitly |
There was a problem hiding this comment.
| if V.graph.device_type == "xpu": | |
| return # SYCL in-order queue handles events implicitly |
| self, code: IndentedBuffer, stream_idx: int | ||
| ) -> None: | ||
| if stream_idx == 0: | ||
| if stream_idx == 0 or V.graph.device_type == "xpu": |
There was a problem hiding this comment.
| if stream_idx == 0 or V.graph.device_type == "xpu": | |
| if stream_idx == 0: |
| if V.graph.device_type == "xpu": | ||
| return |
There was a problem hiding this comment.
| if V.graph.device_type == "xpu": | |
| return |
| def _emit_stream_op_inline(self, kernel_name: str | None, args: list[str]) -> bool: | ||
| if kernel_name is None or not V.graph.aot_mode: | ||
| return False | ||
| if V.graph.device_type == "xpu": |
There was a problem hiding this comment.
| if V.graph.device_type == "xpu": | |
| if self.device == "xpu": |
5f20faf to
b8b3347
Compare
guangyey
left a comment
There was a problem hiding this comment.
Thanks for your update!
|
@pytorchbot rebase |
1 similar comment
|
@pytorchbot rebase |
|
@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here |
The user-streams support PR pytorch#182971 added _ensure_aoti_stream_helpers_emitted() which generates CUDA-specific AOTIPerThreadEventCache and AOTIPerThreadStreamCache helper classes, along with cudaEventRecord/cudaEventSynchronize calls. These helpers are emitted from multiple code paths in CppWrapperGpu: 1. codegen_stream_info_prologue() — when multiple streams detected 2. _emit_stream_op_inline() — when stream ops like record_event are used 3. codegen_enter_cuda_stream_context() — when switching to non-default stream 4. codegen_exit_cuda_stream_context() — when leaving a non-default stream On XPU, SYCL in-order queues handle events implicitly. Skip all four paths. Verified on PVC (driver 1.6.33578) and BMG (Intel Arc Pro B60): D2H copy PASS. Fixes pytorch#189327 Fixes pytorch#189326
|
Successfully rebased |
b8b3347 to
eea3a8d
Compare
|
@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here |
jansel
left a comment
There was a problem hiding this comment.
Do we have test coverage for this?
|
@pytorchmergebot merge |
Merge startedYour 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 |
Summary
Skip the CUDA-specific stream event codegen (
_aoti_aux_stream_cachehelpers) in the AOTIcpp_wrapperfor XPU devices. SYCL in-order queues handle events implicitly, making the generated CUDA stream cache code unnecessary and incompatible.Root Cause
PR #182971 (Jul 8, 2026) added
codegen_stream_info_prologue()tocpp_wrapper_gpu.py, which emits_aoti_aux_stream_cache.ensure(...)— a CUDA-specific stream cache helper. When a model usestorch.Event(), the AOTI compiler detectsnum_strams > 1and enters this codegen path, generating code that references CUDA-only symbols.For the XPU backend, these CUDA stream helpers are not needed because:
This affected the
AOTInductorTestDualWrappertest class specifically because it usesautotune_at_compile_time=False(lazy Triton compile), which triggers the dual-wrapper codegen path that exercises the multi-stream codegen.Timeline
AOTInductorTestDualWrapperadded (PR #184735) — running fineNotes on PR #189980
The earlier PR #189980 attempted to fix this by capturing the
sycl::eventfromq.memcpy()and chaining it withext_oneapi_submit_barrier({copy_event})inCopy.cpp. That approach was rejected by the reviewer (comment) as adding unnecessary overhead, and has since been determined to be unrelated to the actual root cause. The DMA engine event tracking gap described there is a separate PVC driver-level issue that does not reproduce on the tested hardware configuration (driver 1.6.33578+15, all D2H non_blocking copy tests pass without the barrier workaround).Test Plan
test_copy_non_blocking_is_pinned_xpuon bothAOTInductorTestDualWrapperandAOTInductorTestABICompatibleGpuFixes #189327
Fixes #189326
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo