Skip to content

[Torch] Convert PT2E per-token quantization to LinalgExt - #25024

Merged
roberto-laudani merged 1 commit into
mainfrom
users/roberto-laudani/qdq-per-token
Oct 15, 2026
Merged

roberto-laudani merged 1 commit into
mainfrom
users/roberto-laudani/qdq-per-token

Conversation

@roberto-laudani

@roberto-laudani roberto-laudani commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Extends ConvertTorchQuantizationToLinalgExt (#24918) to quantized_decomposed.quantize_per_token and dequantize_per_token.

Depends on #25008 and #25046.

Part of #24862.

@roberto-laudani roberto-laudani changed the title [Torch] Convert PT2E per-token dequantization to LinalgExt [Torch] Preserve PT2E per-token dequantization as LinalgExt ops Oct 12, 2026
@roberto-laudani
roberto-laudani force-pushed the users/roberto-laudani/qdq-per-token branch 2 times, most recently from 0e09d8b to 9a9d397 Compare October 12, 2026 09:27
@roberto-laudani roberto-laudani changed the title [Torch] Preserve PT2E per-token dequantization as LinalgExt ops [Torch] Convert PT2E per-token quantization to LinalgExt Oct 12, 2026
@roberto-laudani roberto-laudani self-assigned this Oct 13, 2026
@roberto-laudani
roberto-laudani force-pushed the users/roberto-laudani/qdq-per-channel-group branch from 322517e to 4927934 Compare October 13, 2026 13:32
@roberto-laudani
roberto-laudani force-pushed the users/roberto-laudani/qdq-per-token branch from 9a9d397 to 0bb8b19 Compare October 13, 2026 13:32
@roberto-laudani
roberto-laudani force-pushed the users/roberto-laudani/qdq-per-channel-group branch from 4927934 to 5b1e0e6 Compare October 13, 2026 13:38
@roberto-laudani
roberto-laudani force-pushed the users/roberto-laudani/qdq-per-token branch 2 times, most recently from 0bb8b19 to 305cc4e Compare October 13, 2026 13:38
@roberto-laudani
roberto-laudani force-pushed the users/roberto-laudani/qdq-per-channel-group branch from 5b1e0e6 to 82748f9 Compare October 13, 2026 13:39
@roberto-laudani
roberto-laudani force-pushed the users/roberto-laudani/qdq-per-token branch 2 times, most recently from ee64b17 to 0f711c9 Compare October 13, 2026 14:01
@roberto-laudani
roberto-laudani force-pushed the users/roberto-laudani/qdq-per-channel-group branch 4 times, most recently from 7079f29 to 9ce7cea Compare October 14, 2026 14:50
@roberto-laudani
roberto-laudani force-pushed the users/roberto-laudani/qdq-per-token branch from 0f711c9 to ee12717 Compare October 14, 2026 14:52
@roberto-laudani
roberto-laudani marked this pull request as ready for review October 14, 2026 14:53
Base automatically changed from users/roberto-laudani/qdq-per-channel-group to main October 14, 2026 20:47
Convert quantized_decomposed.quantize_per_token and dequantize_per_token
to iree_linalg_ext.quantize_affine and dequantize_affine. As in
torchao's PerToken granularity, the block size is one along every input
dimension but the last, which each block spans, so the parameters are
indexed by the leading dimensions and the data path needs no reshape.
The unit last dimension that PT2E keeps in the parameters is dropped
like any other static unit dimension.

Per-token needs no reshape, so only the checks shared with the other
granularities apply.

Quantization computes in the scale type, f64 for the scales that
torch.ao computes per token, as the per-token reference does.
Dequantization matches the PT2E reference. The per-token reference adds
the zero point before rounding, so quantize ties with odd zero points
differ from it and from the Torch-to-Linalg lowering, which follows it.

Depends on the torch-mlir ops from llvm/torch-mlir#4765.

Signed-off-by: Roberto Laudani <[email protected]>
@roberto-laudani
roberto-laudani force-pushed the users/roberto-laudani/qdq-per-token branch from ee12717 to 33c6590 Compare October 15, 2026 15:53
@roberto-laudani
roberto-laudani merged commit 89ece87 into main Oct 15, 2026
60 checks passed
@roberto-laudani
roberto-laudani deleted the users/roberto-laudani/qdq-per-token branch October 15, 2026 22:42
@devtbi devtbi mentioned this pull request Oct 19, 2026
7 of 8 tasks
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.

2 participants