Skip to content

[1/N]Enable some tests in test_ops.TestCommon on Intel GPU - #159944

Closed
daisyden wants to merge 4 commits into
pytorch:mainfrom
daisyden:daisyden/test_ops_s1
Closed

daisyden wants to merge 4 commits into
pytorch:mainfrom
daisyden:daisyden/test_ops_s1

Conversation

@daisyden

@daisyden daisyden commented Aug 6, 2025 •

Copy link
Copy Markdown
Collaborator

For #114850, we will port aten unit tests to Intel GPU. This PR will work on some test case of test/test_ops.py. We could enable Intel GPU with following methods and try the best to keep the original code styles:

  1. Extended XPUTestBase.get_all_devices to support multiple devices
  2. Added skipXPU decorator
  3. Extended onlyOn to support device list
  4. Enabled 'xpu' for some test pathes
  5. Added allow_xpu=True for supported test class.
  6. Replaced onlyCUDA with onlyOn(['cuda', 'xpu']) for supported tests
  7. Use skipIfXpu and skipXPU to disable unsupported test.

cc @gujinghui @EikanWang @fengyuan14 @guangyey

@daisyden
daisyden requested a review from mruberry as a code owner August 6, 2025 08:41
@pytorch-bot

pytorch-bot Bot commented Aug 6, 2025 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ No Failures

As of commit 6f27e20 with merge base ebfc87e (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 added the ciflow/xpu Run XPU CI tasks label Aug 6, 2025
@daisyden daisyden changed the title enable some tests in test_ops.TestCommon on Intel GPU [WIP] enable some tests in test_ops.TestCommon on Intel GPU Aug 6, 2025
@guangyey

guangyey commented Aug 7, 2025

Copy link
Copy Markdown
Collaborator

@pytorchbot rebase

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Rebase failed due to Command git -C /home/runner/work/pytorch/pytorch rebase refs/remotes/origin/viable/strict pull/159944/head returned non-zero exit code 1

Rebasing (1/1)
Auto-merging test/test_ops.py
CONFLICT (content): Merge conflict in test/test_ops.py
Auto-merging torch/testing/_internal/common_device_type.py
Auto-merging torch/testing/_internal/common_methods_invocations.py
Auto-merging torch/testing/_internal/opinfo/definitions/linalg.py
Auto-merging torch/testing/_internal/opinfo/definitions/special.py
CONFLICT (content): Merge conflict in torch/testing/_internal/opinfo/definitions/special.py
error: could not apply cc039eede9b... enable some tests in test_ops.TestCommon on Intel GPU
hint: Resolve all conflicts manually, mark them as resolved with
hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
hint: You can instead skip this commit: run "git rebase --skip".
hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Could not apply cc039eede9b... # enable some tests in test_ops.TestCommon on Intel GPU

Raised by https://github.com/pytorch/pytorch/actions/runs/16793683973

@daisyden daisyden added keep-going Don't stop on first failure, keep running tests until the end module: xpu Intel XPU related issues ciflow/inductor labels Aug 7, 2025
@daisyden
daisyden requested review from guangyey and removed request for mruberry August 7, 2025 08:26
@guangyey guangyey moved this to Pre-Review Required in PyTorch Intel Aug 7, 2025
Comment thread test/test_ops.py Resolved
@guangyey
guangyey requested a review from EikanWang August 8, 2025 06:08

@guangyey guangyey left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just one nit: clarify the reason why we skip a few cases.
Otherwise, LGTM.

@guangyey

guangyey commented Aug 8, 2025

Copy link
Copy Markdown
Collaborator

@EikanWang, which Meta maintainer should we request review from?

skipCUDAIf(not PLATFORM_SUPPORTS_MEM_EFF_ATTENTION, "This platform doesn't support efficient attention"),
skipCUDAIf(TEST_WITH_ROCM, "Efficient attention on ROCM doesn't support custom_mask_type==2")],
skipCUDAIf(TEST_WITH_ROCM, "Efficient attention on ROCM doesn't support custom_mask_type==2"),
skipXPU, ],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
skipXPU, ],
skipXPU],

@daisyden daisyden Aug 13, 2025 •

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.

Hi, @EikanWang, seems most of the 'decorators' augment in op_db has ',' followed the last item of the list. See link1 and link2.

"cusparseSDDMM was added in 11.2.1"),
skipCPUIfNoMklSparse, ],
skipCPUIfNoMklSparse,
skipXPU, ],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
skipXPU, ],
skipXPU],

@daisyden daisyden Aug 13, 2025 •

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.

Hi, @EikanWang, seems most of the 'decorators' augment in op_db has ',' followed the last item of the list. See link1 and link2.

torch_to_numpy_dtype_dict, numpy_to_torch_dtype, TEST_WITH_ASAN,
GRADCHECK_NONDET_TOL, slowTest, TEST_WITH_SLOW,
TEST_WITH_TORCHINDUCTOR, MACOS_VERSION
TEST_WITH_TORCHINDUCTOR, MACOS_VERSION, skipIfXpu,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
TEST_WITH_TORCHINDUCTOR, MACOS_VERSION, skipIfXpu,
TEST_WITH_TORCHINDUCTOR, MACOS_VERSION, skipIfXpu

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.

@EikanWang seems a lot of imports in this file with ',' added after the last one, link1 and link2

skipCUDAIfNoCusolver, skipCPUIfNoLapack, skipCPUIfNoFFT, skipCUDAIf, precisionOverride,
skipCPUIfNoMklSparse,
toleranceOverride, tol)
toleranceOverride, tol, skipXPU, )

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
toleranceOverride, tol, skipXPU, )
toleranceOverride, tol, skipXPU)

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.

@EikanWang seems a lot of imports in this file with ',' added after the last one, link1 and link2

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@daisyden , I don't believe the example can convince me, although I think it is a nit change.

@daisyden daisyden Sep 24, 2025 •

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.

Updated, thanks!

@EikanWang

Copy link
Copy Markdown
Collaborator

@daisyden , has this PR been ready for the community review? If so, pls. refine the title by removing [WIP].

@daisyden daisyden changed the title [WIP] enable some tests in test_ops.TestCommon on Intel GPU Enable some tests in test_ops.TestCommon on Intel GPU Aug 13, 2025
@daisyden

Copy link
Copy Markdown
Collaborator Author

@EikanWang Yes, the PR is ready for community review. Please help to involve reviewers. Thanks.

@guangyey

Copy link
Copy Markdown
Collaborator

@daisyden, please address Eikan‘s suggestions.

@daisyden
daisyden requested review from jeffdaily and malfet August 14, 2025 03:48
@daisyden

Copy link
Copy Markdown
Collaborator Author

@jeffdaily @malfet , please help to review this PR. Thanks.

@daisyden

Copy link
Copy Markdown
Collaborator Author

@daisyden, please address Eikan‘s suggestions.

Replied, thanks.

@guangyey

Copy link
Copy Markdown
Collaborator

@pytorchbot rebase

@guangyey

Copy link
Copy Markdown
Collaborator

@daisyden please rebase this PR before land it.

@daisyden
daisyden force-pushed the daisyden/test_ops_s1 branch 4 times, most recently from 52d408e to 2fa71d4 Compare September 26, 2025 00:33
@daisyden

Copy link
Copy Markdown
Collaborator Author

@pytorchbot rebase

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Successfully rebased daisyden/test_ops_s1 onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via git checkout daisyden/test_ops_s1 && git pull --rebase)

@daisyden

Copy link
Copy Markdown
Collaborator Author

@pytorchbot merge

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Sep 26, 2025
@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

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: 1 jobs have failed, first few of them are: linux-aarch64 / linux-jammy-aarch64-py3.10 / test (default, 1, 3, linux.arm64.m8g.4xlarge)

Details for Dev Infra team Raised by workflow job

@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

@github-project-automation github-project-automation Bot moved this from Pre-Review Required to Done in PyTorch Intel Sep 29, 2025
astachowiczhabana added a commit to astachowiczhabana/pytorch that referenced this pull request Sep 11, 2026
oneMKL provides no half-precision DFT, so torch-xpu-ops emulates one: it
upcasts Half to Float, runs both the transform and the normalization in
float32, and rounds to complex32 once at the end. Separately, pytorch#171231 added
"xpu" to maybe_support_half in torch/_refs/fft.py, which tells the reference
implementation that XPU supports half natively. The ref consequently stays in
float16 and rounds at every prim boundary, while the eager path it is compared
against quietly computed in float32.

test_python_ref, test_python_ref_torch_fallback and test_python_ref_executor
assert ref_distance <= torch_distance against a float64 baseline with no
tolerance, so the ref loses that comparison: 1.18x worse for ihfftn and 1.02x
for ihfft2, on 1 of 10 OpInfo samples. The XPU kernel is not wrong here; it is
more accurate than true float16 would be. No user-visible path is affected,
because inductor promotes float16 FFT to float32 (pytorch#180766) rather than lowering
through these refs, and compiled output is bit-identical to eager.

This adds five xpu-scoped, float16-only skips beside the existing cuda ones for
_refs.fft.ihfft2 and _refs.fft.ihfftn. It is a pure addition and leaves CUDA
behaviour untouched.

Three routes were available. Widening the existing decorators to
device_type=("cuda", "xpu") is terser, but it would attach comments describing
CUDA's native-float16 rounding to a structurally different XPU cause, so the
skips are added as separate entries carrying their own reason - which also
matches the pattern established by pytorch#176688 and pytorch#178849. Adding a tolerance to
the assertion itself would treat the cause and let CUDA, ROCm and XPU all drop
skips, but that single assertion guards every test_python_ref case on every
backend and dtype, so it needs primTorch ownership rather than an XPU change.
Making the refs compute in float32 and cast back to complex32 is the only route
that preserves coverage, but it puts device-conditional numerics inside a
deliberately device-agnostic reference library; that is left for discussion on
the linked issue.

These three tests are currently unreachable on XPU because of the @skipXPU
decorators on them in test/test_ops.py, which are being removed incrementally
(pytorch#159944 introduced them, pytorch#176688 and pytorch#178849 have removed most). Declaring the
skips here is the prerequisite for removing the remaining ones without turning
XPU CI red.

Test Plan

Verified on Intel Arc B570 Graphics (Battlemage). With both skip sources
disabled, exactly five cases fail; with this change they are skipped and the
rest of the selection still passes.

```
cd third_party/torch-xpu-ops
python -m pytest test/xpu/test_ops_xpu.py \
  -k "python_ref and (ihfft2 or ihfftn)" -v --timeout=600
```

```
before (both skip sources disabled):  5 failed, 11 passed
after  (this change):                 0 failed, 68 passed, 14 skipped
```

The skip set was additionally cross-checked by evaluating
DecorateInfo.is_active over both ops, all three tests and all ten instantiated
dtypes for device_type in (cuda, xpu): it matches the five measured failures
exactly, and CUDA's set is unchanged.

```
lintrunner -a torch/testing/_internal/opinfo/definitions/fft.py
ok No lint issues.
```

Authored with the assistance of an AI coding agent; the change and the test
output above come from a run on Intel GPU hardware and were reviewed by a human
before submission.

AI-Assisted: Claude Code (xpu-workspace ai_assisted agent, issue pytorch#174)
Co-Authored-By: Claude Opus 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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: xpu Intel XPU related issues open source release notes: xpu release notes category

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

6 participants