Skip to content

[Test][XPU] Enable xpu on some inductor files - #195700

Closed
daisyden wants to merge 6 commits into
pytorch:mainfrom
daisyden:daisyden/inductor2
Closed

daisyden wants to merge 6 commits into
pytorch:mainfrom
daisyden:daisyden/inductor2

Conversation

@daisyden

@daisyden daisyden commented Sep 2, 2026 •

Copy link
Copy Markdown
Collaborator

@pytorch-bot

pytorch-bot Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

PR Status: Approved 🚀

Please fix all CI failures and trigger merge by commenting "@pytorchbot merge".

✅ AUTOMATED REVIEW - OUTDATED (earlier commit) - Ready for human review:

Test-only PR that ports CUDA-only inductor and numpy-interop tests to also run
on XPU, using GPU_TYPE, device_module and generic decorators. Sub-agent review
found nothing broken: the f-string escaping, imports, the codegen FileCheck
strings and the save_gpu_kernel mock keys all check out. Two minor points
remain, both about coverage that is weaker or inconsistent on XPU.

Findings (2):

[minor] test/inductor/test_triton_kernels.py:2054
Adds bf16 on every XPU without checking device support. This is inconsistent
with the get_interface_for_device(GPU_TYPE).is_dtype_supported(...) check this
PR uses at line 292; use the same check here.

[minor] test/inductor/test_user_streams.py:2948
TestStreamCudagraphInteraction now runs on XPU, but inductor cudagraphs only
accept a single cuda device
(cudagraph_utils.check_multiple_devices_or_any_cpu_nodes). On XPU, capture is
silently skipped and the tests only compare eager results, so they pass without
testing capture. Skip them on XPU or note this.

Reviewed commit: 8f56ac6 (NOT the current head 523bb1e)

Review run

🔗 Helpful Links

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

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

✅ No Failures

As of commit 523bb1e with merge base 12acbeb (image):
💚 Looks good so far! There are no failures yet. 💚

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

@daisyden
daisyden marked this pull request as draft September 2, 2026 06:08
@daisyden
daisyden requested review from etaf and removed request for etaf September 3, 2026 01:07
@daisyden

daisyden commented Sep 4, 2026 •

Copy link
Copy Markdown
Collaborator Author

@CuiYifeng could you please help review this test port / refactor PR? Thanks!

@daisyden
daisyden force-pushed the daisyden/inductor2 branch 2 times, most recently from 5fc7c28 to 53f846e Compare September 7, 2026 02:47
@daisyden daisyden changed the title [Test] Enable xpu on some inductor files [Test][XPU] Enable xpu on some inductor files Sep 7, 2026
@daisyden daisyden added the ciflow/xpu Run XPU CI tasks label Sep 7, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not remove @onlyCUDA for test_batch_invariance?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

torch.backends api used in this test_batch_invariance is cuda specific, for example torch.backends.cuda.preferred_blas_library, so I didn't remove onlyCUDA.

Comment thread test/inductor/test_warnings.py Outdated
Comment on lines +29 to +33

@unittest.skipIf(not _has_cuda_sm80(), "requires CUDA SM80")
@skipIfXpu(msg="torch-xpu-ops/issues/5048")
@unittest.skipIf(not TEST_XPU and not _has_cuda_sm80(), "requires CUDA SM80 or XPU")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since XPU has been skipped by @skipIfXpu, why do we need not TEST_XPU? Furthermore, not TEST_XPU is not equal to TEST_CUDA. How about using:

@unittest.skipIf(TEST_CUDA and not _has_cuda_sm80(), "requires CUDA SM80")

@daisyden daisyden Sep 9, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Adding TEST_XPU check is to enable XPU for this case, skipIfXpu is to skip the test due to known issue, when the known issue is fixed we will remove the skipIfXpu decorator.

Comment thread test/inductor/test_warnings.py Outdated
Comment on lines +61 to +62
@skipIfXpu(msg="torch-xpu-ops/issues/5048")
@unittest.skipIf(not TEST_XPU and not _has_cuda_sm80(), "requires CUDA SM80 or XPU")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ditto.

@daisyden daisyden Sep 9, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Adding TEST_XPU check is to enable XPU for this case, skipIfXpu is to skip the test due to known issue, when the known issue is fixed we will remove the skipIfXpu decorator.

Comment on lines +28 to +38
def _skip_if_not_cuda(self):
if GPU_TYPE != "cuda":
self.skipTest("CUDA-specific variance heuristic")
if GPU_TYPE not in ["cuda", "xpu"]:
self.skipTest("CUDA/XPU-specific variance heuristic")

def _dtypes(self):
dtypes = [torch.float16]
if torch.cuda.is_bf16_supported():
dtypes.append(torch.bfloat16)
return dtypes

@skipIfXpu(msg="intel/torch-xpu-ops/issues/5221")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since the destination is to enable this test case only for cuda and xpu, can we remove self._skip_if_not_cuda() and control devices with decorator directly?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Let me rename _skip_if_not_cuda -> _skip_if_not_gpu

Comment thread test/inductor/test_gpu_cpp_wrapper.py Outdated
Comment on lines 190 to 192
self.skipTest("GPU not available")
if GPU_TYPE != "cuda":
if GPU_TYPE not in ("cuda", "xpu"):
self.skipTest("CUDA/ROCm-only cpp_wrapper debug sync")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Message is not aligned with new condition.

@daisyden daisyden Sep 9, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Let me update the message

xfails = set(xfail_dicts.get(test_type, {}).get(backend, {}).get(op_name, set()))
# fbcode's Triton fork + cuBLAS/GPU stack differ from OSS CI, so some combos
# fail the compiled-vs-eager numerics only in fbcode. Gate on IS_FBCODE (CUDA
# only) so OSS does not hit spurious XPASS on these.
if IS_FBCODE and torch.version.hip is None:
if IS_FBCODE and torch.version.hip is None and device_type != "xpu":

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you add a comment to explain why we can skip the following xfails?

@daisyden daisyden Sep 9, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think there already has comments in 819-821 to address this is a cuda specific XFAIL.

@@ -163,7 +179,7 @@ def setUp(self):
# NOTE: triton.fb is fbcode-only; OSS CI sets CUDA_HOME via env.
import os

if "CUDA_HOME" not in os.environ and "CUDA_PATH" not in os.environ:
if GPU_TYPE == 'cuda' and "CUDA_HOME" not in os.environ and "CUDA_PATH" not in os.environ:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
if GPU_TYPE == 'cuda' and "CUDA_HOME" not in os.environ and "CUDA_PATH" not in os.environ:
if GPU_TYPE == "cuda" and "CUDA_HOME" not in os.environ and "CUDA_PATH" not in os.environ:

Please unify the style.

Comment thread test/inductor/test_user_streams.py Outdated
not TEST_CUDA or torch.cuda.device_count() < 2,
"requires at least two CUDA devices",
not TEST_GPU or device_module.device_count() < 2,
"requires at least two GPU devices",
)
def test_raw_stream_name_does_not_clobber_user_stream_on_cuda_1(self):

@CuiYifeng CuiYifeng Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please update the hard code on_cuda_1 after generalization.

@daisyden
daisyden force-pushed the daisyden/inductor2 branch 2 times, most recently from 633f83a to 6480ab0 Compare September 9, 2026 05:34
@daisyden daisyden added keep-going Don't stop on first failure, keep running tests until the end ci-no-td Do not run TD on this PR labels Sep 10, 2026
@daisyden
daisyden force-pushed the daisyden/inductor2 branch 2 times, most recently from da3545d to 8932f34 Compare September 14, 2026 05:19
@daisyden
daisyden force-pushed the daisyden/inductor2 branch 2 times, most recently from 2ee5276 to 40847c5 Compare September 21, 2026 03:06
@daisyden
daisyden requested a review from etaf September 21, 2026 12:24
Comment thread test/inductor/test_user_streams.py Resolved
Comment thread test/inductor/test_user_streams.py Resolved
Comment thread test/inductor/test_user_streams.py Resolved
Comment thread test/inductor/test_triton_kernels.py Resolved
Comment thread test/inductor/test_triton_kernels.py Resolved
@daisyden
daisyden requested a review from etaf September 24, 2026 06:17
@daisyden
daisyden marked this pull request as ready for review September 28, 2026 02:58
@daisyden
daisyden force-pushed the daisyden/inductor2 branch 2 times, most recently from 8d09a4b to e62e887 Compare October 19, 2026 02:35
…and test/inductor/test_triton_launcher_integration.py
updated test/inductor/test_torchinductor_opinfo_properties.py
Fix according to comments.

Restores test/inductor/test_torchinductor_opinfo_properties.py to its state at
054a3a8, reverting the XPU-enablement changes
made in commits f7f1c37, 2fbd807, and 8932f34.

Test Plan: git diff 054a3a8 -- <file> shows no differences.
@daisyden

Copy link
Copy Markdown
Collaborator Author

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
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

zoranzhao added a commit that referenced this pull request Nov 4, 2026
zoranzhao added a commit that referenced this pull request Nov 4, 2026
zoranzhao added a commit that referenced this pull request Nov 4, 2026
zoranzhao added a commit that referenced this pull request Nov 4, 2026
zoranzhao added a commit that referenced this pull request Nov 4, 2026
zoranzhao added a commit that referenced this pull request Nov 4, 2026
zoranzhao added a commit that referenced this pull request Nov 4, 2026
chunhuanMeng added a commit to chunhuanMeng/pytorch that referenced this pull request Nov 25, 2026
The three TestAOTIUserStreams cases skipped XPU pending intel/torch-xpu-ops#5177.
Now that record_event/wait_event/synchronize_event lower into the XPU AOTI
event cache, drop the skips and assert on the XPU lowering instead of the
CUDA-only cudaEventRecord/cudaStreamWaitEvent symbols.

The upstream generic-device rewrite of this file (pytorch#195700) already landed on
main, so the test bodies keep using the module-level device_module/TEST_GPU
idiom rather than the per-test getattr(torch, GPU_TYPE) form from the original
patch.
chunhuanMeng added a commit to chunhuanMeng/pytorch that referenced this pull request Nov 25, 2026
The three TestAOTIUserStreams cases skipped XPU pending intel/torch-xpu-ops#5177.
Now that record_event/wait_event/synchronize_event lower into the XPU AOTI
event cache, drop the skips and assert on the XPU lowering instead of the
CUDA-only cudaEventRecord/cudaStreamWaitEvent symbols.

The upstream generic-device rewrite of this file (pytorch#195700) already landed on
main, so the test bodies keep using the module-level device_module/TEST_GPU
idiom rather than the per-test getattr(torch, GPU_TYPE) form from the original
patch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-no-td Do not run TD on this PR ciflow/inductor ciflow/trunk Trigger trunk jobs on your pull request ciflow/xpu Run XPU CI tasks keep-going Don't stop on first failure, keep running tests until the end Merged module: inductor open source ready for review Automated review passed, ready for a final review by a maintainer. topic: not user facing topic category

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

6 participants