-
Notifications
You must be signed in to change notification settings - Fork 12
fix(perf): support multiple QNN EP context partitions #1361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
52ee372
dfef05a
96f5148
f04493e
ddb2649
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -921,7 +921,6 @@ def _invoke_text_op_trace_failure(tmp_path: Path, trace_result): | |
| patch("winml.modelkit.commands.perf.display_console_report") as display_report, | ||
| patch("winml.modelkit.commands.perf.write_json_report") as write_json, | ||
| patch("winml.modelkit.session.monitor.report.display_op_trace_report") as display_trace, | ||
| patch("winml.modelkit.session.monitor.report.write_op_trace_json") as write_trace, | ||
| ): | ||
| result = runner.invoke( | ||
| perf, | ||
|
|
@@ -938,7 +937,7 @@ def _invoke_text_op_trace_failure(tmp_path: Path, trace_result): | |
| obj={}, | ||
| ) | ||
|
|
||
| return result, display_report, write_json, display_trace, write_trace | ||
| return result, display_report, write_json, display_trace | ||
|
|
||
|
|
||
| class TestCliOpTracingDispatch: | ||
|
|
@@ -982,7 +981,7 @@ def test_text_mode_not_run_status_exits_before_success_reports(self, tmp_path: P | |
| status="not_run", | ||
| ) | ||
|
|
||
| result, display_report, write_json, display_trace, write_trace = ( | ||
| result, display_report, write_json, display_trace = ( | ||
| _invoke_text_op_trace_failure(tmp_path, trace) | ||
| ) | ||
|
|
||
|
|
@@ -991,7 +990,6 @@ def test_text_mode_not_run_status_exits_before_success_reports(self, tmp_path: P | |
| display_report.assert_not_called() | ||
| write_json.assert_not_called() | ||
| display_trace.assert_not_called() | ||
| write_trace.assert_not_called() | ||
|
|
||
| def test_json_mode_missing_trace_result_does_not_emit_benchmark_json( | ||
| self, tmp_path: Path | ||
|
|
@@ -1143,7 +1141,6 @@ def test_basic_fallback_status_exits_0_with_notice(self, tmp_path: Path): | |
| patch("winml.modelkit.commands.perf.display_console_report"), | ||
| patch("winml.modelkit.commands.perf.write_json_report"), | ||
| patch("winml.modelkit.session.monitor.report.display_op_trace_report"), | ||
| patch("winml.modelkit.session.monitor.report.write_op_trace_json"), | ||
| patch("winml.modelkit.onnx.is_compiled_onnx", return_value=True), | ||
| ): | ||
| result = runner.invoke( | ||
|
|
@@ -1223,7 +1220,6 @@ def test_basic_fallback_status_rejects_raw_running_model(self, tmp_path: Path): | |
| patch("winml.modelkit.commands.perf.display_console_report"), | ||
| patch("winml.modelkit.commands.perf.write_json_report"), | ||
| patch("winml.modelkit.session.monitor.report.display_op_trace_report"), | ||
| patch("winml.modelkit.session.monitor.report.write_op_trace_json"), | ||
| patch("winml.modelkit.onnx.is_compiled_onnx", return_value=False), | ||
| ): | ||
| result = runner.invoke( | ||
|
|
@@ -1317,7 +1313,7 @@ def _capture_write(*args, **kwargs): | |
| # PRD §10.5 / coreloop §8.4 mandate this test: | ||
| # "test_cli_op_tracing_basic_on_qnn (skip if no QNN NPU): runs | ||
| # wmk perf -m resnet50 --device npu --op-tracing basic, asserts CSV | ||
| # produced, *_op_trace.json written, at least one operator entry." | ||
| # produced, op trace embedded in the perf JSON, at least one operator entry." | ||
| # | ||
| # This is the only end-to-end proof that SC-1 holds: the headline | ||
| # invocation produces real per-operator trace data on a QNN NPU. | ||
|
|
@@ -1339,7 +1335,7 @@ def test_cli_op_tracing_basic_on_qnn(tmp_path): | |
|
|
||
| Hardware-gated. Must produce: | ||
| * a profiling CSV under the monitor's output directory, | ||
| * a ``*_op_trace.json`` next to the perf JSON output, | ||
| * op-trace data embedded in the perf JSON output, | ||
| * at least one operator entry, with ``status == "ok"``. | ||
|
|
||
| A regression that silently falls back to CPU (the bug SC-1 explicitly | ||
|
|
@@ -1378,15 +1374,11 @@ def test_cli_op_tracing_basic_on_qnn(tmp_path): | |
| f"perf --op-tracing basic failed (exit {result.exit_code}):\n{result.output}" | ||
| ) | ||
|
|
||
| # Per-op trace JSON written next to the perf output. | ||
| trace_files = list(tmp_path.glob("*_op_trace.json")) | ||
| assert trace_files, ( | ||
| f"Expected *_op_trace.json next to {output_path}; got: {list(tmp_path.iterdir())}" | ||
| ) | ||
|
|
||
| import json | ||
|
|
||
| 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")) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This behavior change also leaves
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated the existing QNN NPU E2E to read |
||
| assert trace_data["status"] == "ok", ( | ||
| f"Expected status='ok' on real hardware, got {trace_data['status']!r} " | ||
| f"with error={trace_data.get('error')!r}" | ||
|
|
||
There was a problem hiding this comment.
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 newsum()runs first. With multiple partitions, summing those strings raisesTypeError, the monitor reportsparse_failed, andwinml perf --op-tracingexits 4. A regression test combining multiple partitions with float-string metadata would catch this.There was a problem hiding this comment.
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.