Skip to content

[QNN EP] Add 2-bit BQ STD Symmetric Support - #787

Open
qti-ashwshan wants to merge 13 commits into
mainfrom
dev/ashwshan/w2a16-bw-block-mapped
Open

qti-ashwshan wants to merge 13 commits into
mainfrom
dev/ashwshan/w2a16-bw-block-mapped

Conversation

@qti-ashwshan

Copy link
Copy Markdown
Collaborator

Description

  • Add 2-bit BQ Standard Symmetric support via BW_BLOCK_MAPPED encoding
  • Skip DQ insertion and use native output dtype for BW_BLOCK_MAPPED (ProcessAttributesAndOutputs)

Motivation and Context

@qti-ashwshan qti-ashwshan self-assigned this Aug 31, 2026
…encoding

Use QNN_QUANTIZATION_ENCODING_BW_BLOCK_MAPPED with STANDARD_SYMMETRIC
mapping for 2-bit weights with symmetric zero-points and 16-bit quantized
activations. This keeps activations in int16 natively without the int16->fp16
Dequantize workaround needed by the BW_FLOAT_BLOCK path.

- Add BwBlockMapped() factory and deep-copy support in QnnQuantParamsWrapper
- Add IsBwBlockMapped() predicate and include in IsBlockQuantized()
- Wire BW_BLOCK_MAPPED path in MatMulNBits op builder (ProcessInputs)
- Skip DQ insertion and use native output dtype for BW_BLOCK_MAPPED (ProcessAttributesAndOutputs)
- Add unit tests for W2A16 std symmetric with/without explicit ZP tensor
@qti-ashwshan
qti-ashwshan force-pushed the dev/ashwshan/w2a16-bw-block-mapped branch from dbbab47 to e8e4368 Compare September 12, 2026 04:36

@1duo 1duo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

A few comments inline. #1 (matmulnbits_op_builder.cc, asymmetric W2A16 path) is blocking: it breaks the build on QAIRT ≥ 2.51 after the merge from main.

Also: BwBlockMapped() and the BW_BLOCK_MAPPED deep copy in Init (copy constructor and operator=) have no host-side tests in qnn_quant_params_wrapper_test.cc. The only coverage is the HTP integration tests, which need aarch64/Linux with V69+. A small host test should check that copies own their own blockSize/scaleOffset buffers, and that bitwidth and mapping survive the copy.

@qti-ashimaj

Copy link
Copy Markdown
Collaborator

@qti-ashwshan, Could you please check the failing existing as well as the BwBlockMapped TCs

- Restrict native W2A16 to standard symmetry, SDK 2.52+, and supported v81+ shapes.
- Preserve ONNX block-scale order and sign-extend unpacked INT2 weights.
- Retain BW_FLOAT_BLOCK fallback and align native and wrapper tests.
- Keep SDK-version definitions for native W2A16 test gating.
- Retain mainline accuracy-test enablement alongside the 2-bit changes.
- Scope SDK version macros to MatMulNBits tests.
- Fix MatMulNBits clang-format alignment.

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.

4 participants