hexagon: support for op-trace (fine-grain tracing of HVX/HMX/DMA events)#24592
Merged
Conversation
chraac
reviewed
Jun 14, 2026
2580fde to
e503953
Compare
e503953 to
cdc7664
Compare
Member
Author
|
@lhez @ggml-org/maintainers |
lhez
approved these changes
Jun 17, 2026
Member
Author
|
@ggml-org/maintainers can I get the second approval please (comments are welcome too of course). |
CISC
approved these changes
Jun 18, 2026
Comment on lines
+2201
to
+2203
| char evt_str[256] = ""; | ||
| if (opt_profile == 3) { | ||
| sprintf(evt_str, " evt [%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u]", |
Member
There was a problem hiding this comment.
Even though this is not likely to overflow it's common curtesy to use snprintf. :)
I see there are a few other sprintfs in hexagon already...
Member
Author
There was a problem hiding this comment.
Sounds good. Thanks for reviewing.
I'm going to merge but will follow up shortly. I have another big MUL_MAT update that is almost ready and it uses/extends this tracing stuff a bit so I'll just replace all sprintfs() in there.
papamoose
pushed a commit
to papamoose/llama.cpp
that referenced
this pull request
Jun 27, 2026
…ts) (ggml-org#24592) * hex-optrace: add support for optrace and instrument matmul and flash-atten code * hex-trace: improve trace event and prefetto generator * hex-trace: add new script dedicated to handling traces, specifically perfetto traces * hex-trace: add --head/--tail options to profile and trace tools * hex-trace: fix whitespaces * hex-trace: fix flake8 warnings * hex-trace: fix flake8 warnings * hmx-fa: restore q_tiles clearing * hex-profile: remove circular dep in includes * hex-trace: simplify trace sizing check * hex-profile: sort events in the summary by name
adrianhoehne
pushed a commit
to adrianhoehne/llama.cpp
that referenced
this pull request
Jul 5, 2026
…ts) (ggml-org#24592) * hex-optrace: add support for optrace and instrument matmul and flash-atten code * hex-trace: improve trace event and prefetto generator * hex-trace: add new script dedicated to handling traces, specifically perfetto traces * hex-trace: add --head/--tail options to profile and trace tools * hex-trace: fix whitespaces * hex-trace: fix flake8 warnings * hex-trace: fix flake8 warnings * hmx-fa: restore q_tiles clearing * hex-profile: remove circular dep in includes * hex-trace: simplify trace sizing check * hex-profile: sort events in the summary by name
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.
Overview
This PR introduces ggml-hexagon Op Trace.
Op Trace is basically a sequence of fine-grain events per HVX/HMX/DMA work/thread.
The NPU stores these events in a buffer provided by the host as part of the Op Batch request.
When the Op Batch response comes back the host dumps those events into the regular debug logging stream mixed with the existing Op Profile records.
The PR updates existing
scripts/snapdragon/ggml-hexagon-profile.pyscript to generate some new stats based on the traces, and adds newscripts/snapdragon/ggml-hexagon-trace.pythat generates Perfetto trace files for visualization.This PR requires #24490 in order to handle the increased logging load.
For now to make it usable I included the logging update here, will remove once the logging stuff goes in.
Usage examples
Details
Run a model with op-tracing:
PROF=3is a shorthand forGGML_HEXAGON_OPPROFILE=3which enables both general profiling and tracingHere is an example of the logging output
These logs can be post-processed with the included scripts
Use perfetto ui to load and display
llama3.2-3B-optrace.perfetto-trace.Requirements