Skip to content

[Test][XPU] Refactor test_torch.py and enable XPU - #197120

Closed
daisyden wants to merge 1 commit into
pytorch:mainfrom
daisyden:daisyden/test_torch
Closed

daisyden wants to merge 1 commit into
pytorch:mainfrom
daisyden:daisyden/test_torch

Conversation

@daisyden

@daisyden daisyden commented Sep 15, 2026 •

Copy link
Copy Markdown
Collaborator

Created TestTorchDeviceSpecific and move cuda specific test into it.
Added hw_classification
Remove redundant @onlyNativeDeviceTypes
Enabled XPU and skipped cases failed due to known issues.

@pytorch-bot

pytorch-bot Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ You can merge normally! (3 Unrelated Failures)

As of commit 3841165 with merge base 9d18b95 (image):

UNSTABLE - The following jobs are marked as unstable, possibly due to flakiness on trunk:

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

@pytorch-bot pytorch-bot Bot added the topic: not user facing topic category label Sep 15, 2026
@daisyden daisyden added the ciflow/xpu Run XPU CI tasks label Sep 15, 2026
@daisyden daisyden added ciflow/trunk Trigger trunk jobs on your pull request ci-no-td Do not run TD on this PR keep-going Don't stop on first failure, keep running tests until the end labels Sep 15, 2026
@daisyden

Copy link
Copy Markdown
Collaborator Author

@CuiYifeng please review this PR.

Comment thread test/test_torch.py Outdated
Comment on lines 2063 to 2066
@onlyCPU
@skipIfXpu(msg="https://github.com/intel/torch-xpu-ops/issues/5307")
def test_gather_backward_one_dim(self, device) -> None:
self._test_gather_backward_one_dim(device, False)

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 @onlyCPU since the target is generalization?

@daisyden daisyden Sep 16, 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's check whether @onlyCPU can be enabled when XPU issue is fixed.

Comment thread test/test_torch.py Outdated
Comment on lines +3819 to +3820
if device.startswith("xpu"):
self.skipTest("intel/torch-xpu-ops/issues/5286")

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 use @skipIfXpu(msg="https://github.com/intel/torch-xpu-ops/issues/5286") here?

Comment thread test/test_torch.py Outdated
Comment on lines +11185 to +11194
@unittest.skipIf(not kineto_available(), "Kineto is required")
@dtypes(torch.bfloat16, torch.half)
def test_reduced_type_float_copy_emits_vectorized_kernel(self, device, dtype):
src = make_tensor((1024, 1024), dtype=dtype, device=device)
torch.accelerator.synchronize()
with torch.profiler.profile() as prof:
src.to(torch.float32)
torch.accelerator.synchronize()
names = tuple(event.key for event in prof.key_averages())
self.assertTrue(any("vectorized_elementwise_kernel" in name for name in names), names)

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 check whether test_reduced_type_float_copy_emits_vectorized_kernel is cuda-specific.

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 have submitted an issue for all the assertTrue check in this class. intel/torch-xpu-ops#5371

Comment thread test/test_torch.py Outdated
Comment on lines +11197 to +11204
@deviceCountAtLeast(2)
@skipIfTorchInductor("FIXME: error not thrown")
def test_multinomial_gpu_device_constrain(self, devices):
x = torch.empty(3, device=devices[0])
y = torch.empty(3, device=devices[1], dtype=torch.long)
self.assertRaisesRegex(
RuntimeError, "Expected all tensors to be on the same device",
lambda: torch.multinomial(x, 2, out=y))

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 check if this test is cuda-specific.

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.

Comment thread test/test_torch.py Outdated
torch.cuda.DoubleTensor([0])

@unittest.skipIf(not torch.autograd.kineto_available(), "Kineto is required")
def test_zero_dense_emits_memset(self, device):

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 check if this test is cuda-specific.

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.

Comment thread test/test_torch.py Outdated
self.assertTrue(any("Memset" in name for name in names), names)

@unittest.skipIf(not torch.autograd.kineto_available(), "Kineto is required")
def test_zero_strided_emits_fill_kernel(self, device):

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 check if this test is cuda-specific.

@daisyden daisyden Sep 16, 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.

So far cuda-specific, I have submitted an issue for XPU, see intel/torch-xpu-ops#5371.

Comment thread test/test_torch.py Outdated

@deviceCountAtLeast(1)
@parametrize("non_blocking", (True, False))
def test_storage_all_devices(self, devices, non_blocking):

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 check if this test is cuda-specific.

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.

Comment thread test/test_torch.py Outdated
Comment on lines +93 to +94
class TestTorchDeviceType(TestCase):
hw_classification = HardwareClassification.ACCELERATOR

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 TestTorchDeviceType has been generalized for all accelerators, please check tests still decorated with @onlyCPU/@onlyCUDA.

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.

Sure, I have removed @onlyCPU/@onlyCUDA if the test can also verified on my local XPU machine.

@daisyden
daisyden force-pushed the daisyden/test_torch branch 2 times, most recently from 0e51575 to df7d87b Compare September 17, 2026 08:50
@liangel-02
liangel-02 requested a review from fffrog September 17, 2026 18:04
@liangel-02 liangel-02 added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Sep 17, 2026
@daisyden
daisyden marked this pull request as draft September 18, 2026 15:57
@daisyden
daisyden requested a review from CuiYifeng September 21, 2026 16:10
Comment thread test/test_torch.py
@@ -115,7 +117,6 @@ def test_constants(self, device):
self.assertIsInstance(torch.inf, float)
self.assertEqual(torch.inf, math.inf)

@onlyNativeDeviceTypes

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.

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.

The device scope to test is defined by instantiate_device_type_tests, removing @onlyNativeDeviceTypes would not decrease the coverage.

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.

Thanks for the elaboration.

Comment thread test/test_torch.py Outdated
@@ -3881,7 +3810,7 @@ def test_scatter_add_bool(self, device):
[True, False, True, False, True]], device=device))

# FIXME: find a test suite for the masked scatter operator
@onlyNativeDeviceTypes
@skipIfXpu(msg="intel/torch-xpu-ops/issues/5286")

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.

How about using a full github link?

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 this is a conversion to use this short format to represent the github link of issue.

@daisyden
daisyden marked this pull request as ready for review September 23, 2026 07:02
@daisyden
daisyden requested review from etaf and jansel September 23, 2026 07:04
@daisyden
daisyden marked this pull request as draft September 28, 2026 06:47
Comment thread test/test_torch.py Resolved
Comment thread test/test_torch.py
Comment on lines 4371 to 4373
@skipCUDAIfNotRocm # This UT throws an OOM error on CUDA
def test_index_add_large_inputs(self, device):
D = 6144

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.

Dropping @onlyCUDA here means this test now runs on CPU and XPU, because skipCUDAIfNotRocm only skips on CUDA. output alone is 1x32x16384x6144 bf16, about 6.4 GB, with no largeTensorTest guard. The reference loop then does 32*16384 = 524k Python iterations, each with an .item(), which means 524k host syncs on XPU. This was effectively a ROCm-only regression test, so I'd put back @onlyCUDA. If you want XPU to cover it, use @onlyAccelerator plus @largeTensorTest('7GB') and a vectorized reference (e.g. x_before.index_add_ on CPU).

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 will move the case to TestTorchDeviceSpecific.

Comment thread test/test_torch.py Resolved
Comment thread test/test_torch.py
scaler.update()

@onlyNativeDeviceTypes
@skipIfXpu(msg="https://github.com/intel/torch-xpu-ops/issues/5308")

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.

I don't think this is an XPU bug. The test picks torch.cpu.amp.GradScaler for every non-CUDA device, and torch.xpu.amp.GradScaler doesn't exist on main (there's no torch/xpu/amp), so there's no deprecated XPU alias that could emit the expected message. intel/torch-xpu-ops#5308 will never be fixable as written. The test really covers the deprecated cpu/cuda namespaces, so @onlyOn(["cpu", "cuda"]) states that directly, and #5308 can be closed.

Comment thread test/test_torch.py Resolved
@daisyden
daisyden requested a review from etaf September 28, 2026 15:14
@daisyden
daisyden marked this pull request as ready for review October 5, 2026 15:00
@daisyden
daisyden force-pushed the daisyden/test_torch branch 3 times, most recently from 6fc4485 to b762ac3 Compare October 14, 2026 03:28
@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_torch onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via git checkout daisyden/test_torch && git pull --rebase)

@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

PatrykWilczewski added a commit to PatrykWilczewski/torch-xpu-ops that referenced this pull request Oct 29, 2026
## Summary
After pytorch/pytorch#197120 was merged,
`test/test_torch.py` instantiates its device-type tests with
`allow_xpu=True`, so we can now run the upstream file directly instead
of the local `test_torch_xpu.py` counterpart.

This replaces intel#5915. Upstream's copy already contains the warning
filters that intel#5915 ported, so
`test_cpp_warnings_have_python_context_xpu` passes.

Fixes: intel#5839

## Coverage comparison
B580 (0xE20B), pytorch 06413cc8b6c + torch-xpu-ops 73a6552,
`PYTORCH_TEST_WITH_SLOW=1`, run from `test/xpu` like on the CI.
BEFORE = `test_torch_xpu.py` with its current skip list
AFTER = upstream `test_torch.py` with no skips.

|  | BEFORE | AFTER | CHANGE |
| - | - | - | - |
| PASSED | 875 | 1762 | 887 |
| FAILED | 1 | 0 | -1 |
| SKIPPED | 56 | 306 | 250 |
| XFAIL | 0 | 6 | 6 |
| TOTAL | 932 | 2074 | 1142 |

- 744 of the AFTER passes are CPU-class tests (eg.
  `TestTorchDeviceTypeCPU`, `TestTorchCPU`). XPU and device-agnostic
tests alone: 1018 passed (BEFORE 875).
- 209 XPU/device-agnostic tests pass now that didn't pass before.
- 38 tests change from FAILED or skip-listed to PASSED. Among them is
  `test_cpp-warnings_have_python_context_xpu` (intel#5839)

# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date:      Thu Oct 29 11:22:42 2026 +0200
#
# On branch issue/5839/use_upstream_test_torch
# Changes to be committed:
#	modified:   .lintrunner.toml
#	modified:   test/xpu/run_test_with_windows_nightly.py
#	modified:   test/xpu/skip_list_common.py
#	deleted:    test/xpu/test_torch_xpu.py
#	modified:   tools/fixheaders/pytorch.yaml
#
pbielak pushed a commit to PatrykWilczewski/torch-xpu-ops that referenced this pull request Oct 29, 2026
## Summary
After pytorch/pytorch#197120 was merged,
`test/test_torch.py` instantiates its device-type tests with
`allow_xpu=True`, so we can now run the upstream file directly instead
of the local `test_torch_xpu.py` counterpart.

This replaces intel#5915. Upstream's copy already contains the warning
filters that intel#5915 ported, so
`test_cpp_warnings_have_python_context_xpu` passes.

Fixes: intel#5839

## Coverage comparison
B580 (0xE20B), pytorch 06413cc8b6c + torch-xpu-ops 73a6552,
`PYTORCH_TEST_WITH_SLOW=1`, run from `test/xpu` like on the CI.
BEFORE = `test_torch_xpu.py` with its current skip list
AFTER = upstream `test_torch.py` with no skips.

|  | BEFORE | AFTER | CHANGE |
| - | - | - | - |
| PASSED | 875 | 1762 | 887 |
| FAILED | 1 | 0 | -1 |
| SKIPPED | 56 | 306 | 250 |
| XFAIL | 0 | 6 | 6 |
| TOTAL | 932 | 2074 | 1142 |

- 744 of the AFTER passes are CPU-class tests (eg.
  `TestTorchDeviceTypeCPU`, `TestTorchCPU`). XPU and device-agnostic
tests alone: 1018 passed (BEFORE 875).
- 209 XPU/device-agnostic tests pass now that didn't pass before.
- 38 tests change from FAILED or skip-listed to PASSED. Among them is
  `test_cpp-warnings_have_python_context_xpu` (intel#5839)

# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date:      Thu Oct 29 11:22:42 2026 +0200
#
# On branch issue/5839/use_upstream_test_torch
# Changes to be committed:
#	modified:   .lintrunner.toml
#	modified:   test/xpu/run_test_with_windows_nightly.py
#	modified:   test/xpu/skip_list_common.py
#	deleted:    test/xpu/test_torch_xpu.py
#	modified:   tools/fixheaders/pytorch.yaml
#
tszulist-hbn added a commit to tszulist-hbn/pytorch that referenced this pull request Oct 30, 2026
Like CUDA, the XPU masked_scatter_ kernel checks the source size inside
the kernel with SYCL_KERNEL_ASSERT to avoid a host sync. A failed assert
is deferred to the next sync and then aborts the process, so the
`assertRaises(RuntimeError)` recovery step can never pass on XPU. Widen
the existing CUDA carve-out to XPU, matching the torch-xpu-ops fork of
this test and the same carve-out already in test_indexing.py. A
host-side size check would make the error catchable, but it adds the
sync both kernels deliberately avoid.

pytorch#197120 enabled TestTorchDeviceType on XPU and skipped this test pending
intel/torch-xpu-ops#5286; drop that skip now that the undersized-src
branch is carved out.

Fixes intel/torch-xpu-ops#5286

Test Plan:
All 11 test_masked_scatter_xpu_* instances pass on a PVC box, and the
CPU instances still pass:

```
python test/test_torch.py -k test_masked_scatter -v
```

Without the carve-out the first XPU instance fails with "RuntimeError
not raised" and the next one aborts with exit 134.

Authored with the help of an AI assistant (Claude Code).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
torchxpubot pushed a commit to intel/torch-xpu-ops that referenced this pull request Nov 2, 2026
Tensor.map_ and Tensor.map2_ apply a python callable element-wise and
are
CPU-only by design. test_broadcast is meant to return early for these
two
functions on GPU tensors, but upstream test/test_torch.py guarded that
with `small.is_cuda`, so on XPU the test fell through to the CPU-only
call and raised TypeError.
    
The guard has since been fixed on both sides: test/xpu/test_torch_xpu.py
checks `small.device.type in ["cuda", "xpu"]`, and
[pytorch/pytorch#197120](pytorch/pytorch#197120)
made the same change in upstream test/test_torch.py. The test now
returns early on XPU as it does on CUDA, so the skip-list entry is stale
and only hides the cases from CI. Implementing map_/map2_ for XPU was
not considered: CUDA does not support them either, and the test treats
them as CPU-only.

Fixes [#5374](#5374)

Co-authored-by: Dmitry Rogozhkin <[email protected]>
torchxpubot pushed a commit to intel/torch-xpu-ops that referenced this pull request Nov 3, 2026
…`test_torch.py` (#5943)

## Summary
After pytorch/pytorch#197120 was merged,
`test/test_torch.py` instantiates its device-type tests with
`allow_xpu=True`, so we can now run the upstream file via
`XPUImportCtx`.
The wrapper imports the upstream test classes, instantiates them for XPU
only, and restores the XPU coverage upstream doesn't have yet. Each
restore links its issue, so it can be dropped once the matching upstream
change lands.

Fixes: #5839

## XPU coverage restored in the wrapper
- `test_scatter_reduce_*` (#5376)
- `test_masked_scatter` (#5286)
- `test_nondeterministic_alert_histc` (#5304)
- `test_split_with_sizes_copy_out`, non-empty cases (#5661)
- `test_terminate_handler_on_crash` (#5309)
- `test_memory_format_cpu_and_cuda_ops`,
`test_addcmul_cuda_errors_with_cpu_scalars` (CUDA-only upstream)
- `@dtypesIfXPU` lists of `test_bernoulli_p`, `test_bernoulli_self`,
`test_diff`, `test_addcdiv`, `test_multinomial_cpu`,
`test_from_sequence`

Not restored, because upstream removed or moved them:
`test_nondeterministic_alert_median` (pytorch/pytorch#199947) and
`TestTorch::test_bf16_supported_on_cpu` (now in the CPU-only
`TestTorchCPU`).

## Coverage comparison
B580, pytorch 06413cc8b6c + torch-xpu-ops 73a6552,
`PYTORCH_TEST_WITH_SLOW=1`, run from `test/xpu` as in CI. BEFORE = old
`test_torch_xpu.py` with its skip list; AFTER = the `XPUImportCtx`
wrapper.

|  | BEFORE | AFTER | CHANGE |
| - | - | - | - |
| PASSED | 879 | 1081 | 202 |
| FAILED | 1 | 0 | -1 |
| SKIPPED | 52 | 106 | 54 |
| TOTAL | 932 | 1187 | 255 |

- BEFORE matches the Nightly op_ut result exactly.
- Every test that passed BEFORE still passes AFTER, except the two not
restored (a few were renamed upstream, e.g. `test_cdist_cuda_backward` →
`test_cdist_device_backward`).
- Newly passing tests include
`test_cpp_warnings_have_python_context_xpu` (#5839). About 170 of the
new passes are tests the old copy didn't have.
- Almost all of the new skips are new upstream `@onlyCUDA` tests
(`test_copy_strided_chunk_*`, `test_copy_transpose_tiled_*`).
pytorchmergebot pushed a commit to tszulist-hbn/pytorch that referenced this pull request Nov 18, 2026
Like CUDA, the XPU masked_scatter_ kernel checks the source size inside
the kernel with SYCL_KERNEL_ASSERT to avoid a host sync. A failed assert
is deferred to the next sync and then aborts the process, so the
`assertRaises(RuntimeError)` recovery step can never pass on XPU. Widen
the existing CUDA carve-out to XPU, matching the torch-xpu-ops fork of
this test and the same carve-out already in test_indexing.py. A
host-side size check would make the error catchable, but it adds the
sync both kernels deliberately avoid.

pytorch#197120 enabled TestTorchDeviceType on XPU and skipped this test pending
intel/torch-xpu-ops#5286; drop that skip now that the undersized-src
branch is carved out.

Fixes intel/torch-xpu-ops#5286

Test Plan:
All 11 test_masked_scatter_xpu_* instances pass on a PVC box, and the
CPU instances still pass:

```
python test/test_torch.py -k test_masked_scatter -v
```

Without the carve-out the first XPU instance fails with "RuntimeError
not raised" and the next one aborts with exit 134.

Authored with the help of an AI assistant (Claude Code).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
NaOHCC added a commit to NaOHCC/pytorch that referenced this pull request Nov 19, 2026
test_grad_scaler_deprecated_warning picks torch.cuda.amp.GradScaler for
CUDA and torch.cpu.amp.GradScaler for every other device, but builds its
expected FutureWarning out of the device under test
(rf"`torch.{device.type}.amp.GradScaler..."). On any device type other
than cpu and cuda it therefore constructs the cpu alias and then asserts
a message that alias can never emit. On XPU that is the reported
failure: the expected `torch.xpu.amp.GradScaler(args...)` does not match
the emitted `torch.cpu.amp.GradScaler(args...)`.

There is nothing to fix on the product side. The deprecated per-device
GradScaler aliases exist only for cpu (torch/cpu/amp/grad_scaler.py) and
cuda (torch/cuda/amp/grad_scaler.py); torch.xpu.amp has never existed, so
there is no XPU-specific deprecation message to assert. What the test
actually covers is the two deprecated namespaces, so @OnlyOn(["cpu",
"cuda"]) states its scope directly and the test body needs no change.

The alternative was to keep the test device-generic and derive the
expected namespace from the alias being constructed rather than from the
device. That makes the assertion pass on XPU, but it asserts a cpu
deprecation message under an xpu test id, which is coverage the cpu
instance of the test already provides. Declaring the scope is the
narrower statement and was the direction taken in review of pytorch#197120.

This also restores the cpu instance of the test on XPU machines: the
@skipIfXpu it replaces keys off the global TEST_XPU rather than the
device under test, so on a machine with an XPU present it was skipping
test_grad_scaler_deprecated_warning_cpu as well.

Fixes the case tracked by intel/torch-xpu-ops issue 5308.

Test Plan:

Intel BMG (Arc Pro B60), torch 2.16.0.dev20261110+xpu, from pytorch/test.

Before (with the @skipIfXpu removed, to expose the failure under test):

```
python test_torch.py TestTorchDeviceTypeXPU.test_grad_scaler_deprecated_warning_xpu -v
```

After:

```
python test_torch.py TestTorchDeviceTypeXPU.test_grad_scaler_deprecated_warning_xpu -v
python test_torch.py TestTorchDeviceTypeCPU.test_grad_scaler_deprecated_warning_cpu -v
```

Surrounding grad-scaler coverage, same command before and after:

```
pytest -q test_torch.py -k "grad_scaler or grad_scaling"
```

Lint (lintrunner and spin are unavailable in this container, so ruff was
run directly): `ruff check test/test_torch.py` reports the same two
pre-existing FURB110 findings before and after the change, and
test/test_torch.py is in PYFMT's exclude list.

This change was authored with the assistance of an AI coding agent.

Co-Authored-By: Claude Opus 5 <[email protected]>
pytorchmergebot pushed a commit to tszulist-hbn/pytorch that referenced this pull request Nov 19, 2026
Like CUDA, the XPU masked_scatter_ kernel checks the source size inside
the kernel with SYCL_KERNEL_ASSERT to avoid a host sync. A failed assert
is deferred to the next sync and then aborts the process, so the
`assertRaises(RuntimeError)` recovery step can never pass on XPU. Widen
the existing CUDA carve-out to XPU, matching the torch-xpu-ops fork of
this test and the same carve-out already in test_indexing.py. A
host-side size check would make the error catchable, but it adds the
sync both kernels deliberately avoid.

pytorch#197120 enabled TestTorchDeviceType on XPU and skipped this test pending
intel/torch-xpu-ops#5286; drop that skip now that the undersized-src
branch is carved out.

Fixes intel/torch-xpu-ops#5286

Test Plan:
All 11 test_masked_scatter_xpu_* instances pass on a PVC box, and the
CPU instances still pass:

```
python test/test_torch.py -k test_masked_scatter -v
```

Without the carve-out the first XPU instance fails with "RuntimeError
not raised" and the next one aborts with exit 134.

Authored with the help of an AI assistant (Claude Code).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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/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 open source topic: not user facing topic category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

7 participants