[converter] Fix negative axis in quantize/dequantize lowering - #24
Merged
jakesabathia2 merged 3 commits intoJul 8, 2026
Merged
Conversation
The quantize/dequantize lowering normalized a negative axis as axis + rank - 1, off by one from the eager op, which resolves it as axis + rank. A per-channel axis=-1 was applied one dimension early, so the converted model used the wrong channel; when the channel and a neighbor dim share a size this is silent, with no shape error. Normalize a negative axis as axis + rank, matching the eager op. Add per-channel negative-axis numerical tests for both ops. They use a (2, 4, 4) shape with equal middle and channel dims so a wrong axis surfaces as a numerical mismatch rather than a reshape error.
pkmandke
reviewed
Jul 6, 2026
| ) | ||
|
|
||
| model = Model() | ||
| x = torch.randn(2, 4, 4) |
Member
There was a problem hiding this comment.
Maybe we can use a different dim value at [1], so something like (2,3,4) for clarity on which axis is picked via the negative indexing.
Contributor
Author
There was a problem hiding this comment.
Added (2, 3, 4) as you suggested and kept (2, 4, 4) too. Equal dims are the case where a wrong axis is silent instead of a reshape error, so both stay covered.
pkmandke
reviewed
Jul 6, 2026
| ) | ||
|
|
||
| model = Model() | ||
| x = torch.randint(-128, 127, (2, 4, 4), dtype=torch.int8) |
Contributor
|
Thank you for the fix @eyupcanakman , can you please rebase on the latest main and re-push? |
pkmandke
approved these changes
Jul 7, 2026
pkmandke
left a comment
Member
There was a problem hiding this comment.
Lgtm!
@yixingli-apple can you please take a look as well?
yixingli-apple
approved these changes
Jul 8, 2026
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.
Description:
Testing