[TorchOnnxToTorch] Add block_size support for onnx.DequantizeLinear#4505
Open
[TorchOnnxToTorch] Add block_size support for onnx.DequantizeLinear#4505
Conversation
sahas3
reviewed
Mar 22, 2026
|
|
||
| // Block quantization: signed int8 input (si8→f32) | ||
| // CHECK-LABEL: @test_dequantizelinear_blocked_si8 | ||
| func.func @test_dequantizelinear_blocked_si8(%arg0: !torch.vtensor<[8,256],si8>, %arg1: !torch.vtensor<[8,4],f32>, %arg2: !torch.vtensor<[8,4],si8>) -> !torch.vtensor<[8,256],f32> attributes {torch.onnx_meta.ir_version = 10 : si64, torch.onnx_meta.opset_version = 21 : si64} { |
Member
There was a problem hiding this comment.
Can some e2e tests be added as well for numerical equivalence?
Contributor
Author
There was a problem hiding this comment.
I didn't find good infrastructure to test onnx ops e2e. The existing infra seems to rely on torch onnx export but that doesn't create onnx dequantize layers with block size. Adding infra for this would be out-of-scope for this PR imo and I think the current lit tests verify the conversion well.
Member
There was a problem hiding this comment.
Thanks for the clarification. Is the dequantize layers with block size produced when an ONNX model is quantized in ONNX directly?
Contributor
Author
There was a problem hiding this comment.
Yes, for example, or it could come from rewrites or other export paths.
Lower block-quantized DequantizeLinear (opset 21+) to reshape → cast → sub(zero_point) → mul(scale) → reshape. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
8fa2d5b to
738421f
Compare
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.
Lower block-quantized DequantizeLinear (opset 21+) to reshape → cast → sub(zero_point) → mul(scale) → reshape.