Skip to content

[Test][XPU] Make test/export/test_passes.py device-generic and enable it on XPU - #196974

Closed
tszulist-hbn wants to merge 3 commits into
pytorch:mainfrom
tszulist-hbn:xpu/test-passes-device-agnostic
Closed

tszulist-hbn wants to merge 3 commits into
pytorch:mainfrom
tszulist-hbn:xpu/test-passes-device-agnostic

Conversation

@tszulist-hbn

Copy link
Copy Markdown
Contributor

Part of #142029.

Four move_to_device_pass tests were gated on TEST_CUDA inside TestPasses, whose other 23 tests never touch a device. This PR moves them into a device-parameterized TestMoveToDevicePassDevice, enables XPU alongside CUDA, and tags both classes with hw_classification (GENERIC / ACCELERATOR).

Three commits: a pure relocation (+4 lines), the device-generic conversion, then the classification tags.

Coverage delta

XPU gains four tests. CUDA is unchanged. Nothing is removed.

before after
TestPasses::test_move_device_to TestMoveToDevicePassDevice{CUDA,XPU}::test_move_device_to_{cuda,xpu}
TestPasses::test_move_device_submod TestMoveToDevicePassDevice{CUDA,XPU}::test_move_device_submod_{cuda,xpu}
TestPasses::test_move_to_device_pass TestMoveToDevicePassDevice{CUDA,XPU}::test_move_to_device_pass_{cuda,xpu}
TestPasses::test_move_device_example_inputs TestMoveToDevicePassDevice{CUDA,XPU}::test_move_device_example_inputs_{cuda,xpu}

On XPU: 27 IDs before, 27 after, an exact four-for-four swap, with the other 23 TestPasses IDs identical.

Known exception: on a machine with neither device the four tests no longer appear at all, where before they were collected as four skips. That is inherent to instantiate_device_type_tests, and costs no real coverage.

third_party/torch-xpu-ops forks this whole file just for these four tests and records no skips for it, so Intel's CI already runs them green on XPU. Landing this lets that fork be deleted.

Test plan

On Intel Arc B580, no CUDA on the box:

python -m pytest test/export/test_passes.py -k TestMoveToDevicePass -v   # 4 passed
python -m pytest test/export/test_passes.py -k TestPasses -q             # 21 passed, 2 xfailed
python -m pytest test/export/test_passes.py --hw-classification ACCELERATOR -q
#   total=27, passed=4, unclassified=0, mismatched=23

With the GPU masked off (ONEAPI_DEVICE_SELECTOR=level_zero:99), 23 IDs are collected, no TestMoveToDevicePass* ID appears, and there is no collection error.


This PR was prepared with the assistance of an AI coding agent (Claude Code). The code and this description were reviewed by me before submission.

🤖 Generated with Claude Code

@pytorch-bot

pytorch-bot Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ You can merge normally! (2 Unrelated Failures)

As of commit 9fa8d9a with merge base 4f574b5 (image):

BROKEN TRUNK - The following jobs failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

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 14, 2026
@tszulist-hbn tszulist-hbn changed the title [Testcase Refactoring][export] Make test/export/test_passes.py device-generic and enable it on XPU [Testcase][export] Make test/export/test_passes.py device-generic and enable it on XPU Sep 14, 2026
@tszulist-hbn tszulist-hbn changed the title [Testcase][export] Make test/export/test_passes.py device-generic and enable it on XPU [Test][export] Make test/export/test_passes.py device-generic and enable it on XPU Sep 14, 2026
@tszulist-hbn tszulist-hbn changed the title [Test][export] Make test/export/test_passes.py device-generic and enable it on XPU [Test][XPU] Make test/export/test_passes.py device-generic and enable it on XPU Sep 14, 2026
@chuanqi129 chuanqi129 added ciflow/trunk Trigger trunk jobs on your pull request ci-no-td Do not run TD on this PR labels Sep 14, 2026
Comment thread test/export/test_passes.py Resolved
Comment thread test/export/test_passes.py Resolved
Comment thread test/export/test_passes.py Resolved
@tszulist-hbn
tszulist-hbn force-pushed the xpu/test-passes-device-agnostic branch from 319b832 to 8e589a1 Compare September 14, 2026 14:40
@pytorch-bot

pytorch-bot Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Workflows were awaiting approval. CI has now been triggered for the ciflow labels on this PR.

@pbielak pbielak added the ciflow/xpu Run XPU CI tasks label Sep 15, 2026
@pbielak
pbielak requested a review from etaf September 22, 2026 11:39
@pbielak
pbielak requested a review from jansel September 24, 2026 09:58
@tszulist-hbn
tszulist-hbn marked this pull request as ready for review September 24, 2026 10:19
@tszulist-hbn

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

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: Command git -C /home/runner/work/pytorch/pytorch merge --squash __pull-request-196974__init__ returned non-zero exit code 1

Auto-merging test/export/test_passes.py
CONFLICT (content): Merge conflict in test/export/test_passes.py
Squash commit -- not updating HEAD
Automatic merge failed; fix conflicts and then commit the result.
Details for Dev Infra team Raised by workflow job

tszulist-hbn and others added 3 commits October 7, 2026 07:49
… tests out of TestPasses

test/export/test_passes.py gates four move_to_device_pass tests on TEST_CUDA
inside TestPasses, whose remaining tests never touch a device. Handing that
mixed class to instantiate_device_type_tests later would clone every
device-independent test onto each accelerator backend for no extra coverage,
so separate the device-requiring tests out first.

This commit is a pure relocation. The four test bodies and their
@unittest.skipIf(not TEST_CUDA, "requires cuda") gates are byte-identical to
before, and the new class repeats the two class-level decorators TestPasses
carries so the dynamo gating is unchanged. The class is named with the
*Device suffix it needs once the next commit hands it to
instantiate_device_type_tests, so that no rename lands mid-stack.

The alternative considered was to relocate and parameterize in one step. Kept
separate because it lets a reviewer confirm the move is behavior-neutral from
a four-line diff, and isolates the actual coverage change to the next commit.

Test Plan:

The four tests keep their CUDA gate, so on a machine without CUDA they are
still collected and skipped rather than disappearing:

```
python -m pytest test/export/test_passes.py -k TestMoveToDevicePass -v
```

```
collected 27 items / 23 deselected / 4 selected
TestMoveToDevicePassDevice::test_move_device_example_inputs SKIPPED
TestMoveToDevicePassDevice::test_move_device_submod SKIPPED
TestMoveToDevicePassDevice::test_move_device_to SKIPPED
TestMoveToDevicePassDevice::test_move_to_device_pass SKIPPED
4 skipped, 23 deselected
```

Collected test-ID count is unchanged at 27, and lint is clean:

```
lintrunner test/export/test_passes.py
```

This change was prepared with the assistance of an AI coding agent
(Claude Code) and reviewed by the author.

Co-Authored-By: Claude Opus 5 <[email protected]>
…ice-generic and enable XPU

The four tests extracted in the previous commit hardcoded "cuda"/"cuda:0" and
were gated on TEST_CUDA, so no other accelerator could run them even though
move_to_device_pass itself is backend-independent. Register
TestMoveToDevicePassDevice with instantiate_device_type_tests and derive every
device from the injected device parameter instead.

This is a functional change, not a pure refactor: CUDA keeps running the same
four tests, and XPU gains them. Both only_for=("cuda", "xpu") and
allow_xpu=True are passed, per the redundancy the framework deliberately
requires until the TODO at common_device_type.py:1230 is resolved. No
@onlyAccelerator decorator is used, because only_for already excludes cpu and
meta, which is all @onlyAccelerator would skip.

Note on the two assertExpectedInline goldens: the framework injects an indexed
device string ("cuda:0"/"xpu:0"), but move_to_device_pass rewrites the graph's
device kwargs to the bare device-type string, so the expected text differs
between backends only in that one token. Interpolating device_type into an
f-string keeps the assertion exact on both, matching the existing convention
in test/dynamo/test_after_aot.py. The alternative of substituting the device
name for a fixed placeholder before comparing was rejected: it keeps the
assertion strict but leaves a golden that is not text the pass can emit, which
makes the expected output unreadable and useless as documentation.

