Skip to content

[LinalgExt] Add affine quantization and dequantization ops - #24901

Merged
Manewing merged 1 commit into
mainfrom
users/ziereis/qdq-linalg-ext-ops
Sep 15, 2026
Merged

Manewing merged 1 commit into
mainfrom
users/ziereis/qdq-linalg-ext-ops

Conversation

@ziereis

@ziereis ziereis commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Adds iree_linalg_ext.quantize_affine and iree_linalg_ext.dequantize_affine to represent QDQ directly in LinalgExt, preserving quantization parameters for subsequent compiler transformations.

Independent indexing maps for the input, scale, zero point, and output express per-tensor, per-channel, and blockwise quantization. The ops support optional zero points, explicit storage and zero-point signedness, and arithmetic in the scale's element type. Quantization rounds ties to even and clamps to the specified storage range.

Includes operation verification, shape reification, and decomposition into elementwise Linalg generics. Dispatch creation decomposes remaining QDQ ops before fusion, allowing earlier optimizations to consume the explicit quantization representation.

Implements the QDQ operation layer of Linalg(_ext) native QDQ #24862.


Stack created with GitHub Stacks CLI • Give Feedback 💬

@ziereis
ziereis added this pull request to stack #24903 September 9, 2026 06:50
@ziereis ziereis changed the title users/ziereis/qdq linalg ext ops [LinalgExt] Add affine quantization and dequantization ops Sep 9, 2026
@ziereis
ziereis marked this pull request as ready for review September 9, 2026 07:00
@ziereis
ziereis force-pushed the users/ziereis/qdq-linalg-ext-ops branch 2 times, most recently from f3fda4b to aa350f2 Compare September 10, 2026 07:16
Signed-off-by: Thomas Ziereis <[email protected]>
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@ziereis
ziereis force-pushed the users/ziereis/qdq-linalg-ext-ops branch from aa350f2 to b0c4672 Compare September 10, 2026 07:26

@jschuhmacher jschuhmacher left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Looks good to me

@Manewing
Manewing merged commit b3e3e26 into main Sep 15, 2026
60 of 62 checks passed
@Manewing
Manewing deleted the users/ziereis/qdq-linalg-ext-ops branch September 15, 2026 08:38
Manewing added a commit that referenced this pull request Sep 22, 2026
Rewrites contractions over `iree_linalg_ext.dequantize_affine` operands
into integer contractions, integer zero-point corrections, and
floating-point scaling.

The transformation uses indexing maps and iterator types to handle named
and generic contractions, including convolutions. It reduces in integer
arithmetic over dimensions where quantization parameters are invariant.
For blockwise quantization, it computes integer partial results, applies
each block's correction and scales, then accumulates across blocks in
floating point.

Zero-point correction terms are built as separate computations so
constant terms can be evaluated independently. Corrections are applied
before conversion to floating point. Scaling and accumulation use at
least f32, preserving wider scale or output types and narrowing only the
final result.

The rewrite requires a plain multiply-add body, zero initialization, and
positive static integer reduction extents whose products and corrections
fit in signed i32. Unsupported cases retain the original computation.
The pass is enabled by default; reassociation changes floating-point
rounding. It can be disabled with
`--iree-global-opt-enable-qdq-to-integer-math=false`.

Builds on the [affine QDQ operations PR
#24901](#24901) and implements the
contraction rewrite portion of [Linalg(_ext) native QDQ
#24862](#24862).

---

<sub>Stack created with <a
href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a
href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub>

---------

Signed-off-by: Thomas Ziereis <[email protected]>
Signed-off-by: Florian Walbroel <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Co-authored-by: Florian Walbroel <[email protected]>
@devtbi devtbi mentioned this pull request Oct 5, 2026
9 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants