Skip to content

Validate DQ scale/zero_point shapes before QGemm fusion - #28714

Merged
fdwr merged 1 commit into
microsoft:mainfrom
wangw-1991:fix_QGemm
Jun 9, 2026
Merged

Validate DQ scale/zero_point shapes before QGemm fusion#28714
fdwr merged 1 commit into
microsoft:mainfrom
wangw-1991:fix_QGemm

Conversation

@wangw-1991

Copy link
Copy Markdown
Contributor

Description:

This PR adds shape validation in GemmNodeGroupSelector::Check to prevent incorrect DQ-Gemm-Q to QGemm fusion when DequantizeLinear nodes have incompatible scale/zero_point shapes.

Problem

The QGemm op requires a_zero_point and b_zero_point as mandatory inputs, and only supports scalar or 1D scale/zero_point. Previously, the selector did not validate these constraints, which could lead to runtime crashes when incorrect fusion occurs.

Changes

  • Added IsScalarOr1DWithSizeOneOrN() helper to validate that a NodeArg's shape is scalar or 1D with size 1 or N. Rejects unknown shapes to avoid incorrect fusion.
  • Added checks in GemmNodeGroupSelector::Check to maintain consistency with QGemm checks.
  • Added test Gemm_NoQGemmFusionWithHighRankScaleZp to verify that DQ nodes with rank-2 scale/zero_point are not fused into QGemm.

@wangw-1991

Copy link
Copy Markdown
Contributor Author

@fdwr PTAL, thanks.

@wangw-1991

Copy link
Copy Markdown
Contributor Author

@fdwr Friendly ping.

@fdwr fdwr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM. Sorry for losing this in the notification sea :(. (feel free to bug me via Teams)

@wangw-1991

Copy link
Copy Markdown
Contributor Author

👍 LGTM. Sorry for losing this in the notification sea :(. (feel free to bug me via Teams)

Thanks for the review. Do I need to find another reviewer or you can help merge this?

@fdwr
fdwr merged commit 238905a into microsoft:main Jun 9, 2026
96 of 97 checks passed
@wangw-1991
wangw-1991 deleted the fix_QGemm branch July 15, 2026 07:55
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.

2 participants