Skip to content

fix(perf): support multiple QNN EP context partitions - #1361

Open
xieofxie wants to merge 5 commits into
mainfrom
hualxie_copilot/c7e8e42e3bab41b0b091f4b02e2ab40c
Open

fix(perf): support multiple QNN EP context partitions#1361
xieofxie wants to merge 5 commits into
mainfrom
hualxie_copilot/c7e8e42e3bab41b0b091f4b02e2ab40c

Conversation

@xieofxie

Copy link
Copy Markdown
Contributor

Summary

  • coalesce QNN profiling blocks emitted per EP-context partition into inference samples
  • preserve partition-local operator IDs and timing conversion
  • infer runtime partition counts when raw model metadata does not expose EPContext nodes
  • add regression coverage for metadata-backed and runtime-inferred multi-partition traces

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@xieofxie
xieofxie requested a review from a team as a code owner August 26, 2026 08:29
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@xieofxie

Copy link
Copy Markdown
Contributor Author

a follow up #1362

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread src/winml/modelkit/commands/perf.py
Comment thread src/winml/modelkit/commands/perf.py Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found two actionable regressions in this change.

"hvx_threads": max(
sample["metadata"]["hvx_threads"] for sample in partition_samples
),
"accel_execute_cycles": sum(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we normalize each partition's metadata before aggregating it? _parse_artifacts() explicitly accepts QNN numeric values such as "120000.7" via _to_int(), but this new sum() runs first. With multiple partitions, summing those strings raises TypeError, the monitor reports parse_failed, and winml perf --op-tracing exits 4. A regression test combining multiple partitions with float-string metadata would catch this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. QNN metadata normalization is now shared by partition coalescing and downstream conversion, including float-string values. Added a multi-partition float-string regression test.

trace_data = json.loads(trace_files[0].read_text(encoding="utf-8"))
report_data = json.loads(output_path.read_text(encoding="utf-8"))
trace_data = report_data["hw_monitor"]["ep_proof"]
assert not list(tmp_path.glob("*_op_trace.json"))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This behavior change also leaves tests/e2e/test_perf_e2e.py::TestPerfOnnx::test_op_tracing_basic_qnn_npu expecting and reading perf_op_tracing_qnn_npu_op_trace.json (lines 805/823). Since perf.py no longer writes that artifact, the QNN hardware E2E now fails. Please update that E2E to read output_file["hw_monitor"]["ep_proof"] and assert the standalone trace file is absent, as this test does.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the existing QNN NPU E2E to read hw_monitor.ep_proof from the main perf JSON and assert the standalone _op_trace.json is absent. The enabled hardware E2E passes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants