-
Notifications
You must be signed in to change notification settings - Fork 4
fix: pre-quantized models run optimize, only skip quantize #794
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
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 |
|---|---|---|
|
|
@@ -160,17 +160,11 @@ def build_onnx_model( | |
| "Skipping optimize + quantize, running analyze-only." | ||
| ) | ||
|
DingmaomaoBJTU marked this conversation as resolved.
|
||
| stages_skipped.append("optimize") | ||
| # Optimize+analyze only, no autoconf re-optimization | ||
| current_path, _, analyze_iters, analyze_unsupported, analyze_details = ( | ||
| run_optimize_analyze_loop( | ||
| model_path=current_path, | ||
| optimized_path=optimized_path, | ||
| config=config, | ||
| ep=ep, | ||
| device=device, | ||
| **onnx_kwargs, | ||
| ) | ||
| ) | ||
| # Skip optimize entirely for pre-quantized models. ORT Level 2 | ||
| # optimization fuses QDQ patterns (e.g. DQ→Conv→Q → QLinearConv), | ||
|
Contributor
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. Unresolved technical premise. This comment says ORT Level 2 fuses QDQ→QLinear (so optimize must be skipped), but the PR description claims the optimizer is safe and does not fuse QDQ. These can't both be true, and the PR's correctness hinges on which is. Note |
||
| # which breaks QNN/DML EP compatibility and causes CPU fallback. | ||
| analyze_iters, analyze_unsupported = 0, 0 | ||
| analyze_details: dict[str, Any] = {} | ||
|
Comment on lines
+163
to
+167
Contributor
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. The PR description contradicts this code. The title/body say pre-quantized models now run the full optimize+autoconf+analyze loop and only skip quantize, and that "our custom optimizer is safe for QDQ models." This code does the opposite — it removes None of the "Changes" bullets match the diff: there is no |
||
| else: | ||
| logger.info("Optimizing ONNX model...") | ||
| current_path, opt_elapsed, analyze_iters, analyze_unsupported, analyze_details = ( | ||
|
|
||
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.
Stale/misleading log message. This still logs "...running analyze-only," but after this change the analyze loop is gone —
analyze_iters/analyze_unsupportedare hardcoded to 0 and no analysis runs. The message now actively misdescribes the behavior (and ironically the PR description claims to fix misleading logs, yet no log line is touched in the diff). Suggest updating to something like"Pre-quantized model: skipping optimize + quantize to preserve QDQ structure."Same applies to the matching line inhf.py.