Repository navigation
[LinalgExt] Canonicalize zero zero-points in affine QDQ ops - #24905
Merged
Merged
Conversation
ziereis
force-pushed
the
users/ziereis/qdq-drop-zero-zp
branch
2 times, most recently
from
September 10, 2026 07:26
7e83cea to
f6ef8a2
Compare
ziereis
force-pushed
the
users/ziereis/qdq-drop-zero-zp
branch
from
September 11, 2026 06:37
f6ef8a2 to
abdb4d4
Compare
Manewing
force-pushed
the
users/ziereis/qdq-drop-zero-zp
branch
from
September 15, 2026 08:38
abdb4d4 to
9290c37
Compare
Manewing
approved these changes
Sep 22, 2026
Manewing
marked this pull request as ready for review
September 22, 2026 11:21
Manewing
requested review from
AGindinson,
egebeysel and
jschuhmacher
as code owners
September 22, 2026 11:21
Base automatically changed from
users/ziereis/qdq-integer-contractions
to
main
September 22, 2026 13:43
Manewing
requested review from
devtbi,
phemashekar and
schuermans-roofline
as code owners
September 22, 2026 13:43
A dequantize whose zero point is zero is symmetric, and every consumer benefits from seeing it that way: the QDQ to integer rewrite skips a whole correction term, and the decomposition skips a subtraction. Quantizers spell a symmetric zero point as a splat, as an explicit tensor of zeros, or, once the model is frozen, as a resource blob whose bytes live outside the attribute. isKnownZero answers a splat from its one stored element and everything else from raw bytes: for an integer tensor, all bytes zero is equivalent to all elements zero whatever the width and packing, so no element is materialized as an APInt and the resource case needs no per width decoding. Padding bytes can only make the answer a conservative false. The element type is not rechecked. The only caller passes a zero_point the op verifier has already established to be an integer. zero_point is the only optional operand, so the ops carry no operand segment attribute and the drop is an in place mutation: clear the operand, drop its indexing map, remove zp_unsigned. Everything else the op carries is preserved by construction rather than by an attribute copy that would have to be revisited whenever an attribute is added. Signed-off-by: Thomas Ziereis <[email protected]> Signed-off-by: default <[email protected]>
Manewing
force-pushed
the
users/ziereis/qdq-drop-zero-zp
branch
from
September 22, 2026 13:43
9290c37 to
926c874
Compare
7 of 8 tasks
roberto-laudani
added a commit
that referenced
this pull request
Oct 23, 2026
PT2E accepts float zero points, and exports store those of symmetric weights as float zeros. The conversion passed them to `iree_linalg_ext.quantize_affine` / `dequantize_affine`, which require integer zero points, so the converted IR failed verification: ``` 'iree_linalg_ext.dequantize_affine' op expected zero_point to have a signless integer element type, got 'f32' ``` - All-zero float zero points are now dropped like a `None` zero point. - The check reuses `isKnownZero` from #24905, moved from `LinalgExtOps.cpp` to the LinalgExt utils and extended to float splats. - The per-channel, per-channel-group and per-token readers now read their zero points through one helper. Part of #24862. Signed-off-by: Roberto Laudani <[email protected]>
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.
Canonicalizes
iree_linalg_ext.quantize_affineandiree_linalg_ext.dequantize_affineby removing a zero-point operand when its constant value is zero in every element. The operations then expose symmetric quantization directly, allowing decomposition to omit zero-point arithmetic and the integer-contraction rewrite to skip the corresponding correction terms.Handles scalar constants, tensor splats, dense tensors, and resource-backed tensor constants. Removing the operand also removes its indexing map and
zp_unsignedattribute while preserving the remaining operation attributes. Tests cover these constant representations, nonzero values that must remain, and preservation of the operation's other parameters.Builds on #24902 in the affine QDQ stack. Part of #24862.