Fix CPU QLinearConv: support per-channel weight zero points with distinct values#28456
Draft
Copilot wants to merge 3 commits into
Draft
Fix CPU QLinearConv: support per-channel weight zero points with distinct values#28456Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
…inct values Agent-Logs-Url: https://github.com/microsoft/onnxruntime/sessions/b3963943-a627-4094-b987-a75ad1b49f62 Co-authored-by: tianleiwu <30328909+tianleiwu@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix CPU QLinearConv for per-channel weight zero points
Fix CPU QLinearConv: support per-channel weight zero points with distinct values
May 11, 2026
tianleiwu
reviewed
May 12, 2026
Contributor
tianleiwu
left a comment
There was a problem hiding this comment.
Kernel-side routing looks correct overall; the remaining gap is regression coverage around the new depthwise fallback.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The CPU
QLinearConvkernel incorrectly rejected per-channel weight zero point tensors whose values were not all identical, even though the ONNX spec allows this for asymmetric per-channel quantization.Kernel (
qlinearconv.cc):ORT_ENFORCEinComputeOffsetthat required all per-channel W zero points to be equalComputeOffsetintoCompute()directly, exposing the full per-channel arrayW_zero_point_is_per_channel/W_zero_point_is_uniformflagsPerColumnZeroPoints = trueand passesW_zero_point_data + group_id * group_output_channelswhen ZPs differ — MLAS already supported thisMlasConvDepthwisetakes a scalarFilterZeroPoint); non-uniform per-channel ZPs automatically fall back to the group-GEMM path insteadTests (
qlinearconv_op_test.cc):zero_points_vector field toQuantizedTensorandSetWeightZeroPoints()method toQLinearConvOpTesterComputeExpectedOutputandRun()to emit a per-channel ZP tensor when setuint8activations,int8activations, and grouped convolution with per-channel W zero pointsMotivation and Context
CPUExecutionProviderthrewQLinearConv : zero point of per-channel filter must be sameat runtime for any model using asymmetric per-channel weight quantization (distinct zero points per output channel), despitew_scaleandw_zpboth being valid 1-D[Cout]tensors per the ONNX spec. This made a common quantization pattern completely unusable on CPU.