microsoft / microsoft/winml-cli

P1-FEATURE-007: Graph Optimizer — QLinear * Rewrite

Open
#154 0 comments 0 reactions 1 assignee View on GitHub

@tezheng is already working on this.

Since Mar 31, 2026.

feature scale graph-optimizer P1 QDQ triaged
Dominant language
Python
Stars
40
Forks
11
Avg merge
1d 8h
Merged PRs (30d)
50

Description

Summary

Implement pattern-based rewriting for QLinear operators (QLinearConv, QLinearMatMul) to enable quantization-aware graph transformations needed for INT8/INT4 model deployment on NPUs.

Context

QLinear operators are ONNX's representation of quantized computations. Fusing and rewriting these operators (e.g., QLinearConv → fused INT8 kernel) is required for efficient execution on hardware NPUs that support quantized computation natively. This is the final graph optimizer capability needed for QDQ pipeline completion.

From:

  • plans/release/0315_release_plan/P1_CHECKLIST.md (P1-FEATURE-006)
  • plans/release/0501_release_plan/P0_CHECKLIST.md (P1-FEATURE-007)

Current State

  • Graph optimizer supports FP32/FP16 rewrites (#397) and attribute changes (#396)
  • No QLinear-specific rewrite rules implemented
  • QDQ pipeline (#401) produces QLinear operators that need post-processing

Desired State

  • QLinear * patterns recognized and rewritten by the graph optimizer
  • QLinearConv + Bias fusion
  • QLinearMatMul → INT8 GEMM rewrite (where EP supports it)
  • Quantization-scale/zero-point folding

Acceptance Criteria

  • QLinearConv fusion rule implemented and tested
  • QLinearMatMul rewrite rule implemented and tested
  • Scale/zero-point folding across consecutive QDQ patterns
  • All QLinear rewrite rules tested against QDQ-quantized P0 models
  • Runtime-validated: quantized model output matches pre-rewrite output within tolerance
  • All existing tests pass (CARDINAL RULE: no regressions)

Technical Notes

  • Must follow CARDINAL RULE #1: no hardcoded model architecture assumptions — all pattern matching must be graph-structure-based
  • QLinear op spec: https://onnx.ai/onnx/operators/onnx__QLinearConv.html
  • Test with QDQ output from #401 on at least 3 architectures (CNN, BERT, ViT)

Related Files

  • plans/release/0315_release_plan/feature-scale.md — P1.4 QLinear Rewrite
  • plans/release/0501_release_plan/feature-scale.md — P1.7 QLinear Rewrite
  • plans/release/0315_release_plan/P1_CHECKLIST.md — P1-FEATURE-006
  • plans/release/0501_release_plan/P0_CHECKLIST.md — P1-FEATURE-007
  • #401 — QDQ quantization (upstream dependency)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.