Skip to content

[XPU] Run the remaining move_to_device_pass tests on all accelerators - #204608

Closed
tszulist-hbn wants to merge 2 commits into
pytorch:mainfrom
tszulist-hbn:xpu-5994-move-to-device-pass
Closed

tszulist-hbn wants to merge 2 commits into
pytorch:mainfrom
tszulist-hbn:xpu-5994-move-to-device-pass

Conversation

@tszulist-hbn

Copy link
Copy Markdown
Contributor

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 [Test][XPU] Make test/export/test_passes.py device-generic and enable it on XPU #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

@pytorch-bot

pytorch-bot Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

PR Status: Approved 🚀

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

✅ AUTOMATED REVIEW - Ready for human review:

The PR deletes TestMoveToDevicePassCuda, moving four tests into the ACCELERATOR
class TestMoveToDevicePassDevice (using `device`) and the meta-only
interpreter-only test into the GENERIC class TestPasses. Recommendation:
Approve, with only one non-blocking point (a redundant setup call).

Findings (1):

[minor] test/export/test_passes.py:1588
Redundant setup call (non-blocking): the moved
`test_move_to_device_pass_interpreter_only_graph` still calls
`init_torchbind_implementations()`. That call was needed in the old
`TestMoveToDevicePassCuda`, which had no `setUp`. In `TestPasses`, `setUp`
already makes the call (line 393), and the function returns early once
initialized (`torch/testing/_internal/torchbind_impls.py:13-23`). It is now the
only inline call in `TestPasses`, so the line can be dropped.

Reviewed commit: cb7da33

Review run

🐛 Report a bad review

🔗 Helpful Links

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

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 cb7da33 with merge base a8ff086 (image):

FLAKY - The following job failed but was likely due to flakiness present on trunk:

BROKEN TRUNK - The following job failed but was 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.

@pbielak pbielak added ciflow/trunk Trigger trunk jobs on your pull request keep-going Don't stop on first failure, keep running tests until the end ciflow/xpu Run XPU CI tasks labels Nov 13, 2026
@pbielak pbielak added the ci-no-td Do not run TD on this PR label Nov 13, 2026
@pbielak
pbielak requested a review from etaf November 13, 2026 08:26
@tszulist-hbn

Copy link
Copy Markdown
Contributor Author

@pytorchmergebot 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 xpu-5994-move-to-device-pass onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via git checkout xpu-5994-move-to-device-pass && git pull --rebase)

@pytorchmergebot
pytorchmergebot force-pushed the xpu-5994-move-to-device-pass branch from 24c2d7f to 6501c2f Compare November 13, 2026 21:10
@pytorch-bot

pytorch-bot Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

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

@tszulist-hbn

Copy link
Copy Markdown
Contributor Author

@pytorchmergebot 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 xpu-5994-move-to-device-pass onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via git checkout xpu-5994-move-to-device-pass && git pull --rebase)

@pytorchmergebot
pytorchmergebot force-pushed the xpu-5994-move-to-device-pass branch from 6501c2f to f5d23d8 Compare November 16, 2026 08:12
@tszulist-hbn

Copy link
Copy Markdown
Contributor Author

@etaf, when you have a chance, could you please take a look at this. Thanks!

@etaf

etaf commented Nov 18, 2026

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

tszulist-hbn and others added 2 commits November 18, 2026 10:01
…NERIC

test_move_to_device_pass_interpreter_only_graph moves an exported
program to the meta device and needs no accelerator, but it sits in
TestMoveToDevicePassCuda (hw_classification = CUDA) next to the
CUDA-gated move_to_device_pass tests. Move it to TestPasses (GENERIC).
The body is unchanged. Its method-level skipIf(IS_MACOS, ...) is dropped
because TestPasses carries the same skip at class level.

CUDA/ROCm jobs exclude GENERIC classes (.ci/pytorch/test.sh), so the
test now runs on CPU and XPU jobs and no longer on CUDA ones.

Test Plan:

An AST comparison of every test-class method, decorators included,
between the parent and this commit reports one move
(TestMoveToDevicePassCuda -> TestPasses, IS_MACOS skip dropped) and 43
methods unchanged.

On an Intel Data Center GPU Max 1550:

```
python test/export/test_passes.py -v --hw-classification GENERIC -k interpreter_only_graph
python test/export/test_passes.py
```

The first run selects and passes the moved test (total=1, passed=1,
unclassified=0). The whole file reports the same 39 tests and
OK (skipped=4, expected failures=2) before and after.

Authored with an AI assistant (Claude Code).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…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

Copy link
Copy Markdown
Collaborator

Successfully rebased xpu-5994-move-to-device-pass onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via git checkout xpu-5994-move-to-device-pass && git pull --rebase)

@pytorchmergebot
pytorchmergebot force-pushed the xpu-5994-move-to-device-pass branch from f5d23d8 to cb7da33 Compare November 18, 2026 10:01
@etaf
etaf marked this pull request as ready for review November 20, 2026 01:57
@etaf etaf added the in progress PR is being worked on by the author, until the automated review accepts it label Nov 20, 2026
@github-actions
github-actions Bot requested a review from fffrog November 20, 2026 01:59
@github-actions github-actions Bot added bot-triaged This is a label only to be used by the auto triage bot triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module labels Nov 20, 2026

@github-actions github-actions Bot left a comment

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.

Automated review of cb7da33: nothing blocking; ready for human review.

The PR deletes TestMoveToDevicePassCuda, moving four tests into the ACCELERATOR class TestMoveToDevicePassDevice (using device) and the meta-only interpreter-only test into the GENERIC class TestPasses. Recommendation: Approve, with only one non-blocking point (a redundant setup call).

⚪ 1 non-blocking finding

init_torchbind_implementations()

Redundant setup call (non-blocking): the moved test_move_to_device_pass_interpreter_only_graph still calls init_torchbind_implementations(). That call was needed in the old TestMoveToDevicePassCuda, which had no setUp. In TestPasses, setUp already makes the call (line 393), and the function returns early once initialized (torch/testing/_internal/torchbind_impls.py:13-23). It is now the only inline call in TestPasses, so the line can be dropped.

This review is AI-generated and advisory. Each new automated review replaces the previous one. Report a bad review

@pytorch-bot pytorch-bot Bot added ready for review Automated review passed, ready for a final review by a maintainer. and removed in progress PR is being worked on by the author, until the automated review accepts it labels Nov 20, 2026
@pbielak
pbielak requested a review from jansel November 24, 2026 09:18
daisyden added a commit to daisyden/pytorch that referenced this pull request Nov 24, 2026
…tests on all accelerators)

Authored with AI assistant (opencode).
@tszulist-hbn

Copy link
Copy Markdown
Contributor Author

@pytorchmergebot 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

This branch was previously deployed

1 inactive deployment
bedrock — cb7da332 Deployed Nov 20, 2026 by etaf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot-triaged This is a label only to be used by the auto triage bot 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 ready for review Automated review passed, ready for a final review by a maintainer. 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.

[upstream_ut] Make the four TestMoveToDevicePassCuda tests in test/export/test_passes.py device-generic and run them on XPU

6 participants