Repository navigation
[Fix][Relax] Preserve 16-bit quantization saturation - #20987
Open
DiadkoShmek wants to merge 1 commit into
Open
DiadkoShmek wants to merge 1 commit into
DiadkoShmek wants to merge 1 commit into
Conversation
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.
Fixes #20891.
Relax quantization to 16-bit integers can clip in float16. The signed upper bound
32767rounds to32768, and the unsigned bound65535rounds to infinity. The final integer cast can turn positive saturation into-32768or0, respectively. Adding the zero point in float16 can also lose valid interior codes such as4096 / 2 + 15 = 2063.For
int16anduint16outputs, use float32 for the division, rounding, zero-point addition, and clip. The clip bounds are exactly representable in float32, and the cast to the requested integer dtype happens after clipping.Validation on
23a6dbe, Linux x86-64, LLVM from TIRx 0.1.0.Codex assisted with the patch and validation.