Skip to content

[Test] Refactor test_profiler.py tests to enhance device compatibility[2/N] - #198321

Closed
can-gaa-hou wants to merge 2 commits into
gh/can-gaa-hou/52/basefrom
gh/can-gaa-hou/52/head
Closed

can-gaa-hou wants to merge 2 commits into
gh/can-gaa-hou/52/basefrom
gh/can-gaa-hou/52/head

Conversation

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ You can merge normally! (1 Unrelated Failure)

As of commit 6dcfe87 with merge base ecc974c (image):

NEW FAILURES SUPPRESSED BY AI (non-blocking) - The following job failed, but the AI CI Advisor judged the failure not to be evidence against this change:

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

Comment thread test/profiler/test_profiler.py Outdated
Comment on lines +2439 to +2441
with _profile(use_kineto=use_kineto) as prof:
t1, t2 = torch.ones(1), torch.ones(1)
torch.add(t1, t2)

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.

Suggested change
with _profile(use_kineto=use_kineto) as prof:
t1, t2 = torch.ones(1), torch.ones(1)
torch.add(t1, t2)
with _profile(use_device=device, use_kineto=use_kineto) as prof:
t1, t2 = torch.ones(1, device=device), torch.ones(1, device=device)
torch.add(t1, t2)

Comment thread test/profiler/test_profiler.py Outdated
Comment on lines +2468 to +2481
# Same test but for an accelerator.
if device_type == "cpu":
return

with _profile(use_device=device_type, use_kineto=use_kineto) as prof:
t1, t2 = torch.ones(1, device=device), torch.ones(1, device=device)
torch.add(t1, t2)

with TemporaryFileName(mode="w+") as fname:
prof.export_chrome_trace(fname)
# Now validate the json
with open(fname) as f:
json.load(f)

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.

Delete this one

[ghstack-poisoned]
@fffrog fffrog moved this from Backlog to Ready for Merge in PyTorch Test Refactoring Sep 23, 2026
@fffrog fffrog added the module: tests/simple This label covers all the testcase that are very straightforward label Sep 23, 2026
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Starting merge as part of PR stack under #198324

@github-project-automation github-project-automation Bot moved this from Ready for Merge to Done in PyTorch Test Refactoring Sep 23, 2026
pytorchmergebot pushed a commit that referenced this pull request Oct 9, 2026
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

- 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: #196466
Approved by: https://github.com/pbielak, https://github.com/etaf, https://github.com/jansel

Co-authored-by: Claude Opus 5 <[email protected]>
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]>
@github-actions
github-actions Bot deleted the gh/can-gaa-hou/52/head branch November 30, 2026 01:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merged module: tests/simple This label covers all the testcase that are very straightforward open source topic: not user facing topic category

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants