Skip to content

[OnnxToTorch] Preserve element types in MatMulInteger when zero-points are absent#4531

Open
Abhishek-Varma wants to merge 1 commit intollvm:mainfrom
Abhishek-Varma:fix_matmul_int
Open

[OnnxToTorch] Preserve element types in MatMulInteger when zero-points are absent#4531
Abhishek-Varma wants to merge 1 commit intollvm:mainfrom
Abhishek-Varma:fix_matmul_int

Conversation

@Abhishek-Varma
Copy link
Copy Markdown
Collaborator

@Abhishek-Varma Abhishek-Varma commented Apr 10, 2026

The MatMulInteger lowering unconditionally widens operands to i32 before creating aten.matmul, even when no zero-point operands were provided (symmetric quantization, zp=0). This destroyed the narrow element type information early in the pipeline, preventing downstream passes from selecting appropriate hardware intrinsics (e.g. i8 MAC instructions) that depend on seeing the original element types.

When both zero-point operands are absent, skip the i32 widening and zero-point subtraction entirely and emit aten.matmul with the original (i8/u8) operands. The existing i32 path is preserved when at least one zero-point is provided, since subtracting a non-zero zero-point from an i8 (or any low bit-width) value requires a wider type to avoid overflow.

Signed-off-by: Abhishek Varma abhvarma@amd.com

…s are absent

The MatMulInteger lowering unconditionally widened i8/u8 operands to
i32 before creating aten.matmul, even when no zero-point operands were
provided (symmetric quantization, zp=0). This destroyed the narrow
element type information early in the pipeline, preventing downstream
passes from selecting appropriate hardware intrinsics (e.g. i8 MAC
instructions) that depend on seeing the original element types.

When both zero-point operands are absent, skip the i32 widening and
zero-point subtraction entirely and emit aten.matmul with the original
i8/u8 operands. The existing i32 path is preserved when at least one
zero-point is provided, since subtracting a non-zero zero-point from
an i8 value requires a wider type to avoid overflow.

Signed-off-by: Abhishek Varma <abhvarma@amd.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant