Repository navigation
Conversation
🔗 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 ( 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. |
c781e6b to
92e366e
Compare
|
@CuiYifeng please review this PR. |
| @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) |
There was a problem hiding this comment.
Why not remove @onlyCPU since the target is generalization?
There was a problem hiding this comment.
Let's check whether @onlyCPU can be enabled when XPU issue is fixed.
| if device.startswith("xpu"): | ||
| self.skipTest("intel/torch-xpu-ops/issues/5286") |
There was a problem hiding this comment.
Why not use @skipIfXpu(msg="https://github.com/intel/torch-xpu-ops/issues/5286") here?
| @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) |
There was a problem hiding this comment.
Please check whether test_reduced_type_float_copy_emits_vectorized_kernel is cuda-specific.
There was a problem hiding this comment.
I have submitted an issue for all the assertTrue check in this class. intel/torch-xpu-ops#5371
| @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)) |
There was a problem hiding this comment.
Please check if this test is cuda-specific.
There was a problem hiding this comment.
| torch.cuda.DoubleTensor([0]) | ||
|
|
||
| @unittest.skipIf(not torch.autograd.kineto_available(), "Kineto is required") | ||
| def test_zero_dense_emits_memset(self, device): |
There was a problem hiding this comment.
Please check if this test is cuda-specific.
There was a problem hiding this comment.
| 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): |
There was a problem hiding this comment.
Please check if this test is cuda-specific.
There was a problem hiding this comment.
So far cuda-specific, I have submitted an issue for XPU, see intel/torch-xpu-ops#5371.
|
|
||
| @deviceCountAtLeast(1) | ||
| @parametrize("non_blocking", (True, False)) | ||
| def test_storage_all_devices(self, devices, non_blocking): |
There was a problem hiding this comment.
Please check if this test is cuda-specific.
There was a problem hiding this comment.
| class TestTorchDeviceType(TestCase): | ||
| hw_classification = HardwareClassification.ACCELERATOR |
There was a problem hiding this comment.
Since TestTorchDeviceType has been generalized for all accelerators, please check tests still decorated with @onlyCPU/@onlyCUDA.
There was a problem hiding this comment.
Sure, I have removed @onlyCPU/@onlyCUDA if the test can also verified on my local XPU machine.
0e51575 to
df7d87b
Compare
df7d87b to
8eb1b18
Compare
| @@ -115,7 +117,6 @@ def test_constants(self, device): | |||
| self.assertIsInstance(torch.inf, float) | |||
| self.assertEqual(torch.inf, math.inf) | |||
|
|
|||
| @onlyNativeDeviceTypes | |||
There was a problem hiding this comment.
I noticed that @onlyNativeDeviceTypes contains multiple devices including xpu.
The comment of @onlyNativeDeviceTypes does not match its implementation.
Please refer to:
https://github.com/pytorch/pytorch/blob/main/torch/testing/_internal/common_device_type.py#L1980-L1989
https://github.com/pytorch/pytorch/blob/main/torch/testing/_internal/common_utils.py#L483.
So, please double check the coverage.
There was a problem hiding this comment.
The device scope to test is defined by instantiate_device_type_tests, removing @onlyNativeDeviceTypes would not decrease the coverage.
There was a problem hiding this comment.
Thanks for the elaboration.
| @@ -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") | |||
There was a problem hiding this comment.
How about using a full github link?
There was a problem hiding this comment.
I think this is a conversion to use this short format to represent the github link of issue.
| @skipCUDAIfNotRocm # This UT throws an OOM error on CUDA | ||
| def test_index_add_large_inputs(self, device): | ||
| D = 6144 |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
I will move the case to TestTorchDeviceSpecific.
| scaler.update() | ||
|
|
||
| @onlyNativeDeviceTypes | ||
| @skipIfXpu(msg="https://github.com/intel/torch-xpu-ops/issues/5308") |
There was a problem hiding this comment.
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.
8eb1b18 to
11418c2
Compare
6fc4485 to
b762ac3
Compare
|
@pytorchbot rebase |
|
@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here |
|
Successfully rebased |
b762ac3 to
3841165
Compare
|
@pytorchbot 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 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 #
## 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 #
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]>
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]>
…`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_*`).
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]>
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]>
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]>
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.