Skip to content

Fix QDQ MatMul fusion by validating quantization parameters - #33616

Open
Theodore Cooper (the0cp) wants to merge 2 commits into
microsoft:mainfrom
the0cp:fix-qdq-matmul-params
Open

Theodore Cooper (the0cp) wants to merge 2 commits into
microsoft:mainfrom
the0cp:fix-qdq-matmul-params

Conversation

@the0cp

@the0cp Theodore Cooper (the0cp) commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fix QDQ MatMul fusion that can produce an unsupported QLinearMatMul or incorrect results when per-axis quantization parameters are used.

The selector now validates that:

  • A and Y use scalar or single-element quantization parameters.

  • B uses per-tensor or supported 2D per-column quantization, with a supported axis and shapes.

Unsupported cases fall back to the original DQ → MatMul → Q path by skipping fusion, preserving correctness without changing the kernels.

fix: #33333

Copilot AI balanced review requested due to automatic review settings October 26, 2026 14:03
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI 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.

🟡 Changes recommended

The kernel-specific checks also restrict shared execution-provider grouping, breaking previously supported QNN quantized MatMul offload.

1 open issue
What changed in this PR

This PR adds quantization-parameter validation to ONNX Runtime’s QDQ MatMul fusion to avoid unsupported QLinearMatMul nodes or incorrect results.

Changes:

  • Require scalar or single-element quantization parameters for A and Y.
  • Allow B’s per-tensor or supported two-dimensional per-column quantization, skipping fusion otherwise.
  • Add five regression tests covering supported and rejected parameter shapes and axes.
File Description
onnxruntime/​test/​optimizer/​qdq_transformer_test.cc Adds fusion and fallback tests for MatMul quantization parameters.
onnxruntime/​core/​optimizer/​qdq_transformer/​selectors_actions/​qdq_selectors.cc Validates parameter shapes and B’s quantization axis before fusion.

Review effort: Balanced

Comment thread onnxruntime/core/optimizer/qdq_transformer/selectors_actions/qdq_selectors.cc Outdated

Copilot AI 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.

🟢 Approval recommended

The focused validation matches kernel restrictions, preserves generic selection, and includes regression coverage for the affected behavior.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

This branch has not been deployed

No deployments
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.

[Bug] QDQ MatMul fusion creates a QLinearMatMul that rejects valid per-row parameters

2 participants