This repository was archived by the owner on Sep 30, 2026. It is now read-only.
Repository navigation
Conversation
Summary: When the sync profiling path is active and we've reached our limit of CUPTI activity buffers, `CuptiActivityApi::bufferRequested()` sets `stopCollection = true`. The async path already checks this via `isGpuCollectionStopped()` in `performRunLoopStep()`, but the sync path has no way to query it — the method is protected on `GenericActivityProfiler` and not exposed through the public `ActivityProfilerInterface`. This diff plumbs this status up through to the public interface. A follow-up change in PyTorch will use this API in the Python profiler's `step()` method to detect that the profiling had to stop early and force an early `stop_trace`. We've already fixed it so that when there's too many activity buffers, CUPTI should stop requesting buffers (D100731798 / pytorch#1362). But we still don't have a way to tell the Python layer that profiling should stop in synchronous tracing. Differential Revision: D101044411
|
@scotts has exported this pull request. If you are a Meta employee, you can view the originating Diff in D101044411. |
|
This pull request has been merged in 17708f5. |
scotts
added a commit
to scotts/pytorch
that referenced
this pull request
Apr 16, 2026
Includes the following commits: - Fix stream wait events referencing future correlation IDs (pytorch/kineto#1339) 23b5bb5 - Remove kineto tb_plugin directory entirely (pytorch/kineto#1368) 9497960 - Move Stream Sync events to a new row in JSON trace export (pytorch/kineto#1356) 041e7ce - Expose isGpuCollectionStopped() through Kineto's public API (pytorch/kineto#1367) 17708f5 - Fix toggle test (pytorch/kineto#1369) ee2103c - Link to correct fmt repo (pytorch/kineto#1345) 3447834 - Fix data race on CuptiActivityApi::externalCorrelationEnabled_ (pytorch/kineto#1365) 0e86499 - Stop allocating CUPTI buffers after exceeding max buffer count (pytorch/kineto#1362) 666f62c - Add XPU workflow (pytorch/kineto#1302) 11cc1e0 - Remove RocprofActivity.h/RoctracerActivity.h from RocmActivityProfiler.h (pytorch/kineto#1357) 896068d - Split ActivityProfilerController into Sync and Async Handlers (pytorch/kineto#1269) 6d7f045 - Add priority field to kernel metadata (pytorch/kineto#1361) f2a7423 - Add kineto-release skill (pytorch/kineto#1360) 675b6cd Authored with Claude.
pytorchmergebot
pushed a commit
to pytorch/pytorch
that referenced
this pull request
Apr 17, 2026
Includes the following commits: - Fix stream wait events referencing future correlation IDs (pytorch/kineto#1339) 23b5bb5 - Remove kineto tb_plugin directory entirely (pytorch/kineto#1368) 9497960 - Move Stream Sync events to a new row in JSON trace export (pytorch/kineto#1356) 041e7ce - Expose isGpuCollectionStopped() through Kineto's public API (pytorch/kineto#1367) 17708f5 - Fix toggle test (pytorch/kineto#1369) ee2103c - Link to correct fmt repo (pytorch/kineto#1345) 3447834 - Fix data race on CuptiActivityApi::externalCorrelationEnabled_ (pytorch/kineto#1365) 0e86499 - Stop allocating CUPTI buffers after exceeding max buffer count (pytorch/kineto#1362) 666f62c - Add XPU workflow (pytorch/kineto#1302) 11cc1e0 - Remove RocprofActivity.h/RoctracerActivity.h from RocmActivityProfiler.h (pytorch/kineto#1357) 896068d - Split ActivityProfilerController into Sync and Async Handlers (pytorch/kineto#1269) 6d7f045 - Add priority field to kernel metadata (pytorch/kineto#1361) f2a7423 - Add kineto-release skill (pytorch/kineto#1360) 675b6cd Authored with Claude. Pull Request resolved: #180606 Approved by: https://github.com/ryanzhang22, https://github.com/Skylion007
pytorchmergebot
pushed a commit
to pytorch/pytorch
that referenced
this pull request
May 2, 2026
If Kineto, in the C++ layer, hit errors that caused the Kineto side to exit profiling early, the PyTorch side in Python never learned of this. In particular, the `torch.profiler.schedule` object would still step through its entire schedule, never having learned that Kineto tried to exit early. This is particularly bad if Kineto wanted to exit early during warmup, and the schedule still tries to go through more warmup and then a bunch of active phases. This PR checks the newly exposed (pytorch/kineto#1367) `isStopped()` API in Kineto during the `torch.profiler.schedule` state transitions. If it has been stopped, we enter a new schedule state: `DEVICE_STOPPED`. Earlier implementations avoided adding a new state to the scheduling state machine, but they ran into the problem that the intended profiling behavior would no longer line up with the schedule the user specified. That is, we tried effectively fast-forwarding to `NONE` or `RECORD_AND_SAVE`. But if the user has a repeating schedule, we'd actually then end up with _more_ profiling. Now, if `torch.autogra._is_kineto_stopped()` is true, we'll enter the state `DEVICE_STOPPED`. Transitioning _into_ `DEVICE_STOPPED` shuts down profiling. We stay in that state until the schedule would ordinarily go into either `NONE` or `WARMUP`. This behavior ensures: * Users get a partial trace--which is particularly useful since there was enough of a problem during tracing to shut it down. * Their specified schedule behaves as requested. * We still appropriately shut down profiling when Kineto has told us cannot continue. Pull Request resolved: #180698 Approved by: https://github.com/ryanzhang22
Alokksinha00
pushed a commit
to Alokksinha00/pytorch
that referenced
this pull request
May 15, 2026
If Kineto, in the C++ layer, hit errors that caused the Kineto side to exit profiling early, the PyTorch side in Python never learned of this. In particular, the `torch.profiler.schedule` object would still step through its entire schedule, never having learned that Kineto tried to exit early. This is particularly bad if Kineto wanted to exit early during warmup, and the schedule still tries to go through more warmup and then a bunch of active phases. This PR checks the newly exposed (pytorch/kineto#1367) `isStopped()` API in Kineto during the `torch.profiler.schedule` state transitions. If it has been stopped, we enter a new schedule state: `DEVICE_STOPPED`. Earlier implementations avoided adding a new state to the scheduling state machine, but they ran into the problem that the intended profiling behavior would no longer line up with the schedule the user specified. That is, we tried effectively fast-forwarding to `NONE` or `RECORD_AND_SAVE`. But if the user has a repeating schedule, we'd actually then end up with _more_ profiling. Now, if `torch.autogra._is_kineto_stopped()` is true, we'll enter the state `DEVICE_STOPPED`. Transitioning _into_ `DEVICE_STOPPED` shuts down profiling. We stay in that state until the schedule would ordinarily go into either `NONE` or `WARMUP`. This behavior ensures: * Users get a partial trace--which is particularly useful since there was enough of a problem during tracing to shut it down. * Their specified schedule behaves as requested. * We still appropriately shut down profiling when Kineto has told us cannot continue. Pull Request resolved: pytorch#180698 Approved by: https://github.com/ryanzhang22
aperson30
pushed a commit
to aperson30/pytorch
that referenced
this pull request
Jun 20, 2026
Includes the following commits: - Fix stream wait events referencing future correlation IDs (pytorch/kineto#1339) 23b5bb5 - Remove kineto tb_plugin directory entirely (pytorch/kineto#1368) 9497960 - Move Stream Sync events to a new row in JSON trace export (pytorch/kineto#1356) 041e7ce - Expose isGpuCollectionStopped() through Kineto's public API (pytorch/kineto#1367) 17708f5 - Fix toggle test (pytorch/kineto#1369) ee2103c - Link to correct fmt repo (pytorch/kineto#1345) 3447834 - Fix data race on CuptiActivityApi::externalCorrelationEnabled_ (pytorch/kineto#1365) 0e86499 - Stop allocating CUPTI buffers after exceeding max buffer count (pytorch/kineto#1362) 666f62c - Add XPU workflow (pytorch/kineto#1302) 11cc1e0 - Remove RocprofActivity.h/RoctracerActivity.h from RocmActivityProfiler.h (pytorch/kineto#1357) 896068d - Split ActivityProfilerController into Sync and Async Handlers (pytorch/kineto#1269) 6d7f045 - Add priority field to kernel metadata (pytorch/kineto#1361) f2a7423 - Add kineto-release skill (pytorch/kineto#1360) 675b6cd Authored with Claude. Pull Request resolved: pytorch#180606 Approved by: https://github.com/ryanzhang22, https://github.com/Skylion007
aperson30
pushed a commit
to aperson30/pytorch
that referenced
this pull request
Jun 20, 2026
If Kineto, in the C++ layer, hit errors that caused the Kineto side to exit profiling early, the PyTorch side in Python never learned of this. In particular, the `torch.profiler.schedule` object would still step through its entire schedule, never having learned that Kineto tried to exit early. This is particularly bad if Kineto wanted to exit early during warmup, and the schedule still tries to go through more warmup and then a bunch of active phases. This PR checks the newly exposed (pytorch/kineto#1367) `isStopped()` API in Kineto during the `torch.profiler.schedule` state transitions. If it has been stopped, we enter a new schedule state: `DEVICE_STOPPED`. Earlier implementations avoided adding a new state to the scheduling state machine, but they ran into the problem that the intended profiling behavior would no longer line up with the schedule the user specified. That is, we tried effectively fast-forwarding to `NONE` or `RECORD_AND_SAVE`. But if the user has a repeating schedule, we'd actually then end up with _more_ profiling. Now, if `torch.autogra._is_kineto_stopped()` is true, we'll enter the state `DEVICE_STOPPED`. Transitioning _into_ `DEVICE_STOPPED` shuts down profiling. We stay in that state until the schedule would ordinarily go into either `NONE` or `WARMUP`. This behavior ensures: * Users get a partial trace--which is particularly useful since there was enough of a problem during tracing to shut it down. * Their specified schedule behaves as requested. * We still appropriately shut down profiling when Kineto has told us cannot continue. Pull Request resolved: pytorch#180698 Approved by: https://github.com/ryanzhang22
gplutop7
pushed a commit
to gplutop7/pytorch
that referenced
this pull request
Jul 15, 2026
Includes the following commits: - Fix stream wait events referencing future correlation IDs (pytorch/kineto#1339) 23b5bb5 - Remove kineto tb_plugin directory entirely (pytorch/kineto#1368) 9497960 - Move Stream Sync events to a new row in JSON trace export (pytorch/kineto#1356) 041e7ce - Expose isGpuCollectionStopped() through Kineto's public API (pytorch/kineto#1367) 17708f5 - Fix toggle test (pytorch/kineto#1369) ee2103c - Link to correct fmt repo (pytorch/kineto#1345) 3447834 - Fix data race on CuptiActivityApi::externalCorrelationEnabled_ (pytorch/kineto#1365) 0e86499 - Stop allocating CUPTI buffers after exceeding max buffer count (pytorch/kineto#1362) 666f62c - Add XPU workflow (pytorch/kineto#1302) 11cc1e0 - Remove RocprofActivity.h/RoctracerActivity.h from RocmActivityProfiler.h (pytorch/kineto#1357) 896068d - Split ActivityProfilerController into Sync and Async Handlers (pytorch/kineto#1269) 6d7f045 - Add priority field to kernel metadata (pytorch/kineto#1361) f2a7423 - Add kineto-release skill (pytorch/kineto#1360) 675b6cd Authored with Claude. Pull Request resolved: pytorch#180606 Approved by: https://github.com/ryanzhang22, https://github.com/Skylion007
gplutop7
pushed a commit
to gplutop7/pytorch
that referenced
this pull request
Jul 15, 2026
If Kineto, in the C++ layer, hit errors that caused the Kineto side to exit profiling early, the PyTorch side in Python never learned of this. In particular, the `torch.profiler.schedule` object would still step through its entire schedule, never having learned that Kineto tried to exit early. This is particularly bad if Kineto wanted to exit early during warmup, and the schedule still tries to go through more warmup and then a bunch of active phases. This PR checks the newly exposed (pytorch/kineto#1367) `isStopped()` API in Kineto during the `torch.profiler.schedule` state transitions. If it has been stopped, we enter a new schedule state: `DEVICE_STOPPED`. Earlier implementations avoided adding a new state to the scheduling state machine, but they ran into the problem that the intended profiling behavior would no longer line up with the schedule the user specified. That is, we tried effectively fast-forwarding to `NONE` or `RECORD_AND_SAVE`. But if the user has a repeating schedule, we'd actually then end up with _more_ profiling. Now, if `torch.autogra._is_kineto_stopped()` is true, we'll enter the state `DEVICE_STOPPED`. Transitioning _into_ `DEVICE_STOPPED` shuts down profiling. We stay in that state until the schedule would ordinarily go into either `NONE` or `WARMUP`. This behavior ensures: * Users get a partial trace--which is particularly useful since there was enough of a problem during tracing to shut it down. * Their specified schedule behaves as requested. * We still appropriately shut down profiling when Kineto has told us cannot continue. Pull Request resolved: pytorch#180698 Approved by: https://github.com/ryanzhang22
aws-kingrj
pushed a commit
to amazon-contributing/upstream-to-pytorch
that referenced
this pull request
Jul 29, 2026
Includes the following commits: - Fix stream wait events referencing future correlation IDs (pytorch/kineto#1339) 23b5bb5 - Remove kineto tb_plugin directory entirely (pytorch/kineto#1368) 9497960 - Move Stream Sync events to a new row in JSON trace export (pytorch/kineto#1356) 041e7ce - Expose isGpuCollectionStopped() through Kineto's public API (pytorch/kineto#1367) 17708f5 - Fix toggle test (pytorch/kineto#1369) ee2103c - Link to correct fmt repo (pytorch/kineto#1345) 3447834 - Fix data race on CuptiActivityApi::externalCorrelationEnabled_ (pytorch/kineto#1365) 0e86499 - Stop allocating CUPTI buffers after exceeding max buffer count (pytorch/kineto#1362) 666f62c - Add XPU workflow (pytorch/kineto#1302) 11cc1e0 - Remove RocprofActivity.h/RoctracerActivity.h from RocmActivityProfiler.h (pytorch/kineto#1357) 896068d - Split ActivityProfilerController into Sync and Async Handlers (pytorch/kineto#1269) 6d7f045 - Add priority field to kernel metadata (pytorch/kineto#1361) f2a7423 - Add kineto-release skill (pytorch/kineto#1360) 675b6cd Authored with Claude. Pull Request resolved: pytorch#180606 Approved by: https://github.com/ryanzhang22, https://github.com/Skylion007
aws-kingrj
pushed a commit
to amazon-contributing/upstream-to-pytorch
that referenced
this pull request
Jul 29, 2026
If Kineto, in the C++ layer, hit errors that caused the Kineto side to exit profiling early, the PyTorch side in Python never learned of this. In particular, the `torch.profiler.schedule` object would still step through its entire schedule, never having learned that Kineto tried to exit early. This is particularly bad if Kineto wanted to exit early during warmup, and the schedule still tries to go through more warmup and then a bunch of active phases. This PR checks the newly exposed (pytorch/kineto#1367) `isStopped()` API in Kineto during the `torch.profiler.schedule` state transitions. If it has been stopped, we enter a new schedule state: `DEVICE_STOPPED`. Earlier implementations avoided adding a new state to the scheduling state machine, but they ran into the problem that the intended profiling behavior would no longer line up with the schedule the user specified. That is, we tried effectively fast-forwarding to `NONE` or `RECORD_AND_SAVE`. But if the user has a repeating schedule, we'd actually then end up with _more_ profiling. Now, if `torch.autogra._is_kineto_stopped()` is true, we'll enter the state `DEVICE_STOPPED`. Transitioning _into_ `DEVICE_STOPPED` shuts down profiling. We stay in that state until the schedule would ordinarily go into either `NONE` or `WARMUP`. This behavior ensures: * Users get a partial trace--which is particularly useful since there was enough of a problem during tracing to shut it down. * Their specified schedule behaves as requested. * We still appropriately shut down profiling when Kineto has told us cannot continue. Pull Request resolved: pytorch#180698 Approved by: https://github.com/ryanzhang22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
When the sync profiling path is active and we've reached our limit of CUPTI activity buffers,
CuptiActivityApi::bufferRequested()setsstopCollection = true. The async path already checks this viaisGpuCollectionStopped()inperformRunLoopStep(), but the sync path has no way to query it — the method is protected onGenericActivityProfilerand not exposed through the publicActivityProfilerInterface.This diff plumbs this status up through to the public interface.
A follow-up change in PyTorch will use this API in the Python profiler's
step()method to detect that the profiling had to stop early and force an earlystop_trace.We've already fixed it so that when there's too many activity buffers, CUPTI should stop requesting buffers (D100731798 / #1362). But we still don't have a way to tell the Python layer that profiling should stop in synchronous tracing.
Differential Revision: D101044411