Repository navigation
[4/12] Add DLA quantization and FP32 preprocessing - #3184
mgohil-png wants to merge 1 commit into
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
Walkthrough
Merge Risk:
|
|
@coderabbitai full review |
Action performed
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dla/onnxscript-03-matrix-indexing #3184 +/- ##
=====================================================================
+ Coverage 82.17% 82.21% +0.04%
=====================================================================
Files 738 741 +3
Lines 82483 82686 +203
=====================================================================
+ Hits 67781 67984 +203
Misses 14702 14702
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
9da08aa to
cb101bd
Compare
|
cb101bd to
7f71f33
Compare
Signed-off-by: mgohil <[email protected]>
7f71f33 to
e17fd78
Compare
| continue | ||
| parameter = formal[min(index, len(formal) - 1)] | ||
| groups[parameter.type_str].append(value) | ||
| if "tensor(float)" not in allowed.get(parameter.type_str, [parameter.type_str]): |
There was a problem hiding this comment.
P1 — An operator attribute can fix its output dtype even when the schema allows FLOAT. Changing the value metadata leaves the operator producing the old dtype, so its consumer can fail type checking. Please skip promotion when the producing attribute fixes the type.
| for value in (*graph.inputs, *graph.initializers.values()) | ||
| if value.dtype != ir.DataType.FLOAT | ||
| } | ||
| for node in graph: |
There was a problem hiding this comment.
P1 — A nested graph can use an outer value without listing it as an input to the parent node. Promoting that value can break a branch that needs an integer. Please check captured uses before changing the Cast.
| graph.apply_pass(_cleanup.RestoreValueNames(names)) | ||
| graph.apply_pass(ir.passes.common.RemoveUnusedNodesPass()) | ||
| count += graph.apply_pattern(preprocessing_rules.ConstantInitializer.rule(graph)) | ||
| analysis = preprocessing_passes.AnalyzeFp32Casts() |
There was a problem hiding this comment.
P1 — Q/DQ removal can insert a Cast to preserve the graph output dtype. This pass promotes that Cast too, which changes the public output type. Please keep the output-preserving Cast out of promotion.
| shape[axis] = -1 | ||
| factors, zeros = factors.reshape(shape), zeros.reshape(shape) | ||
| else: | ||
| factors, zeros = factors.reshape(()), zeros.reshape(()) |
There was a problem hiding this comment.
P2 — An empty per-axis scale reaches the scalar reshape here and makes preprocessing fail on a valid model. Please keep the per-axis broadcast shape when the axis is empty.
| blocked.add(value) | ||
| for group in groups.values(): | ||
| for value in group: | ||
| adjacent[value].update(group) |
There was a problem hiding this comment.
P2 — Storing every pair in the type group makes memory use grow quadratically with the input count. Connecting each value to one representative would keep the group reachable with linear storage.
What does this PR do?
Type of change: new feature
Adds selected Q/DQ bypass, Constant materialization, connected FP32-region preparation and eligible static dequantization folding. Standard and Microsoft Q/DQ share the same policies; matrix weight eligibility from PR 3 prevents folding weight chains needed by later lowering.
Usage
Internal preprocessing stage. Default Q/DQ bypass targets INT16/UINT16 storage; the final public operation exposes explicit dtype selection or removal of all Q/DQ.
Testing
CI readiness check (2026-11-05): latest unit tests, code quality, and documentation workflows passed for this head. Aggregate checks still include cancelled duplicate runs.
Focus: Q/DQ domains and endpoint dtypes, constants, connected Cast analysis, native/control-flow constraints, optional inputs and shared static DQ expressions.
Slice validation: 53 tests passed on this slice using
python -m pytest tests/unit/onnx/graph_surgery/dla_transforms tests/unit/onnx/graph_surgery/test_graph_utils.py -o addopts= -q -p no:cacheprovider --strict-markers.Repository checks: Ruff, formatting, license, security, whitespace and applicable repository hooks passed. Mypy reports the preexisting Windows
os.sched_getaffinityerror; it was excluded from commit hooks after confirming the same unrelated error.Added source lines against this PR's base: 448 added Python source lines; tests and documentation excluded.
Before your PR is "Ready for review"
Follow the Contributor guidelines and Security Coding Practices. Commits are signed and signed off.
CONTRIBUTING.md?: N/A - uses existing dependencies; no external source copied.Additional Information
Base: #3183. Merge after that PR; this slice builds on the preceding stack changes.
Merge order is 1 through 12. Review against the immediate base so earlier slices are excluded from this diff. Series: 1/12, 2/12, 3/12, 4/12, 5/12, 6/12, 7/12, 8/12, 9/12, 10/12, 11/12, 12/12
Q/DQ bypass intentionally removes rounding/clipping, and eligible integer-to-FLOAT Cast promotion changes truncation semantics. These are preparation policies rather than exact graph simplifications.
Summary by CodeRabbit