Skip to content

[Test] Enable test/profiler/test_profiler.py on XPU - #196466

Closed
tszulist-hbn wants to merge 3 commits into
pytorch:mainfrom
tszulist-hbn:xpu-enable-test-profiler
Closed

tszulist-hbn wants to merge 3 commits into
pytorch:mainfrom
tszulist-hbn:xpu-enable-test-profiler

Conversation

@tszulist-hbn

@tszulist-hbn tszulist-hbn commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Part of #142029.

Enables the device-generic tests in test/profiler/test_profiler.py on XPU. Most of the hardware classification this PR used to carry landed upstream in #198321-#198324. What is left, reviewable in order:

  1. Classify the inline-annotation tests as generic (they need no CUDA) and name the CUDA-gated metadata test class for its gate.
  2. Prime Kineto with the current accelerator instead of CUDA only. Without it, a CPU-only first session leaves XPU collection dead process-wide (kernel, ac2g, xpu_runtime all 0). The CUDA priming helper used by test_cuspy.py and test_linalg.py is unchanged.
  3. Run the device-generic tests on XPU, drop a stale skip for the now-closed torch-xpu-ops#2263, and widen test_kineto to XPU.

Coverage delta

Intel Data Center GPU Max 1550, oneAPI 2026.1.1.

XPU test IDs before after
total 0 20
passed 0 18
skipped 0 1
failed 0 1

Follow-ups filed against intel/torch-xpu-ops

@pytorch-bot

pytorch-bot Bot commented Sep 9, 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:

Enables TestProfilerDevice on XPU and generalizes Kineto priming in setUpModule
to the current accelerator; CUDA/ROCm behavior is unchanged. The one issue found
is a skip used where an expected-failure marker fits, which does not block human
review.

Findings (1):

[minor] test/profiler/test_profiler.py:3124
XPU kernel events deterministically lack stream/grid/block (assertIn fails, no
crash/hang), so use @​ expectedFailureXPU instead of skipXPUIf(True, ...) so the
test flips to unexpected-success once torch-xpu-ops#5284 is fixed.

Reviewed commit: f4054ab

Review run

🔗 Helpful Links

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

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

✅ No Failures

As of commit f4054ab with merge base bb154bb (image):
💚 Looks good so far! There are no failures yet. 💚

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 9, 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 9, 2026
Comment thread test/profiler/test_profiler.py Resolved
Comment thread test/profiler/test_profiler.py Resolved
Comment thread test/profiler/test_profiler.py Resolved
Comment thread test/profiler/test_profiler.py Resolved
Comment thread test/profiler/test_profiler.py Resolved
Comment thread test/profiler/test_profiler.py Resolved
@tszulist-hbn
tszulist-hbn force-pushed the xpu-enable-test-profiler branch from b3418a3 to 3b7f26a Compare September 10, 2026 10:03
@pytorch-bot

pytorch-bot Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

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

@tszulist-hbn tszulist-hbn changed the title [XPU] Enable test/profiler/test_profiler.py on Intel GPU [Test] Enable test/profiler/test_profiler.py on XPU Sep 10, 2026
@daisyden
daisyden requested a review from pbielak September 15, 2026 08:50
@tszulist-hbn
tszulist-hbn force-pushed the xpu-enable-test-profiler branch from 3b7f26a to 3f30780 Compare September 16, 2026 08:36
@pbielak
pbielak requested a review from etaf September 22, 2026 11:37
@kdrozd-dev

Copy link
Copy Markdown
Contributor

This looks like a partial duplicate of #193961

Comment thread test/profiler/test_profiler.py Resolved
@tszulist-hbn
tszulist-hbn force-pushed the xpu-enable-test-profiler branch from 3f30780 to f35d57f Compare September 25, 2026 09:47
@tszulist-hbn
tszulist-hbn requested a review from etaf September 28, 2026 08:21
Comment thread test/profiler/test_profiler.py Resolved
@tszulist-hbn
tszulist-hbn force-pushed the xpu-enable-test-profiler branch from f35d57f to 5eafd46 Compare September 29, 2026 08:24
@tszulist-hbn
tszulist-hbn requested a review from etaf September 29, 2026 08:29
Comment thread test/profiler/test_profiler.py Resolved
tszulist-hbn and others added 3 commits September 29, 2026 12:02
TestChromeTraceInlineAnnotations drives stub activities and needs no CUDA,
so classify it GENERIC. Rename TestMetadataJsonFormat to
TestMetadataJsonFormatCUDA so its name matches its CUDA gate.

Test Plan:

```
$ python test/profiler/test_profiler.py --hw-classification generic -v
Ran 90 tests in 6.922s
OK (skipped=1)
```

Authored with the assistance of an AI coding agent (Claude Code).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
setUpModule() primed Kineto only for CUDA, so on other accelerators a
CPU-only first session left device collection dead process-wide. Add
initialize_kineto_with_accelerator() next to initialize_kineto_with_cuda()
and call it instead; the CUDA helper, used by test_cuspy.py and
test_linalg.py, is unchanged.

Priming XPU makes test_forked_process deadlock
(intel/torch-xpu-ops#5287), so it is skipped on
XPU builds in the same commit.

Test Plan, on Intel Data Center GPU Max 1550:

```
$ python test/profiler/test_profiler.py
Ran 116 tests in 19.248s
OK (skipped=16)
```

Authored with the assistance of an AI coding agent (Claude Code).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
TestProfilerDevice was already device-generic but never instantiated for XPU,
leaving its XPU-specific code dead. Set allow_xpu=True (not only_for, which
would drop the PrivateUse1 and HPU instances the bare call already generated),
drop a stale skip citing torch-xpu-ops#2263 (closed, and fixed in this very
file by e0bab07), and widen test_kineto's onlyOn along with the matching
branch in its body: XPU emits gemm_kernel and urEnqueueUSMMemcpy, so it belongs
on the found_gemm/found_memcpy path rather than the found_mm one.

Enablement exposed one real gap. XPU kernel activities carry "sycl queue" and
"l0 queue" but no stream, grid or block, so test_kineto_kernel_metadata_in_trace
fails; filed as intel/torch-xpu-ops#5284 and skipped
on XPU with that URL as the reason.

The torch-xpu-ops fork of this file, test/xpu/profiler/test_profiler_xpu.py,
still cannot be deleted - it mirrors five other classes besides
TestProfilerDevice.

Test Plan:

TestProfilerDeviceXPU goes 0 -> 18 IDs and every other class keeps its count
(TestProfiler 57, TestProfilerDeviceCPU 18, TestProfilerDeviceStoppedCUDA 18,
TestChromeTraceInlineAnnotations 12, TestProfilerEventsParityCUDA 10,
TestProfilerCUDA 8, TestExperimentalUtils 7, TestPythonChromeTraceExportCUDA 5,
TestMetadataJsonFormatCUDA 4, TestPrivateUse1ProfilerState 3, TestProfilerITT 1),
so 143 -> 161.

On Intel Data Center GPU Max 1550, oneAPI 2026.1.1:

```
$ python test/profiler/test_profiler.py
Ran 161 tests in 42.913s
OK (skipped=60)
```

```
$ python -m pytest test/profiler/test_profiler.py -k xpu -rs
16 passed, 2 skipped, 143 deselected in 16.33s
```

