Integrate a KleidiAI SME2 kernel into XNNPACK
Introduction
Prepare the XNNPACK baseline
Understand XNNPACK QD8 and QC4W operand formats
Select a compatible KleidiAI microkernel
Inspect QC4W weight packing for the KleidiAI SME2 kernel
Inspect QD8 activation packing without requantizing for KleidiAI
Inspect SME2 kernel configuration and dispatch
Build and validate the integration
Next Steps
Integrate a KleidiAI SME2 kernel into XNNPACK
Introduction
Prepare the XNNPACK baseline
Understand XNNPACK QD8 and QC4W operand formats
Select a compatible KleidiAI microkernel
Inspect QC4W weight packing for the KleidiAI SME2 kernel
Inspect QD8 activation packing without requantizing for KleidiAI
Inspect SME2 kernel configuration and dispatch
Build and validate the integration
Next Steps
Review frequently asked questions
These FAQs were drafted with an approved AI-assisted workflow and reviewed by Arm contributors before publication. Human technical review remains part of the process so the final page reflects engineering rigor, accuracy, and Arm editorial standards.
Read the name as a description of the output type, operand formats, and instruction family. For this operator, confirm
f16 output, a qai8dxp left-hand side with asymmetric int8 quantization per row, a qsi4cxp right-hand side with signed int4 quantization per channel, and sme2_mopa instructions. Reject the kernel if any part of that contract differs.Avoid a kernel such as
matmul_clamp_f16_qsi8d32p_qai4c32p because it requires symmetric int8 quantization for each block of 32 K values. XNNPACK QD8 uses asymmetric int8 quantization for each row, so you’d have to dequantize and requantize the left-hand side. Instead, select the qai8dxp and qsi4cxp kernel that matches the existing operand contract.Pack the QC4W right-hand side once during
xnn_create_fully_connected_nc_qd8_f16_qc4w. The packed int4 weights, weight sums, per-channel scales, and bias are stored in operator memory or the XNNPACK weights cache so that you can reuse them across inference runs.Use the
pack_lhs and lhs_packed_size helpers added by patch 0003-pack-qd8-lhs-for-kai-sme2.patch in src/qd8-f16-qc4w-gemm/qd8-f16-qc4w-gemm-minmax-16x64c4-neonsme2.c. The patch preserves the QD8 values, stores each row’s negative zero point and scale, and pads K with that row’s zero point. Patch 0004-dispatch-qd8-f16-qc4w-through-kai-sme2.patch queries the kernel parameters and calls these helpers at runtime.Build the Android test binary with KleidiAI enabled, then run the filtered
FULLY_CONNECTED_NC_QD8_F16_QC4W correctness suite on an SME2 device and confirm that all 15 tests pass. Separately, build the //:packing target with xnn_enable_kleidiai=false to verify that the compile-time guards preserve the non-KleidiAI configuration.