Skip to content

[Profiler] Fix a set of profiler tests - #186970

Closed
ryanzhang22 wants to merge 2 commits into
pytorch:mainfrom
ryanzhang22:profiler-fix-more-tests
Closed

ryanzhang22 wants to merge 2 commits into
pytorch:mainfrom
ryanzhang22:profiler-fix-more-tests

Conversation

@ryanzhang22

@ryanzhang22 ryanzhang22 commented Jun 10, 2026 •

Copy link
Copy Markdown
Contributor

A couple changes for pytorch/kineto#1429 and pytorch/kineto#1430:

  1. Add setUpModule to make sure Kineto is created with CUDA support. Fix CPU-only profiler mode to avoid initializing GPU tracing #186036 recently changed the behavior to not initialize Kineto with GPU tracing if only CPU activities are requested, which is more correct behavior. However, this changes the behavior of the following code:
with profile(activities=[ProfilerActivity.CPU]) as prof:
   ...

with profile(activities=[ProfilerActivity.CPU, ProfilerActivity.CUDA]) as prof:
   ...

Now Kineto is armed to only do CPU tracing. The issue is that Kineto is only registered once, so even though you added ProfilerActivity.CUDA in the second pass, the profiler still latches on to the CPU-only session, leading to no device-side activities being recorded. We need to find a more complete solution but to unblock the tests we can hack around it by forcing Kineto to instantiate with GPU-tracing before running any tests.

  1. Clear KinetoStepTracker to make sure repeat runs with different activity types don't pollute test_kineto_profiler_multiple_steppers.
  2. Make sure test_forked_process explicitly runs with CPU activities only.

There are a few more failures due to test pollution, but I haven't tracked those down yet.

@ryanzhang22
ryanzhang22 requested a review from scotts June 10, 2026 20:24
@pytorch-bot

pytorch-bot Bot commented Jun 10, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ No Failures

As of commit 3eec903 with merge base d2bb2b5 (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 Jun 10, 2026
@ryanzhang22 ryanzhang22 changed the title Profiler fix more tests [Profiler] Fix a set of profiler tests Jun 10, 2026
@ryanzhang22

Copy link
Copy Markdown
Contributor Author

@pytorchbot 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 profiler-fix-more-tests onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via git checkout profiler-fix-more-tests && git pull --rebase)

@pytorchmergebot
pytorchmergebot force-pushed the profiler-fix-more-tests branch from dfa4620 to d54590a Compare June 10, 2026 20:28
@meta-codesync

meta-codesync Bot commented Jun 10, 2026

Copy link
Copy Markdown

@ryanzhang22 has imported this pull request. If you are a Meta employee, you can view this in D108206446.

@ryanzhang22

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Jun 10, 2026
@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

ryanzhang22 added a commit to ryanzhang22/kineto that referenced this pull request Jun 11, 2026
Summary:

These should have been fixed in pytorch/pytorch#186970

Differential Revision: D108287028
jemitche1 pushed a commit to jemitche1/pytorch that referenced this pull request Jun 13, 2026
A couple changes for pytorch/kineto#1429 and pytorch/kineto#1430:

1. Add `setUpModule` to make sure Kineto is created with CUDA support. pytorch#186036 recently changed the behavior to not initialize Kineto with GPU tracing if only CPU activities are requested, which is more correct behavior. However, this changes the behavior of the following code:

```
with profile(activities=[ProfilerActivity.CPU]) as prof:
   ...

with profile(activities=[ProfilerActivity.CPU, ProfilerActivity.CUDA]) as prof:
   ...
```

Now Kineto is armed to only do CPU tracing. The issue is that Kineto is only registered once, so even though you added ProfilerActivity.CUDA in the second pass, the profiler still latches on to the CPU-only session, leading to no device-side activities being recorded. We need to find a more complete solution but to unblock the tests we can hack around it by forcing Kineto to instantiate with GPU-tracing before running any tests.

2. Clear KinetoStepTracker to make sure repeat runs with different activity types don't pollute `test_kineto_profiler_multiple_steppers`.
3. Make sure `test_forked_process` explicitly runs with CPU activities only.

There are a few more failures due to test pollution, but I haven't tracked those down yet.
Pull Request resolved: pytorch#186970
Approved by: https://github.com/scotts
ryanzhang22 added a commit to ryanzhang22/kineto that referenced this pull request Jun 16, 2026
Summary:

These should have been fixed in pytorch/pytorch#186970

Reviewed By: scotts

Differential Revision: D108287028
ryanzhang22 added a commit to ryanzhang22/kineto that referenced this pull request Jun 16, 2026
Summary:

These should have been fixed in pytorch/pytorch#186970

Reviewed By: scotts

Differential Revision: D108287028
ryanzhang22 added a commit to ryanzhang22/kineto that referenced this pull request Jun 16, 2026
Summary:

These should have been fixed in pytorch/pytorch#186970

Reviewed By: scotts

Differential Revision: D108287028
ryanzhang22 added a commit to ryanzhang22/kineto that referenced this pull request Jul 1, 2026
Summary:

These should have been fixed in pytorch/pytorch#186970

Reviewed By: scotts

Differential Revision: D108287028
ryanzhang22 added a commit to ryanzhang22/kineto that referenced this pull request Jul 1, 2026
Summary:

These should have been fixed in pytorch/pytorch#186970

Reviewed By: scotts

Differential Revision: D108287028
ryanzhang22 added a commit to ryanzhang22/kineto that referenced this pull request Jul 2, 2026
Summary:

These should have been fixed in pytorch/pytorch#186970

Reviewed By: scotts

Differential Revision: D108287028
ryanzhang22 added a commit to ryanzhang22/kineto that referenced this pull request Jul 6, 2026
Summary:

These should have been fixed in pytorch/pytorch#186970

Reviewed By: scotts

Differential Revision: D108287028
ryanzhang22 added a commit to ryanzhang22/kineto that referenced this pull request Jul 6, 2026
Summary:

These should have been fixed in pytorch/pytorch#186970

Reviewed By: scotts

Differential Revision: D108287028
ryanzhang22 added a commit to ryanzhang22/kineto that referenced this pull request Jul 13, 2026
Summary:

These should have been fixed in pytorch/pytorch#186970

Reviewed By: scotts

Differential Revision: D108287028
ryanzhang22 added a commit to ryanzhang22/kineto that referenced this pull request Jul 13, 2026
Summary:

These should have been fixed in pytorch/pytorch#186970

Reviewed By: scotts

Differential Revision: D108287028
ryanzhang22 added a commit to ryanzhang22/kineto that referenced this pull request Jul 13, 2026
Summary:

These should have been fixed in pytorch/pytorch#186970

Reviewed By: scotts

Differential Revision: D108287028
meta-codesync Bot pushed a commit to pytorch/kineto that referenced this pull request Jul 13, 2026
Summary:
Pull Request resolved: #1432

These should have been fixed in pytorch/pytorch#186970

Reviewed By: scotts

Differential Revision: D108287028

fbshipit-source-id: f1113f338f614429cd94f17b577c3db66f40925f
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
A couple changes for pytorch/kineto#1429 and pytorch/kineto#1430:

1. Add `setUpModule` to make sure Kineto is created with CUDA support. pytorch#186036 recently changed the behavior to not initialize Kineto with GPU tracing if only CPU activities are requested, which is more correct behavior. However, this changes the behavior of the following code:

```
with profile(activities=[ProfilerActivity.CPU]) as prof:
   ...

with profile(activities=[ProfilerActivity.CPU, ProfilerActivity.CUDA]) as prof:
   ...
```

Now Kineto is armed to only do CPU tracing. The issue is that Kineto is only registered once, so even though you added ProfilerActivity.CUDA in the second pass, the profiler still latches on to the CPU-only session, leading to no device-side activities being recorded. We need to find a more complete solution but to unblock the tests we can hack around it by forcing Kineto to instantiate with GPU-tracing before running any tests.

2. Clear KinetoStepTracker to make sure repeat runs with different activity types don't pollute `test_kineto_profiler_multiple_steppers`.
3. Make sure `test_forked_process` explicitly runs with CPU activities only.

There are a few more failures due to test pollution, but I haven't tracked those down yet.
Pull Request resolved: pytorch#186970
Approved by: https://github.com/scotts
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
A couple changes for pytorch/kineto#1429 and pytorch/kineto#1430:

1. Add `setUpModule` to make sure Kineto is created with CUDA support. pytorch#186036 recently changed the behavior to not initialize Kineto with GPU tracing if only CPU activities are requested, which is more correct behavior. However, this changes the behavior of the following code:

```
with profile(activities=[ProfilerActivity.CPU]) as prof:
   ...

with profile(activities=[ProfilerActivity.CPU, ProfilerActivity.CUDA]) as prof:
   ...
```

Now Kineto is armed to only do CPU tracing. The issue is that Kineto is only registered once, so even though you added ProfilerActivity.CUDA in the second pass, the profiler still latches on to the CPU-only session, leading to no device-side activities being recorded. We need to find a more complete solution but to unblock the tests we can hack around it by forcing Kineto to instantiate with GPU-tracing before running any tests.

2. Clear KinetoStepTracker to make sure repeat runs with different activity types don't pollute `test_kineto_profiler_multiple_steppers`.
3. Make sure `test_forked_process` explicitly runs with CPU activities only.

There are a few more failures due to test pollution, but I haven't tracked those down yet.
Pull Request resolved: pytorch#186970
Approved by: https://github.com/scotts
torchxpubot pushed a commit to intel/torch-xpu-ops that referenced this pull request Sep 7, 2026
Kineto is initialized only once per process and is then unable to be
extended to profile accelerator if initialized only for CPU. This change
is a workaround to avoid test flakyness by always priming profiler with
accelerator activity. This mirrors upstream version of this test file
(Relevant PR: pytorch/pytorch#186970).

Fixes: #5171
orrangetabby17 pushed a commit to intel/torch-xpu-ops that referenced this pull request Oct 8, 2026
Kineto is initialized only once per process and is then unable to be
extended to profile accelerator if initialized only for CPU. This change
is a workaround to avoid test flakyness by always priming profiler with
accelerator activity. This mirrors upstream version of this test file
(Relevant PR: pytorch/pytorch#186970).

Fixes: #5171
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants