Ship the profiler as its own library so a C++ app can use it - #21591
Open
shoumikhin wants to merge 3 commits into
Open
Ship the profiler as its own library so a C++ app can use it#21591shoumikhin wants to merge 3 commits into
shoumikhin wants to merge 3 commits into
Conversation
Contributor
Author
shoumikhin
requested review from
digantdesai,
kirklandsign,
larryliu0820 and
mergennachin
as code owners
August 5, 2026 16:29
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/21591
Note: Links to docs will display an error until the docs builds have been completed. ❌ 194 New Failures, 4 Cancelled Jobs, 21 Pending, 1 Unrelated Failure, 10 Unclassified FailuresAs of commit c8bcddf with merge base efd6b55 ( NEW FAILURES - The following jobs have failed:
UNCLASSIFIED FAILURES - DrCI could not classify the following jobs because the workflow did not run on the merge base. The failures may be pre-existing on trunk or introduced by this PR:
CANCELLED JOBS - The following jobs were cancelled. Please retry:
FLAKY - The following job failed but was likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This was referenced Aug 5, 2026
shoumikhin
changed the base branch from
gh/shoumikhin/80/head
to
gh/shoumikhin/90/head
August 5, 2026 18:42
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
ExecuTorch can record timing and tracing data while a model runs. That
profiler is useful for finding out which operator is slow, and today it is
reachable only from Python: its code is compiled into the Python extension,
and the wheel ships none of its headers. A C++ application has nothing to
link and nothing to include, so it cannot profile a model at all unless it
builds ExecuTorch from source.
This builds the profiler as its own shared library and ships it, the same
way the runtime, the thread pool and the CPU kernels are already shipped:
Then an application constructs a tracer, hands it to the module, runs a
method, and reads the trace back:
One detail worth explaining. The profiler's implementation uses a flatbuffer
runtime that the wheel does not ship, and that dependency used to be public,
which would make the shipped header impossible to link against. It is now
private, so it stays inside the library. The public header includes only
runtime headers, which is what makes shipping it possible.
Before this change the Python extension defined the profiler's symbols
itself. Now it imports them from the shared library, so a process has one
profiler rather than one per component that uses it, matching the thread
pool.
Tested by building the wheel and inspecting it: the profiler ships as a
versioned library, its seven public headers ship, the Python extension no
longer defines any of its symbols and links the library instead, and the
public header compiles against the installed package.