Repository navigation
[Torch] Preserve PT2E per-channel-group quantization as LinalgExt ops - #25008
Conversation
e15b536 to
52fcff2
Compare
f4d9db0 to
322517e
Compare
There was a problem hiding this comment.
Generally the approach looks fine to me. I'm generally not very happy with the axis/group_size split, thats also why we need so many special case if blocks. Depending on if the the per_token lowering adds another set of those we should maybe think of refactoring this a bit. However i would not do this right now.
I think some of the tests could be a bit more verbose and i have some smaller comments about duplicate verification/ verification in the wrong place. If these are addressed its good2go from my side.
|
i just took a quick look at the PR for the per_tensor ops. I think better if we add something like:
to the PT2EQuantization struct and get rid of the "axis" and "groupSize" parameter and instead derive this from the named pt2e ops. This could then also be used by the per_token ops and ofc also the torchao-native ops as soon as they are ready. |
512a5f1 to
d22e898
Compare
Convert quantized_decomposed.quantize_per_channel_group and dequantize_per_channel_group to iree_linalg_ext.quantize_affine and dequantize_affine, so later QDQ optimizations see the groups instead of the floordiv-indexed arithmetic of Torch-to-Linalg. LinalgExt parameter maps must be projected permutations, so the ops work on the input with its last dimension split into groups, and the result is collapsed back. Ops that LinalgExt cannot express stay on the Torch-to-Linalg path, such as groups that do not divide a static last dimension, bounds outside the storage type, and quantize with scales narrower than 32 bits or than the input. These checks only apply to the grouped ops, so per-tensor and per-channel conversion is unchanged. Dequantization matches the PT2E reference, except where the reference overflows when subtracting the zero point in the storage type. The reference quantizes by adding the zero point before rounding, so ties with odd zero points differ, as they already do in Torch-to-Linalg. Signed-off-by: Roberto Laudani <[email protected]>
f09b638 to
7079f29
Compare
Signed-off-by: Roberto Laudani <[email protected]>
7079f29 to
9ce7cea
Compare
|
@ziereis thanks for the review. I addressed your comments. Could you have another look, please? |
Extends `ConvertTorchQuantizationToLinalgExt` (#24918) to `quantized_decomposed.quantize_per_token` and `dequantize_per_token`. Depends on #25008 and #25046. Part of #24862. Signed-off-by: Roberto Laudani <[email protected]>
Extends
ConvertTorchQuantizationToLinalgExtto the PT2Equantized_decomposedper-channel-group quantize/dequantize ops. All granularities, including per-tensor and per-channel, derive their layout from a torchao-style block size and share one operand check. Bool zero points are treated as unsigned.Part of #24862.