Skip to content

Introduced Packers/Matmul for QC2W weights and QP8 activations - #10877

Open
damdoo001-arm wants to merge 2 commits into
google:masterfrom
damdoo001-arm:damdoo01/int2_qc2w
Open

Introduced Packers/Matmul for QC2W weights and QP8 activations#10877
damdoo001-arm wants to merge 2 commits into
google:masterfrom
damdoo001-arm:damdoo01/int2_qc2w

Conversation

@damdoo001-arm

@damdoo001-arm damdoo001-arm commented Jul 29, 2026

Copy link
Copy Markdown

Summary

Add an SME2-optimized QP8/F32/QC2W fully connected path using KleidiAI 1.29.

The integration adds wrappers for two signed INT2 weight kernels:

  • SME2 DOT 1x64c4, targeting single-row/decode workloads.
  • SME2 MOPA 16x64c4, targeting multi-row/prefill workloads.

The path dynamically quantizes FP32 activations to INT8, uses per-channel signed INT2 weights, and produces FP32 output. It also adds:

  • Runtime SME2 dispatch.
  • NxK INT2 weight packing with scales and optional bias.
  • Fully connected operator and subgraph integration.
  • Validation of zero per-channel weight zero points.
  • Microkernel, packing, operator, and subgraph tests.

Testing

Validated locally:

  • //test:packing_test
  • //test:qp8_f32_qc2w_gemm_minmax_test
  • //test/operators:fully_connected_nc_test
  • //test/subgraph:fully_connected_test
  • SME2-enabled/KleidiAI-disabled configuration build

Validated on the Android board:

  • INT2 microkernels: 36/36 passed on both CME cores.
  • INT2 packer: 1/1 passed.
  • Fully connected operator: 13/13 passed.
  • Fully connected subgraph: 5/5 passed.
  • Gemma 4 end-to-end CPU smoke test completed successfully on both CME cores.

Dependency

Requires KleidiAI 1.29, which provides the SME2 DOT and MOPA INT2 kernels and the corresponding NxK weight packer.

Signed-off-by: Damien Dooley <damien.dooley@arm.com>
@damdoo001-arm damdoo001-arm changed the title Introduced Packers/Mamtul for QC2W weight and QP8 activations Introduced Packers/Matmul for QC2W weight and QP8 activations Jul 29, 2026
@damdoo001-arm damdoo001-arm changed the title Introduced Packers/Matmul for QC2W weight and QP8 activations Introduced Packers/Matmul for QC2W weights and QP8 activations Jul 29, 2026
Comment thread cmake/DownloadKleidiAI.cmake Outdated
ExternalProject_Add(kleidiai
URL https://gitlab.arm.com/kleidi/kleidiai/-/archive/b87ef9c94f45f11c81a6b1fdaed1b2b45ea58c0c/kleidiai-b87ef9c94f45f11c81a6b1fdaed1b2b45ea58c0c.zip
URL_HASH SHA256=b147799b94c51f5e57492930bfd9e5294fb7ffe44fee1dbcd3f8048adeedd5e3
URL https://github.com/ARM-software/kleidiai/archive/13cd35993d8439143aff1e756a862d366acded0d.zip

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.

Keep the Gitlab url.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Reverted to GitLab

Comment thread test/subgraph/BUILD Outdated
Comment on lines +273 to +274
"//:operator_h",
"//src/configs:config_hdrs",

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.

Can you explain why this change is needed? What do you add that requires this?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The new QP8/QC2W selection tests directly use XNN_FLAG_INLINE_LHS_PACKING from operator.h and xnn_init_qp8_f32_qc2w_gemm_config() from config.h. The latter checks whether the configuration is available before running. I’ve narrowed config_hdrs to the specific config_h target.

Comment thread test/subgraph/fully-connected.cc Outdated
Comment on lines +300 to +301
std::fill(channelwise_zero_point.begin(), channelwise_zero_point.end(),
0.0f);

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.

The constructor of channelwise_zero_point just above already fills the vector with zeros.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Agree. I've removed this. Thanks.

Comment thread test/subgraph/fully-connected.cc Outdated
void TestStaticB(xnn_datatype convert_to = xnn_datatype_invalid,
size_t block_size = no_blockwise) {
size_t block_size = no_blockwise,
bool require_qp8_qc2w = false) {

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.

Change this bool to an enum. If other configs need a special setup it won't scale well to have to add new booleans everytime.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done.

Comment thread DEPS Outdated
},
'third_party/kleidiai/src': {
'url': 'https://gitlab.arm.com/kleidi/kleidiai@v1.25.0',
'url': 'https://github.com/ARM-software/kleidiai.git@v1.29.0',

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.

Keep the Gitlab url.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Reverted to GitLab

Comment thread MODULE.bazel Outdated
strip_prefix = "kleidiai-13cd35993d8439143aff1e756a862d366acded0d",
urls = [
"https://gitlab.arm.com/kleidi/kleidiai/-/archive/b87ef9c94f45f11c81a6b1fdaed1b2b45ea58c0c/kleidiai-b87ef9c94f45f11c81a6b1fdaed1b2b45ea58c0c.zip",
"https://github.com/ARM-software/kleidiai/archive/13cd35993d8439143aff1e756a862d366acded0d.zip",

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.

Keep the Gitlab url.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Reverted to GitLab

Signed-off-by: Damien Dooley <damien.dooley@arm.com>
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