Repository navigation
Conversation
quantize_per_channel and dequantize_per_tensor.tensor checked for a float64 scale with ET_CHECK_MSG, so a float32 scale aborted the process. quantize_per_tensor.tensor failed with InvalidArgument through the runtime and aborted through its context-free overload. They now accept Float and Double scales, as dequantize_per_channel already does, which also lets quantize_per_token, built on quantize_per_channel, take float32 scales. Other scale dtypes are still rejected.
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/25874
Note: Links to docs will display an error until the docs builds have been completed.
|
Contributor
Author
|
@pytorchbot label "release notes: ops & kernels" |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
quantize_per_channelanddequantize_per_tensor.tensorchecked for a float64 scale withET_CHECK_MSG, so a float32 scale aborted the process, andquantize_per_tensor.tensorfailed withInvalidArgument(reproduction in #25873). They now accept Float and Double scales, asdequantize_per_channelalready does;quantize_per_token, which goes throughquantize_per_channel, gets the same. Other scale dtypes are still rejected, and float64 scales give the same results as before.choose_qparamskeeps its float64 output, like the eager op, and the Cadence copies of these kernels are left as they are.This touches
quantize_per_channel_outlike #25824; whichever lands second, I will rebase it.Fixes #25873
Test plan
New C++ cases:
QuantizePerChannelFloatScale(axes 0 and 1),QuantizePerTokenFloatScale, andTensorArgOverloadFloatScalefor quantize (which also checks that a Half scale still fails withInvalidArgument) and for dequantize. Before the change they aborted on the scale dtype check, or returned error 0x12.Through the Python runtime, the three ops with float32 scales now match eager PyTorch exactly on 4096 random values per case, for int8, uint8 and int16.
pytest exir runtime/test kernels/quantized/testfails only where it already fails on main in my build (XNNPACK and demo backends, not built).This PR was authored with the help of Claude Code (Anthropic); I reviewed and tested it.
cc @nil-is-all