Also worth stating explicitly: on a machine with neither device the four tests
no longer appear at all, where previously they were collected and skipped.
That is inherent to instantiate_device_type_tests, which only creates variants
for available devices, and it costs no real coverage.

Test Plan:

All four tests pass on Intel Arc B580 (torch.xpu.device_count() == 1, no CUDA
on the box):

```
python -m pytest test/export/test_passes.py -k TestMoveToDevicePass -v
```

```
collected 27 items / 23 deselected / 4 selected
TestMoveToDevicePassDeviceXPU::test_move_device_example_inputs_xpu PASSED
TestMoveToDevicePassDeviceXPU::test_move_device_submod_xpu PASSED
TestMoveToDevicePassDeviceXPU::test_move_device_to_xpu PASSED
TestMoveToDevicePassDeviceXPU::test_move_to_device_pass_xpu PASSED
4 passed, 23 deselected
```

The device-independent class is unaffected:

```
python -m pytest test/export/test_passes.py -k TestPasses -q
```

```
21 passed, 4 deselected, 2 xfailed
```

Collected test IDs are a one-for-one swap, 27 before and 27 after: the four
TestPasses::test_move_* IDs are replaced by four
TestMoveToDevicePassDeviceXPU::test_move_*_xpu IDs, with nothing else added or
removed. With the GPU masked off, 23 IDs are collected and no
TestMoveToDevicePass* ID appears, with no collection error:

```
ONEAPI_DEVICE_SELECTOR=level_zero:99 python -m pytest test/export/test_passes.py --collect-only -q
```

Independent evidence that these four tests hold on XPU beyond this one device:
third_party/torch-xpu-ops carries a full fork of this file,
test/xpu/export/test_passes_xpu.py, whose only substantive difference from
upstream is these same four tests, and skip_list_common.py records no skips
for it. Landing this lets that fork and its skip-list entry be deleted.

This change was prepared with the assistance of an AI coding agent
(Claude Code) and reviewed by the author.

Co-Authored-By: Claude Opus 5 <[email protected]>
Co-authored-by: Copilot <[email protected]>
…es.py suites

Tag each test class in test/export/test_passes.py so the whole file is accounted
for by the --hw-classification test selector, which otherwise counts every
test in it as unclassified and drops it from a filtered run.

TestPasses is GENERIC: after the preceding commits it never allocates on or
moves to a device, and it is deliberately not handed to
instantiate_device_type_tests. TestMoveToDevicePassDevice is ACCELERATOR
because it is device-parameterized; the classification tracks that
parameterization rather than whether the tests could run on CPU. The generated
per-device classes inherit the attribute, so no per-backend tag is needed.
TestMoveToDevicePassCuda is ACCELERATOR because it contains upstream CUDA tests;
its interpreter-only graph test initializes TorchBind registrations in isolation.

Test Plan:

```
python -m pytest test/export/test_passes.py --hw-classification ACCELERATOR -q
```

```
HW classification mode active (['ACCELERATOR']): total=32, passed=9, unclassified=0, mismatched=23
5 passed, 4 skipped
```

unclassified=0 confirms all classes are tagged, and the 9/23 split matches
the accelerator and device-independent test counts.

This change was prepared with the assistance of an AI coding agent
(Claude Code) and reviewed by the author.

Co-Authored-By: Claude Opus 5 <[email protected]>
Co-authored-by: Copilot <[email protected]>
@tszulist-hbn
tszulist-hbn force-pushed the xpu/test-passes-device-agnostic branch from 8e589a1 to 9fa8d9a Compare October 7, 2026 08:02
@tszulist-hbn

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

cyyever pushed a commit to BakeLab/pytorch that referenced this pull request Oct 11, 2026
… it on XPU (pytorch#196974)

Part of pytorch#142029.

Four `move_to_device_pass` tests were gated on `TEST_CUDA` inside `TestPasses`, whose other 23 tests never touch a device. This PR moves them into a device-parameterized `TestMoveToDevicePassDevice`, enables XPU alongside CUDA, and tags both classes with `hw_classification` (`GENERIC` / `ACCELERATOR`).

Three commits: a pure relocation (+4 lines), the device-generic conversion, then the classification tags.

## Coverage delta

XPU gains four tests. CUDA is unchanged. Nothing is removed.

| before | after |
| --- | --- |
| `TestPasses::test_move_device_to` | `TestMoveToDevicePassDevice{CUDA,XPU}::test_move_device_to_{cuda,xpu}` |
| `TestPasses::test_move_device_submod` | `TestMoveToDevicePassDevice{CUDA,XPU}::test_move_device_submod_{cuda,xpu}` |
| `TestPasses::test_move_to_device_pass` | `TestMoveToDevicePassDevice{CUDA,XPU}::test_move_to_device_pass_{cuda,xpu}` |
| `TestPasses::test_move_device_example_inputs` | `TestMoveToDevicePassDevice{CUDA,XPU}::test_move_device_example_inputs_{cuda,xpu}` |

On XPU: 27 IDs before, 27 after, an exact four-for-four swap, with the other 23 `TestPasses` IDs identical. <!-- TODO: confirm the same on a CUDA box before posting. -->

**Known exception:** on a machine with neither device the four tests no longer appear at all, where before they were collected as four skips. That is inherent to `instantiate_device_type_tests`, and costs no real coverage.

`third_party/torch-xpu-ops` forks this whole file just for these four tests and records no skips for it, so Intel's CI already runs them green on XPU. Landing this lets that fork be deleted.

## Test plan

On Intel Arc B580, no CUDA on the box:

```
python -m pytest test/export/test_passes.py -k TestMoveToDevicePass -v   # 4 passed
python -m pytest test/export/test_passes.py -k TestPasses -q             # 21 passed, 2 xfailed
python -m pytest test/export/test_passes.py --hw-classification ACCELERATOR -q
#   total=27, passed=4, unclassified=0, mismatched=23
```

With the GPU masked off (`ONEAPI_DEVICE_SELECTOR=level_zero:99`), 23 IDs are collected, no `TestMoveToDevicePass*` ID appears, and there is no collection error.

---

This PR was prepared with the assistance of an AI coding agent (Claude Code). The code and this description were reviewed by me before submission.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Pull Request resolved: pytorch#196974
Approved by: https://github.com/pbielak, https://github.com/etaf, https://github.com/jansel

Co-authored-by: Claude Opus 5 <[email protected]>
SHIHAIFENG15 added a commit to SHIHAIFENG15/pytorch that referenced this pull request Oct 12, 2026
pytorch#196974 already moved these tests onto instantiate_device_type_tests for CUDA and XPU, and pytorch#185105 added the CUDA recompile regressions. Keep that code, and open the device class to other non-CPU backends with except_for="cpu" while retaining allow_xpu=True.

Test Plan:
```
python -m pytest test/export/test_passes.py --collect-only -q
# 28 tests collected on CPU. TestMoveToDevicePassDevice is not generated without an accelerator, which matches except_for="cpu".
```
torchxpubot pushed a commit to intel/torch-xpu-ops that referenced this pull request Oct 15, 2026
)

Next PR for synchronizing upstream generalization with local files:

1) **functorch/test_eager_transforms.py**

Upstream PR: pytorch/pytorch#192806

Before: 682 passed, 7 skipped, 2 xfailed
After:  721 passed, 6 skipped, 2 xfailed

Changes:
- 11 new test cases: `TestGradTransform::test_inference_mode_*`
- 4 new test cases: `TestCompileTransforms::test_compile_dynamic_grad_*`
- 2 new test cases:
`TestGradTransform::test_pop_dynamic_layer_stack_to_depth_*`
- 2 new test cases: `TestFunctionalize::test_multioutput_view_*`
- new test case: `TestGradTransform::test_linear_nd_inplace_activation`
- new test case: `TestAutogradFunction::test_unwrap_dead_wrappers`
- 1 less skipped: `test_unrelated_hessian` now passes on XPU
- `TestGradTrackingTensorToList` is no longer device-parametrized: the
local
copy ran its 4 device-agnostic test cases twice (CPU and XPU), upstream
marks
  the class `GENERIC` and runs them once
- the 15 device-parametrized classes are renamed to `Test*Device`


2) **functorch/test_leaf_function.py**

Upstream PR: pytorch/pytorch#193950

Before: not run
After:  102 passed, 1 skipped


3) **export/test_passes.py**

Upstream PR: pytorch/pytorch#196974

Before: 25 passed, 2 xfailed
After:  26 passed, 4 skipped, 2 xfailed

Changes:
- 5 new test cases: `TestMoveToDevicePassCuda`, 4 require CUDA and are
skipped,
  `test_move_to_device_pass_interpreter_only_graph` passes
- move `test_move_device_example_inputs`, `test_move_device_submod`,
`test_move_device_to` and `test_move_to_device_pass` from `TestPasses`
to the
  new device-parametrized `TestMoveToDevicePassDevice`

4) **export/test_converter.py**

Upstream PR: pytorch/pytorch#197113

Before: 46 passed, 2 skipped
After:  46 passed, 2 skipped

Changes:
- move `test_prim_device` from `TestConverter` to the new
device-parametrized
`TestConverterDevice`, which runs it on both CPU and XPU. The local copy
carried it as `test_prim_device_cuda` with a hardcoded `device="xpu:0"`,
  so a single misnamed test case becomes two properly parametrized ones
minmingzhu pushed a commit to minmingzhu/torch-xpu-ops that referenced this pull request Oct 28, 2026
…tel#5693)

Next PR for synchronizing upstream generalization with local files:

1) **functorch/test_eager_transforms.py**

Upstream PR: pytorch/pytorch#192806

Before: 682 passed, 7 skipped, 2 xfailed
After:  721 passed, 6 skipped, 2 xfailed

Changes:
- 11 new test cases: `TestGradTransform::test_inference_mode_*`
- 4 new test cases: `TestCompileTransforms::test_compile_dynamic_grad_*`
- 2 new test cases:
`TestGradTransform::test_pop_dynamic_layer_stack_to_depth_*`
- 2 new test cases: `TestFunctionalize::test_multioutput_view_*`
- new test case: `TestGradTransform::test_linear_nd_inplace_activation`
- new test case: `TestAutogradFunction::test_unwrap_dead_wrappers`
- 1 less skipped: `test_unrelated_hessian` now passes on XPU
- `TestGradTrackingTensorToList` is no longer device-parametrized: the
local
copy ran its 4 device-agnostic test cases twice (CPU and XPU), upstream
marks
  the class `GENERIC` and runs them once
- the 15 device-parametrized classes are renamed to `Test*Device`


2) **functorch/test_leaf_function.py**

Upstream PR: pytorch/pytorch#193950

Before: not run
After:  102 passed, 1 skipped


3) **export/test_passes.py**

Upstream PR: pytorch/pytorch#196974

Before: 25 passed, 2 xfailed
After:  26 passed, 4 skipped, 2 xfailed

Changes:
- 5 new test cases: `TestMoveToDevicePassCuda`, 4 require CUDA and are
skipped,
  `test_move_to_device_pass_interpreter_only_graph` passes
- move `test_move_device_example_inputs`, `test_move_device_submod`,
`test_move_device_to` and `test_move_to_device_pass` from `TestPasses`
to the
  new device-parametrized `TestMoveToDevicePassDevice`

4) **export/test_converter.py**

Upstream PR: pytorch/pytorch#197113

Before: 46 passed, 2 skipped
After:  46 passed, 2 skipped

Changes:
- move `test_prim_device` from `TestConverter` to the new
device-parametrized
`TestConverterDevice`, which runs it on both CPU and XPU. The local copy
carried it as `test_prim_device_cuda` with a hardcoded `device="xpu:0"`,
  so a single misnamed test case becomes two properly parametrized ones
pytorchmergebot pushed a commit to tszulist-hbn/pytorch that referenced this pull request Nov 13, 2026
…rators

Four move_to_device_pass tests sat in TestMoveToDevicePassCuda behind
skipIf(not TEST_CUDA) with "cuda:0" hard-coded, so XPU and other
accelerators skipped them. Nothing in them is CUDA-specific. They check
that the moved GraphModule and its nested torch.cond submodules are
recompiled, that the source module's parameters and buffers are not
mutated, and that wrapper-subclass parameters move with their inner
tensors.

Root cause: pytorch#185105 added the tests behind a TEST_CUDA gate. pytorch#196974
moved the four older move_to_device_pass tests into the device-generic
TestMoveToDevicePassDevice but left these behind, and pytorch#191079 then
tagged their class CUDA to match its gate.

Move them into TestMoveToDevicePassDevice with a device parameter, drop
the gates and replace each "cuda:0" with device. The instantiated
primary device always carries an index (cuda:N, xpu:N,
<privateuse1>:N), so the code and device-equality assertions behave as
before on CUDA. After the previous commit the CUDA class is empty, so
delete it and the now-unused TEST_CUDA import.

XPU, PrivateUse1 and HPU gain the four tests. CUDA keeps them as
TestMoveToDevicePassDeviceCUDA::<name>_cuda. On a machine without an
accelerator they are no longer collected instead of being reported as
skipped, the same trade-off pytorch#196974 made. Widening the gate to TEST_CUDA
or TEST_XPU was the alternative; it keeps the hard-coded device and
leaves PrivateUse1 out.

See intel/torch-xpu-ops#5994.

Test Plan:

The same AST comparison as the previous commit: the four methods match
the originals once device maps back to 'cuda:0' and the device parameter
and TEST_CUDA skip are dropped. The other 40 methods are unchanged.

On an Intel Data Center GPU Max 1550:

```
python test/export/test_passes.py -v -k move_device -k move_to_device
python test/export/test_passes.py
```

All 8 TestMoveToDevicePassDeviceXPU tests pass, 4 of them new. The whole
file goes from OK (skipped=4, expected failures=2) to
OK (expected failures=2) with the same 39 tests. The only ID changes are
TestMoveToDevicePassCuda::<name> ->
TestMoveToDevicePassDeviceXPU::<name>_xpu. CUDA was not run locally.

Authored with an AI assistant (Claude Code).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
pytorchmergebot pushed a commit to tszulist-hbn/pytorch that referenced this pull request Nov 16, 2026
…rators

Four move_to_device_pass tests sat in TestMoveToDevicePassCuda behind
skipIf(not TEST_CUDA) with "cuda:0" hard-coded, so XPU and other
accelerators skipped them. Nothing in them is CUDA-specific. They check
that the moved GraphModule and its nested torch.cond submodules are
recompiled, that the source module's parameters and buffers are not
mutated, and that wrapper-subclass parameters move with their inner
tensors.

Root cause: pytorch#185105 added the tests behind a TEST_CUDA gate. pytorch#196974
moved the four older move_to_device_pass tests into the device-generic
TestMoveToDevicePassDevice but left these behind, and pytorch#191079 then
tagged their class CUDA to match its gate.

Move them into TestMoveToDevicePassDevice with a device parameter, drop
the gates and replace each "cuda:0" with device. The instantiated
primary device always carries an index (cuda:N, xpu:N,
<privateuse1>:N), so the code and device-equality assertions behave as
before on CUDA. After the previous commit the CUDA class is empty, so
delete it and the now-unused TEST_CUDA import.

XPU, PrivateUse1 and HPU gain the four tests. CUDA keeps them as
TestMoveToDevicePassDeviceCUDA::<name>_cuda. On a machine without an
accelerator they are no longer collected instead of being reported as
skipped, the same trade-off pytorch#196974 made. Widening the gate to TEST_CUDA
or TEST_XPU was the alternative; it keeps the hard-coded device and
leaves PrivateUse1 out.

See intel/torch-xpu-ops#5994.

Test Plan:

The same AST comparison as the previous commit: the four methods match
the originals once device maps back to 'cuda:0' and the device parameter
and TEST_CUDA skip are dropped. The other 40 methods are unchanged.

On an Intel Data Center GPU Max 1550:

```
python test/export/test_passes.py -v -k move_device -k move_to_device
python test/export/test_passes.py
```

All 8 TestMoveToDevicePassDeviceXPU tests pass, 4 of them new. The whole
file goes from OK (skipped=4, expected failures=2) to
OK (expected failures=2) with the same 39 tests. The only ID changes are
TestMoveToDevicePassCuda::<name> ->
TestMoveToDevicePassDeviceXPU::<name>_xpu. CUDA was not run locally.

Authored with an AI assistant (Claude Code).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
pytorchmergebot pushed a commit to tszulist-hbn/pytorch that referenced this pull request Nov 18, 2026
…rators

Four move_to_device_pass tests sat in TestMoveToDevicePassCuda behind
skipIf(not TEST_CUDA) with "cuda:0" hard-coded, so XPU and other
accelerators skipped them. Nothing in them is CUDA-specific. They check
that the moved GraphModule and its nested torch.cond submodules are
recompiled, that the source module's parameters and buffers are not
mutated, and that wrapper-subclass parameters move with their inner
tensors.

Root cause: pytorch#185105 added the tests behind a TEST_CUDA gate. pytorch#196974
moved the four older move_to_device_pass tests into the device-generic
TestMoveToDevicePassDevice but left these behind, and pytorch#191079 then
tagged their class CUDA to match its gate.

Move them into TestMoveToDevicePassDevice with a device parameter, drop
the gates and replace each "cuda:0" with device. The instantiated
primary device always carries an index (cuda:N, xpu:N,
<privateuse1>:N), so the code and device-equality assertions behave as
before on CUDA. After the previous commit the CUDA class is empty, so
delete it and the now-unused TEST_CUDA import.

XPU, PrivateUse1 and HPU gain the four tests. CUDA keeps them as
TestMoveToDevicePassDeviceCUDA::<name>_cuda. On a machine without an
accelerator they are no longer collected instead of being reported as
skipped, the same trade-off pytorch#196974 made. Widening the gate to TEST_CUDA
or TEST_XPU was the alternative; it keeps the hard-coded device and
leaves PrivateUse1 out.

See intel/torch-xpu-ops#5994.

Test Plan:

The same AST comparison as the previous commit: the four methods match
the originals once device maps back to 'cuda:0' and the device parameter
and TEST_CUDA skip are dropped. The other 40 methods are unchanged.

On an Intel Data Center GPU Max 1550:

```
python test/export/test_passes.py -v -k move_device -k move_to_device
python test/export/test_passes.py
```

All 8 TestMoveToDevicePassDeviceXPU tests pass, 4 of them new. The whole
file goes from OK (skipped=4, expected failures=2) to
OK (expected failures=2) with the same 39 tests. The only ID changes are
TestMoveToDevicePassCuda::<name> ->
TestMoveToDevicePassDeviceXPU::<name>_xpu. CUDA was not run locally.

Authored with an AI assistant (Claude Code).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
pytorchmergebot pushed a commit that referenced this pull request Nov 27, 2026
…#204608)

### Linked issue or supporting maintainer

Fixes intel/torch-xpu-ops#5994

### BC-breaking?

No

### Summary

- XPU, PrivateUse1 and HPU gain four `move_to_device_pass` tests that were CUDA-only by decorator. CUDA keeps them under device-suffixed IDs. Test bodies are unchanged apart from `"cuda:0"` -> `device`.
- `test_move_to_device_pass_interpreter_only_graph` uses only `meta`, so it is now a GENERIC test: it runs on CPU and XPU jobs, no longer on CUDA ones. Its macOS skip is covered by the identical class-level skip on `TestPasses`.
- On a machine without an accelerator the four tests are no longer collected instead of being reported as skipped, the same trade-off as #196974.
- Tested on an Intel Max 1550 only: the 4 skips become passes, 39/39 in the file. Not run on CUDA or PrivateUse1.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Pull Request resolved: #204608
Approved by: https://github.com/pbielak, https://github.com/etaf, https://github.com/jansel

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 Merged open source topic: not user facing topic category

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

7 participants