refactor(optracing): per-sample QNN CSV parsing with warmup skip and clean output#1006
Open
xieofxie wants to merge 5 commits into
Open
refactor(optracing): per-sample QNN CSV parsing with warmup skip and clean output#1006xieofxie wants to merge 5 commits into
xieofxie wants to merge 5 commits into
Conversation
added 5 commits
June 30, 2026 16:23
Each inference sample now carries its own ROOT metadata (HVX threads,
accelerator execute cycles/US) instead of a single first-occurrence
snapshot. result[samples] is now a list of {metadata, samples} records.
Extract OperatorMetrics construction in the profiler into a standalone
_csv_operator_metrics helper.
parse_qnn_profiling_csv now returns [{metadata, samples}] directly, one
entry per inference sample with its own ROOT metadata. Operator
aggregation moves into the profiler's _csv_operator_metrics helper, which
computes each op's duration/percent against its own sample's metadata
(cycle->US factor differs per inference) before averaging across samples.
test_basic_pipeline_csv_to_json now compares the full CSV->JSON output against a code-generated fixture (basic_pipeline_expected.json) with a pinned timestamp, instead of asserting only shape.
OperatorMetrics.to_dict() now drops unset (None) fields. Basic-mode traces only populate identity + timing, so the output no longer carries the many detail-only fields (DMA/VTCM/roofline) as null. Regenerated the golden fixture and updated tests that asserted null presence.
Thread warmup through run -> _collect_results -> _from_csv. The QNN CSV records every execute call (warmup included); _from_csv now drops the first warmup samples, asserts the remaining count equals iterations, and builds metrics only from those measured samples.
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.
Summary
Reworks the QNN basic-mode op-tracing CSV pipeline so metadata is tracked per inference sample, durations are computed correctly, and the JSON output is clean.
parse_qnn_profiling_csvnow returns a list of{"metadata": {...}, "samples": [...]}— one entry per inference, each carrying its own ROOT metadata (HVX threads, accelerator execute cycles/US) instead of a single first-occurrence snapshot. Samples are delimited by the"Number of HVX threads used"marker that begins each inference._csv_operator_metricshelper, which computes each operator'sduration_us/percent_of_totalagainst the metadata of the same sample (the cycle→US factor differs slightly per inference) before averaging across samples.warmupis threaded throughrun → _collect_results → _from_csv. The CSV records every execute call (warmup included), so_from_csvdrops the firstwarmupsamples, asserts the remainder equalsiterations, and builds metrics only from the measured samples.OperatorMetrics.to_dict()now omits unset (None) fields, so basic-mode traces no longer serialize the many detail-only fields (DMA/VTCM/roofline) asnull.Tests
test_basic_pipeline_csv_to_jsonnow validates the full CSV→JSON output against a code-generated golden fixture (basic_pipeline_expected.json) with a pinned timestamp.uv run pytest tests/unit/optracing/— 98 passed.