Apply constant folding to Q/DQ patterns on constants#802
Open
pluralia wants to merge 12 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends ONNX constant propagation to further fold/remove Q/DQ patterns rooted at constants (under the existing enableQDQ gate), helping eliminate leftover Slice/Transpose/etc. that can block later optimizations.
Changes:
- Adds
BypassShapeOpThroughDQ<...>to commute shape-only ops ahead ofDequantizeLinearfor per-tensor quantization on constants. - Adds
DropIdempotentQDQOnConstto remove no-opConst -> DQ -> Qround-trips on integer constants when parameters are identical. - Adds
FoldRequantizeOnConstto materialize a new integer constant for genuineConst -> DQ -> Qrequantization.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
jorickert
reviewed
Jun 1, 2026
guwacAMD
approved these changes
Jun 1, 2026
ilango100
requested changes
Jun 1, 2026
ilango100
approved these changes
Jun 1, 2026
DMAC FE Regression Summary
Per-model frontend diff
psx0-qdq — net op-type deltas (REF → CHK)
120 microsoft-infoxlm-large — side effect
|
54f8e3e to
35620a8
Compare
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.
The update is required to remove
SliceandTransposeops ifMMis identified as act x weight instead of act x act.Adds three new patthers to
src/Dialect/ONNX/Transforms/ConstProp.cpp, all gated behind the existingenableQDQflag and registered alongside the currentRemoveQDQForConst. They target Q/DQ chains rooted at anONNXConstantOpthat the existing patterns leave behind:BypassShapeOpThroughDQ<ONNXOp>— swapsConst → DQ → ShapeOpintoConst → ShapeOp → DQforSlice/Transpose/Reshape/Squeeze/Unsqueezeso the existing *OfConst folders can collapse the shape op on the integer constant.DropIdempotentQDQOnConst— removes aConst → DQ(s,z) → Q(s,z)round-trip on an integer constant when theDQandQshare the same scale, zero-point, and storage dtypeFoldRequantizeOnConst— materializes a new integer constant for a genuineConst → DQ(s1,z1) → Q(s2,z2,intT2)requantize by recomputing each element with round-to-nearest-even and saturation