This repository was archived by the owner on Sep 30, 2026. It is now read-only.
Repository navigation
Move state machine from profiler into async handler (#1352) - #1352
Closed
ryanzhang22 wants to merge 1 commit into
Closed
ryanzhang22 wants to merge 1 commit into
ryanzhang22 wants to merge 1 commit into
Conversation
|
@ryanzhang22 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D93475197. |
ryanzhang22
added a commit
to ryanzhang22/kineto
that referenced
this pull request
Apr 9, 2026
Summary: Part 2 of a refactor to improve safety and readability around sync/async profiling. Sync profiling currently only uses the profiler state machine to check whether `isActive()` is true. However that doesn't tell us if sync or async is the one that actually owns the profiler at that point, which can lead to edge cases when we make decisions about whether or not to proceed based on the profiler state. See the example below. Since the state machine behavior is only relevant for async tracing, we move the related functions from the `GenericActivityProfiler` into the Async handler. The `GenericActivityProfiler` just becomes a set of functions used to drive profiling, without needing to worry about transitions. Each handler owns their own `isActive()` state, and `ActivityProfilerController` makes decisions about how to handle scheduling between sync and async. In particular, we add a `cancel()` function both handlers so the controller can make sure both handlers are in a good state before preempting. For the async trace, `cancel()` will also clear the async config and move the state back to `WaitForRequest`. This change makes ownership explicit, which should hopefully make reasoning about preemptions from the controller perspective easier. Differential Revision: D93475197
ryanzhang22
added a commit
to ryanzhang22/kineto
that referenced
this pull request
Jun 4, 2026
Summary: Part 2 of a refactor to improve safety and readability around sync/async profiling. Sync profiling currently only uses the profiler state machine to check whether `isActive()` is true. However that doesn't tell us if sync or async is the one that actually owns the profiler at that point, which can lead to edge cases when we make decisions about whether or not to proceed based on the profiler state. Since the state machine behavior is only relevant for async tracing, we move the related functions from the `GenericActivityProfiler` into the Async handler. The `GenericActivityProfiler` just becomes a set of functions used to drive profiling, without needing to worry about transitions. Each handler owns their own `isActive()` state, and `ActivityProfilerController` makes decisions about how to handle scheduling between sync and async. In particular, we add a `cancel()` function both handlers so the controller can make sure both handlers are in a good state before preempting. For the async trace, `cancel()` will also clear the async config and move the state back to `WaitForRequest`. This change makes ownership explicit, which should hopefully make reasoning about preemptions from the controller perspective easier. Differential Revision: D93475197
ryanzhang22
force-pushed
the
export-D93475197
branch
from
June 4, 2026 13:02
27c0a1e to
3a0046a
Compare
ryanzhang22
added a commit
to ryanzhang22/kineto
that referenced
this pull request
Jun 4, 2026
Summary: Part 2 of a refactor to improve safety and readability around sync/async profiling. Sync profiling currently only uses the profiler state machine to check whether `isActive()` is true. However that doesn't tell us if sync or async is the one that actually owns the profiler at that point, which can lead to edge cases when we make decisions about whether or not to proceed based on the profiler state. Since the state machine behavior is only relevant for async tracing, we move the related functions from the `GenericActivityProfiler` into the Async handler. The `GenericActivityProfiler` just becomes a set of functions used to drive profiling, without needing to worry about transitions. Each handler owns their own `isActive()` state, and `ActivityProfilerController` makes decisions about how to handle scheduling between sync and async. In particular, we add a `cancel()` function both handlers so the controller can make sure both handlers are in a good state before preempting. For the async trace, `cancel()` will also clear the async config and move the state back to `WaitForRequest`. This change makes ownership explicit, which should hopefully make reasoning about preemptions from the controller perspective easier. Differential Revision: D93475197
ryanzhang22
force-pushed
the
export-D93475197
branch
from
June 4, 2026 17:20
3a0046a to
5b94454
Compare
ryanzhang22
added a commit
to ryanzhang22/kineto
that referenced
this pull request
Jun 8, 2026
Summary: Part 2 of a refactor to improve safety and readability around sync/async profiling. Sync profiling currently only uses the profiler state machine to check whether `isActive()` is true. However that doesn't tell us if sync or async is the one that actually owns the profiler at that point, which can lead to edge cases when we make decisions about whether or not to proceed based on the profiler state. Since the state machine behavior is only relevant for async tracing, we move the related functions from the `GenericActivityProfiler` into the Async handler. The `GenericActivityProfiler` just becomes a set of functions used to drive profiling, without needing to worry about transitions. Each handler owns their own `isActive()` state, and `ActivityProfilerController` makes decisions about how to handle scheduling between sync and async. In particular, we add a `cancel()` function both handlers so the controller can make sure both handlers are in a good state before preempting. For the async trace, `cancel()` will also clear the async config and move the state back to `WaitForRequest`. This change makes ownership explicit, which should hopefully make reasoning about preemptions from the controller perspective easier. Reviewed By: scotts Differential Revision: D93475197
ryanzhang22
force-pushed
the
export-D93475197
branch
from
June 8, 2026 14:12
5b94454 to
f96d3ac
Compare
ryanzhang22
added a commit
to ryanzhang22/kineto
that referenced
this pull request
Jun 8, 2026
Summary: Part 2 of a refactor to improve safety and readability around sync/async profiling. Sync profiling currently only uses the profiler state machine to check whether `isActive()` is true. However that doesn't tell us if sync or async is the one that actually owns the profiler at that point, which can lead to edge cases when we make decisions about whether or not to proceed based on the profiler state. Since the state machine behavior is only relevant for async tracing, we move the related functions from the `GenericActivityProfiler` into the Async handler. The `GenericActivityProfiler` just becomes a set of functions used to drive profiling, without needing to worry about transitions. Each handler owns their own `isActive()` state, and `ActivityProfilerController` makes decisions about how to handle scheduling between sync and async. In particular, we add a `cancel()` function both handlers so the controller can make sure both handlers are in a good state before preempting. For the async trace, `cancel()` will also clear the async config and move the state back to `WaitForRequest`. This change makes ownership explicit, which should hopefully make reasoning about preemptions from the controller perspective easier. Reviewed By: scotts Differential Revision: D93475197
ryanzhang22
added a commit
to ryanzhang22/kineto
that referenced
this pull request
Jun 9, 2026
Summary: Part 2 of a refactor to improve safety and readability around sync/async profiling. Sync profiling currently only uses the profiler state machine to check whether `isActive()` is true. However that doesn't tell us if sync or async is the one that actually owns the profiler at that point, which can lead to edge cases when we make decisions about whether or not to proceed based on the profiler state. Since the state machine behavior is only relevant for async tracing, we move the related functions from the `GenericActivityProfiler` into the Async handler. The `GenericActivityProfiler` just becomes a set of functions used to drive profiling, without needing to worry about transitions. Each handler owns their own `isActive()` state, and `ActivityProfilerController` makes decisions about how to handle scheduling between sync and async. In particular, we add a `cancel()` function both handlers so the controller can make sure both handlers are in a good state before preempting. For the async trace, `cancel()` will also clear the async config and move the state back to `WaitForRequest`. This change makes ownership explicit, which should hopefully make reasoning about preemptions from the controller perspective easier. Reviewed By: scotts Differential Revision: D93475197
ryanzhang22
force-pushed
the
export-D93475197
branch
from
June 9, 2026 13:48
f96d3ac to
59c8e1c
Compare
ryanzhang22
added a commit
to ryanzhang22/kineto
that referenced
this pull request
Jun 9, 2026
Summary: Part 2 of a refactor to improve safety and readability around sync/async profiling. Sync profiling currently only uses the profiler state machine to check whether `isActive()` is true. However that doesn't tell us if sync or async is the one that actually owns the profiler at that point, which can lead to edge cases when we make decisions about whether or not to proceed based on the profiler state. Since the state machine behavior is only relevant for async tracing, we move the related functions from the `GenericActivityProfiler` into the Async handler. The `GenericActivityProfiler` just becomes a set of functions used to drive profiling, without needing to worry about transitions. Each handler owns their own `isActive()` state, and `ActivityProfilerController` makes decisions about how to handle scheduling between sync and async. In particular, we add a `cancel()` function both handlers so the controller can make sure both handlers are in a good state before preempting. For the async trace, `cancel()` will also clear the async config and move the state back to `WaitForRequest`. This change makes ownership explicit, which should hopefully make reasoning about preemptions from the controller perspective easier. Reviewed By: scotts Differential Revision: D93475197
ryanzhang22
added a commit
to ryanzhang22/kineto
that referenced
this pull request
Jun 10, 2026
Summary: Part 2 of a refactor to improve safety and readability around sync/async profiling. Sync profiling currently only uses the profiler state machine to check whether `isActive()` is true. However that doesn't tell us if sync or async is the one that actually owns the profiler at that point, which can lead to edge cases when we make decisions about whether or not to proceed based on the profiler state. Since the state machine behavior is only relevant for async tracing, we move the related functions from the `GenericActivityProfiler` into the Async handler. The `GenericActivityProfiler` just becomes a set of functions used to drive profiling, without needing to worry about transitions. Each handler owns their own `isActive()` state, and `ActivityProfilerController` makes decisions about how to handle scheduling between sync and async. In particular, we add a `cancel()` function both handlers so the controller can make sure both handlers are in a good state before preempting. For the async trace, `cancel()` will also clear the async config and move the state back to `WaitForRequest`. This change makes ownership explicit, which should hopefully make reasoning about preemptions from the controller perspective easier. Reviewed By: scotts Differential Revision: D93475197
ryanzhang22
added a commit
to ryanzhang22/kineto
that referenced
this pull request
Jun 10, 2026
Summary: Part 2 of a refactor to improve safety and readability around sync/async profiling. Sync profiling currently only uses the profiler state machine to check whether `isActive()` is true. However that doesn't tell us if sync or async is the one that actually owns the profiler at that point, which can lead to edge cases when we make decisions about whether or not to proceed based on the profiler state. Since the state machine behavior is only relevant for async tracing, we move the related functions from the `GenericActivityProfiler` into the Async handler. The `GenericActivityProfiler` just becomes a set of functions used to drive profiling, without needing to worry about transitions. Each handler owns their own `isActive()` state, and `ActivityProfilerController` makes decisions about how to handle scheduling between sync and async. In particular, we add a `cancel()` function both handlers so the controller can make sure both handlers are in a good state before preempting. For the async trace, `cancel()` will also clear the async config and move the state back to `WaitForRequest`. This change makes ownership explicit, which should hopefully make reasoning about preemptions from the controller perspective easier. Reviewed By: scotts Differential Revision: D93475197
ryanzhang22
added a commit
to ryanzhang22/kineto
that referenced
this pull request
Jun 10, 2026
Summary: Part 2 of a refactor to improve safety and readability around sync/async profiling. Sync profiling currently only uses the profiler state machine to check whether `isActive()` is true. However that doesn't tell us if sync or async is the one that actually owns the profiler at that point, which can lead to edge cases when we make decisions about whether or not to proceed based on the profiler state. Since the state machine behavior is only relevant for async tracing, we move the related functions from the `GenericActivityProfiler` into the Async handler. The `GenericActivityProfiler` just becomes a set of functions used to drive profiling, without needing to worry about transitions. Each handler owns their own `isActive()` state, and `ActivityProfilerController` makes decisions about how to handle scheduling between sync and async. In particular, we add a `cancel()` function both handlers so the controller can make sure both handlers are in a good state before preempting. For the async trace, `cancel()` will also clear the async config and move the state back to `WaitForRequest`. This change makes ownership explicit, which should hopefully make reasoning about preemptions from the controller perspective easier. Reviewed By: scotts Differential Revision: D93475197
ryanzhang22
force-pushed
the
export-D93475197
branch
from
June 10, 2026 13:05
59c8e1c to
0766feb
Compare
Summary: Part 2 of a refactor to improve safety and readability around sync/async profiling. Sync profiling currently only uses the profiler state machine to check whether `isActive()` is true. However that doesn't tell us if sync or async is the one that actually owns the profiler at that point, which can lead to edge cases when we make decisions about whether or not to proceed based on the profiler state. Since the state machine behavior is only relevant for async tracing, we move the related functions from the `GenericActivityProfiler` into the Async handler. The `GenericActivityProfiler` just becomes a set of functions used to drive profiling, without needing to worry about transitions. Each handler owns their own `isActive()` state, and `ActivityProfilerController` makes decisions about how to handle scheduling between sync and async. In particular, we add a `cancel()` function both handlers so the controller can make sure both handlers are in a good state before preempting. For the async trace, `cancel()` will also clear the async config and move the state back to `WaitForRequest`. This change makes ownership explicit, which should hopefully make reasoning about preemptions from the controller perspective easier. Reviewed By: scotts Differential Revision: D93475197
ryanzhang22
force-pushed
the
export-D93475197
branch
from
June 10, 2026 13:06
0766feb to
30ff76b
Compare
|
This pull request has been merged in eb578c5. |
scotts
added a commit
to scotts/pytorch
that referenced
this pull request
Jun 16, 2026
Includes the following commits: - surface HSA queue ID (pytorch/kineto#1425) 1d43601 - Add TypedMetadata to CUPTI activities (pytorch/kineto#1434) 461a26c - Move around methods so they are accurately described by the comments (pytorch/kineto#1435) ff95265 - Introduce TypedMetadata structs (pytorch/kineto#1433) 965a14d - Add unit tests for sync/async interleaving behavior (pytorch/kineto#1431) 67612e6 - Restrict on-demand trace output path to a safe directory (pytorch/kineto#1426) 9ea826e - Add a cancellation state to the state machine and remove syncTraceActive_ (pytorch/kineto#1355) 3289139 - Move state machine from profiler into async handler (pytorch/kineto#1352) eb578c5 - map kernel and copy events to logical stream ID instead of HSA queue ID (pytorch/kineto#1424) 25856f7 - Speedup and fix PyTorch CI build (pytorch/kineto#1428) e675bbb - Add logging for async rejections (pytorch/kineto#1422) 14becfb - Make sure we clear the logger observer before starting a new session (pytorch/kineto#1387) a8cae92 - Add a scope guard for logging to help us capture all exit paths (pytorch/kineto#1383) ce13b13 - Remove roctracer support (pytorch/kineto#1419) 2a3a002
pytorchmergebot
pushed a commit
to pytorch/pytorch
that referenced
this pull request
Jun 16, 2026
Includes the following commits: - surface HSA queue ID (pytorch/kineto#1425) 1d43601 - Add TypedMetadata to CUPTI activities (pytorch/kineto#1434) 461a26c - Move around methods so they are accurately described by the comments (pytorch/kineto#1435) ff95265 - Introduce TypedMetadata structs (pytorch/kineto#1433) 965a14d - Add unit tests for sync/async interleaving behavior (pytorch/kineto#1431) 67612e6 - Restrict on-demand trace output path to a safe directory (pytorch/kineto#1426) 9ea826e - Add a cancellation state to the state machine and remove syncTraceActive_ (pytorch/kineto#1355) 3289139 - Move state machine from profiler into async handler (pytorch/kineto#1352) eb578c5 - map kernel and copy events to logical stream ID instead of HSA queue ID (pytorch/kineto#1424) 25856f7 - Speedup and fix PyTorch CI build (pytorch/kineto#1428) e675bbb - Add logging for async rejections (pytorch/kineto#1422) 14becfb - Make sure we clear the logger observer before starting a new session (pytorch/kineto#1387) a8cae92 - Add a scope guard for logging to help us capture all exit paths (pytorch/kineto#1383) ce13b13 - Remove roctracer support (pytorch/kineto#1419) 2a3a002 Pull Request resolved: #187440 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
Includes the following commits: - surface HSA queue ID (pytorch/kineto#1425) 1d43601 - Add TypedMetadata to CUPTI activities (pytorch/kineto#1434) 461a26c - Move around methods so they are accurately described by the comments (pytorch/kineto#1435) ff95265 - Introduce TypedMetadata structs (pytorch/kineto#1433) 965a14d - Add unit tests for sync/async interleaving behavior (pytorch/kineto#1431) 67612e6 - Restrict on-demand trace output path to a safe directory (pytorch/kineto#1426) 9ea826e - Add a cancellation state to the state machine and remove syncTraceActive_ (pytorch/kineto#1355) 3289139 - Move state machine from profiler into async handler (pytorch/kineto#1352) eb578c5 - map kernel and copy events to logical stream ID instead of HSA queue ID (pytorch/kineto#1424) 25856f7 - Speedup and fix PyTorch CI build (pytorch/kineto#1428) e675bbb - Add logging for async rejections (pytorch/kineto#1422) 14becfb - Make sure we clear the logger observer before starting a new session (pytorch/kineto#1387) a8cae92 - Add a scope guard for logging to help us capture all exit paths (pytorch/kineto#1383) ce13b13 - Remove roctracer support (pytorch/kineto#1419) 2a3a002 Pull Request resolved: pytorch#187440 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
Includes the following commits: - surface HSA queue ID (pytorch/kineto#1425) 1d43601 - Add TypedMetadata to CUPTI activities (pytorch/kineto#1434) 461a26c - Move around methods so they are accurately described by the comments (pytorch/kineto#1435) ff95265 - Introduce TypedMetadata structs (pytorch/kineto#1433) 965a14d - Add unit tests for sync/async interleaving behavior (pytorch/kineto#1431) 67612e6 - Restrict on-demand trace output path to a safe directory (pytorch/kineto#1426) 9ea826e - Add a cancellation state to the state machine and remove syncTraceActive_ (pytorch/kineto#1355) 3289139 - Move state machine from profiler into async handler (pytorch/kineto#1352) eb578c5 - map kernel and copy events to logical stream ID instead of HSA queue ID (pytorch/kineto#1424) 25856f7 - Speedup and fix PyTorch CI build (pytorch/kineto#1428) e675bbb - Add logging for async rejections (pytorch/kineto#1422) 14becfb - Make sure we clear the logger observer before starting a new session (pytorch/kineto#1387) a8cae92 - Add a scope guard for logging to help us capture all exit paths (pytorch/kineto#1383) ce13b13 - Remove roctracer support (pytorch/kineto#1419) 2a3a002 Pull Request resolved: pytorch#187440 Approved by: https://github.com/ryanzhang22, https://github.com/Skylion007
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:
Part 2 of a refactor to improve safety and readability around sync/async profiling.
Sync profiling currently only uses the profiler state machine to check whether
isActive()is true. However that doesn't tell us if sync or async is the one that actually owns the profiler at that point, which can lead to edge cases when we make decisions about whether or not to proceed based on the profiler state.Since the state machine behavior is only relevant for async tracing, we move the related functions from the
GenericActivityProfilerinto the Async handler. TheGenericActivityProfilerjust becomes a set of functions used to drive profiling, without needing to worry about transitions. Each handler owns their ownisActive()state, andActivityProfilerControllermakes decisions about how to handle scheduling between sync and async. In particular, we add acancel()function both handlers so the controller can make sure both handlers are in a good state before preempting. For the async trace,cancel()will also clear the async config and move the state back toWaitForRequest.This change makes ownership explicit, which should hopefully make reasoning about preemptions from the controller perspective easier.
Reviewed By: scotts
Differential Revision: D93475197