Skip to content

[QNN EP] Refactor LPBQ lowering helpers across op builders - #755

Open
qti-ashimaj wants to merge 5 commits into
mainfrom
dev/qti-ashimaj/lpbqrefactor
Open

qti-ashimaj wants to merge 5 commits into
mainfrom
dev/qti-ashimaj/lpbqrefactor

Conversation

@qti-ashimaj

Copy link
Copy Markdown
Collaborator

Description

Refactors the block-quantized (BQ) and LPBQ weight lowering logic across the QNN EP op builders (Conv, MatMul, MatMulNBits) to eliminate code duplication and consolidate shared helpers.

qnn_bq_utils :

  • RegisterWeightAsConv1x1Filter: registers an LPBQ weight [K, N] as a [1, 1, K, N] HWCN 1×1 Conv2D filter, updating the LPBQ quant axis.
  • AddConv2DNodeforBQLowering: creates a QNN Conv2D node (stride=1, pad=0, dilation=1, group=1) shared by both LPBQ and BwFloatBlock lowering paths.

qnn_utils :

  • ProcessBiasForQuantizedOp: handles bias processing for quantized ops, requantizes INT32 bias if scales mismatch or quantizes float bias using activation_scale * weight_scale[c].

conv_op_builder : removed duplicated helpers (GetActivationScale, BuildBiasQuantParams, AddStaticBiasTensor, ProcessRequantizeBias, ProcessFloatBias).

matmul_op_builder / matmulnbits_op_builder : updated to use the new shared helpers.

matmul_test : enabled MatMulOp_QDQ_BlockQuant on Windows in addition to Linux.

Motivation and Context

The LPBQ lowering code was duplicated across various op builders like conv_op_builder, matmul_op_builder, and matmulnbits_op_builder. This refactor centralizes the shared logic into qnn_bq_utils and qnn_utils, making future changes (e.g., adding LPBQ support to new op builders) require only a single implementation.

@minfhong-qti

Copy link
Copy Markdown
Collaborator

Could you help rebase on mainline and resolve the conflicts?

@qti-ashimaj
qti-ashimaj force-pushed the dev/qti-ashimaj/lpbqrefactor branch from 34e7b1a to 2504fc1 Compare September 25, 2026 04:39

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.

2 participants