The two XPU skips are test_kineto_kernel_metadata_in_trace (pytorch#5284 above) and
test_activity_filter_dict_syntax (onlyOn cuda; XPU dies with PTI_ERROR_DRIVER in
XpuptiScopeProfilerApi::enableScopeProfiler).

Authored with the assistance of an AI coding agent (Claude Code).

Co-Authored-By: Claude Opus 5 <[email protected]>
@tszulist-hbn
tszulist-hbn force-pushed the xpu-enable-test-profiler branch from 5eafd46 to f4054ab Compare September 29, 2026 12:27
@tszulist-hbn
tszulist-hbn requested a review from etaf September 29, 2026 16:47
@tszulist-hbn
tszulist-hbn marked this pull request as ready for review October 8, 2026 06:13
@github-actions
github-actions Bot requested a review from fffrog October 8, 2026 06:16
@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 Oct 8, 2026
@jansel jansel added the in progress PR is being worked on by the author, until the automated review accepts it label Oct 8, 2026
@github-actions github-actions 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 Oct 8, 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 f4054ab: nothing blocking; ready for human review.

Enables TestProfilerDevice on XPU and generalizes Kineto priming in setUpModule to the current accelerator; CUDA/ROCm behavior is unchanged. The one issue found is a skip used where an expected-failure marker fits, which does not block human review.

⚪ 1 non-blocking finding

XPU kernel events deterministically lack stream/grid/block (assertIn fails, no crash/hang), so use @ expectedFailureXPU instead of skipXPUIf(True, ...) so the test flips to unexpected-success once torch-xpu-ops#5284 is fixed.

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

@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
Part of pytorch#142029.

Enables the device-generic tests in `test/profiler/test_profiler.py` on XPU. Most of the hardware classification this PR used to carry landed upstream in pytorch#198321-pytorch#198324. What is left, reviewable in order:

1. Classify the inline-annotation tests as generic (they need no CUDA) and name the CUDA-gated metadata test class for its gate.
2. Prime Kineto with the current accelerator instead of CUDA only. Without it, a CPU-only first session leaves XPU collection dead process-wide (`kernel`, `ac2g`, `xpu_runtime` all 0). The CUDA priming helper used by `test_cuspy.py` and `test_linalg.py` is unchanged.
3. Run the device-generic tests on XPU, drop a stale skip for the now-closed torch-xpu-ops#2263, and widen `test_kineto` to XPU.

### Coverage delta

Intel Data Center GPU Max 1550, oneAPI 2026.1.1.

| XPU test IDs | before | after |
| ------------ | ------ | ----- |
| total        | 0      | 20    |
| passed       | 0      | 18    |
| skipped      | 0      | 1     |
| failed       | 0      | 1     |

### Follow-ups filed against intel/torch-xpu-ops

- intel/torch-xpu-ops#5284 - XPU kernel activities carry `sycl queue` / `l0 queue` but no `stream`, `grid` or `block`. Skips `test_kineto_kernel_metadata_in_trace` on XPU, and blocks the CUDA metadata-format tests from being enabled as written.
- intel/torch-xpu-ops#5287 - `os.fork()` deadlocks after Kineto XPU init. Skips `test_forked_process` on XPU builds.
Pull Request resolved: pytorch#196466
Approved by: https://github.com/pbielak, https://github.com/etaf, https://github.com/jansel

Co-authored-by: Claude Opus 5 <[email protected]>
pytorchmergebot pushed a commit to tszulist-hbn/pytorch that referenced this pull request Oct 15, 2026
pytorch#196466 enabled TestProfilerDevice on XPU, which added
test_profiler_tracing_use_kineto_False_xpu. It always fails:
_profile(use_device="xpu", use_kineto=False) raises on purpose, because
only CUDA and PrivateUse1 can profile without Kineto. Skip that case on
XPU; use_kineto=True still runs.
pytorchmergebot pushed a commit to tszulist-hbn/pytorch that referenced this pull request Oct 15, 2026
pytorch#196466 enabled TestProfilerDevice on XPU, which added
test_profiler_tracing_use_kineto_False_xpu. It always fails:
_profile(use_device="xpu", use_kineto=False) raises on purpose, because
only CUDA and PrivateUse1 can profile without Kineto. Skip that case on
XPU; use_kineto=True still runs.

This branch was previously deployed

1 inactive deployment
bedrock — f4054aba Deployed Oct 8, 2026 by tszulist-hbn
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 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

None yet

Development

Successfully merging this pull request may close these issues.

8 participants