Skip to content

Fix for Type Check in Quantized CPU op_dequantize #13174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 8, 2025

Conversation

BujSet
Copy link
Contributor

@BujSet BujSet commented Aug 7, 2025

Summary

When quantizing a model (without delegating to a specific backend), an exported model relies on the operator library in kernels/quantized/cpu/. Specifically, the essential operation of op_dequantize is performing:

out = (in - offset) * scale

where the offset is an integer type. While initially, this offset is assumed to be an uint64_t (see here), when it is used to perform the operation above, it is cast down to a uint32_t (see here). It seems an implicit assumption is that the quantization offset is a uint32_t value, and the uint64_t declaration is simply safeguarding for future proofing. In any event, the type check for the offset should allow the offset to be either uint32_t or uint64_t`. This PR allows for that change.

Test plan

Tested with mobilenet V2 on Arm backend. Quantized model runner initially crashed do to this check only allowing the offset to be uint64_t. When examining the values, none were larger than UINT32_MAX, so it should be safe to permit the offset to have uint32_t values. When this change was made, the mobilenet V2 runner was able to complete.

Copy link

pytorch-bot bot commented Aug 7, 2025

🔗 Helpful Links

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

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

❌ 2 New Failures, 1 Unrelated Failure

As of commit bc3d730 with merge base be221c6 (image):

NEW FAILURES - The following jobs have failed:

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

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

@BujSet BujSet self-assigned this Aug 7, 2025
@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 Aug 7, 2025
@BujSet
Copy link
Contributor Author

BujSet commented Aug 7, 2025

@pytorchbot label "release notes: none"

@pytorch-bot pytorch-bot bot added the release notes: none Do not include this in the release notes label Aug 7, 2025
@BujSet BujSet marked this pull request as ready for review August 7, 2025 04:57
@BujSet BujSet force-pushed the op_dequantize_accept_ints_and_longs branch from a07b007 to 057f136 Compare August 7, 2025 18:10
@BujSet BujSet force-pushed the op_dequantize_accept_ints_and_longs branch from 057f136 to bc3d730 Compare August 8, 2025 04:48
@BujSet BujSet merged commit 9b0feb0 into pytorch:main Aug 8, 2025
99 of 102 checks passed
@BujSet BujSet deleted the op_dequantize_accept_ints_and_longs branch August 8, 2025 16:21
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. release notes: none Do not include this in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants