Skip to content

Fix int8 zero-point overflow and conv bias_scale in eager quantized ref kernels#20655

Merged
meta-codesync[bot] merged 1 commit into
pytorch:mainfrom
abeakkas:export-D110220645
Jul 1, 2026
Merged

Fix int8 zero-point overflow and conv bias_scale in eager quantized ref kernels#20655
meta-codesync[bot] merged 1 commit into
pytorch:mainfrom
abeakkas:export-D110220645

Conversation

@abeakkas

Copy link
Copy Markdown
Contributor

Summary:
Fix two numerical bugs in the eager Cadence reference kernels (ref_implementations.py) that made them diverge from the deployed C++ kernels.

  1. Int8 zero-point overflow: the dequant subtracted the zero-point while the tensor was still int8, so a negative zero-point could overflow and wrap. We now upcast before subtracting. Affects quantized_add, quantized_mul, quantized_linear, quantized_matmul, quantized_conv, and quantized_relu.

  2. Conv bias_scale: quantized_conv_per_tensor added a pre-scaled bias onto an unscaled integer convolution accumulation, leaving the output off by ~1/bias_scale. We now add the integer bias pre-scale and dequantize the whole accumulation by bias_scale.

Also corrects the uint8 dtype-check error messages in quantized_add.

Differential Revision: D110220645

…ef kernels

Summary:
Fix two numerical bugs in the eager Cadence reference kernels (`ref_implementations.py`) that made them diverge from the deployed C++ kernels.

1. Int8 zero-point overflow: the dequant subtracted the zero-point while the tensor was still int8, so a negative zero-point could overflow and wrap. We now upcast before subtracting. Affects `quantized_add`, `quantized_mul`, `quantized_linear`, `quantized_matmul`, `quantized_conv`, and `quantized_relu`.

2. Conv bias_scale: `quantized_conv_per_tensor` added a pre-scaled bias onto an unscaled integer convolution accumulation, leaving the output off by ~`1/bias_scale`. We now add the integer bias pre-scale and dequantize the whole accumulation by `bias_scale`.

Also corrects the uint8 dtype-check error messages in `quantized_add`.

Differential Revision: D110220645
@pytorch-bot

pytorch-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20655

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 08ef0e5 with merge base d54a0c0 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 30, 2026
@meta-codesync

meta-codesync Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

@abeakkas has exported this pull request. If you are a Meta employee, you can view the originating Diff in D110220645.

@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@meta-codesync meta-codesync Bot merged commit f95486d into pytorch:main Jul 1, 2026
192 of 198 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants