Skip to content

[Torch] Convert integral float zero points of PT2E and torchao ops - #25136

Merged
roberto-laudani merged 2 commits into
mainfrom
users/roberto-laudani/qdq-integral-float-zero-points
Nov 4, 2026
Merged

roberto-laudani merged 2 commits into
mainfrom
users/roberto-laudani/qdq-integral-float-zero-points

Conversation

@roberto-laudani

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

Copy link
Copy Markdown
Contributor

Converts integer-valued float zero points of PT2E and torchao ops to i32 so they lower to LinalgExt. The constant zero-point check moves from the dequantize_affine verifier into the Torch conversion, which declines constant zero points outside the quantization bounds.

Part of #24862.

Assisted by: Claude

@roberto-laudani roberto-laudani self-assigned this Oct 28, 2026
@roberto-laudani
roberto-laudani force-pushed the users/roberto-laudani/qdq-integral-float-zero-points branch from 6d73d8d to b612557 Compare October 28, 2026 12:56
@roberto-laudani
roberto-laudani marked this pull request as ready for review October 28, 2026 13:00
@roberto-laudani
roberto-laudani force-pushed the users/roberto-laudani/qdq-integral-float-zero-points branch from b612557 to cdbd42a Compare November 2, 2026 10:34
@roberto-laudani roberto-laudani changed the title [Torch] Convert integral float zero points of PT2E ops [Torch] Convert integral float zero points of PT2E and torchao ops Nov 2, 2026
@roberto-laudani
roberto-laudani force-pushed the users/roberto-laudani/qdq-integral-float-zero-points branch from cdbd42a to 22597c4 Compare November 2, 2026 10:39
@roberto-laudani
roberto-laudani marked this pull request as draft November 2, 2026 10:56
@roberto-laudani
roberto-laudani force-pushed the users/roberto-laudani/qdq-integral-float-zero-points branch from 22597c4 to 51a2aee Compare November 2, 2026 14:26
@roberto-laudani
roberto-laudani marked this pull request as ready for review November 2, 2026 14:27
@roberto-laudani
roberto-laudani force-pushed the users/roberto-laudani/qdq-integral-float-zero-points branch from 51a2aee to 2133964 Compare November 2, 2026 15:16
@roberto-laudani
roberto-laudani force-pushed the users/roberto-laudani/qdq-integral-float-zero-points branch from 2133964 to b25c88c Compare November 3, 2026 12:09

@egebeysel egebeysel 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.

Generally LGTM % a remark on the verifier.

Also, my coding agent found this but not sure if it's 100% relevant for the "common" zero-point values:

The two computations differ in where the subtraction happens. With a float zero point, every PT2E dequantize reference (per-channel, per-channel-group, per-token in PyTorch's _decomposed.py at main) does input - zero_points directly on the integer tensor. PyTorch type promotion makes that a float subtraction in the zero point's dtype, so the quantized value is first rounded to f16 or bf16 and the difference is rounded again. LinalgExt's dequantize_affine lowering subtracts in integers, converts the exact difference to the scale type, and then multiplies.

PT2E (f16 zero point):   f16(q) - zp   -> rounded in f16   -> * scale
LinalgExt:               (q - zp) exact as i32 -> sitofp     -> * scale

@roberto-laudani
roberto-laudani force-pushed the users/roberto-laudani/qdq-integral-float-zero-points branch from ff53898 to 69402ad Compare November 3, 2026 16:44
@roberto-laudani

Copy link
Copy Markdown
Contributor Author

Hi @egebeysel, good point, but the integer subtraction is exact and matches Inductor's dequantize_per_channel lowering. The difference comes from eager rounding in bf16/f16.

@roberto-laudani
roberto-laudani merged commit cbde0b0 into main Nov 4, 2026
60 checks passed
@roberto-laudani
roberto-laudani deleted the users/roberto-laudani/qdq-integral-float-zero-points branch November 4, 2026 14:17
@devtbi devtbi mentioned this pull request Nov 16, 2026
8 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