Skip to content

KleidiAI SVE2p1 halfgemm kernel integrated - #32670

Draft
Melike Kaptan (melkap01-Arm) wants to merge 2 commits into
microsoft:mainfrom
melkap01-Arm:SVE2p1_kernel_integration
Draft

Melike Kaptan (melkap01-Arm) wants to merge 2 commits into
microsoft:mainfrom
melkap01-Arm:SVE2p1_kernel_integration

Conversation

@melkap01-Arm

Copy link
Copy Markdown
Contributor

Description

This PR adds SVE2.1 acceleration for MLAS FP16 HalfGemm using the KleidiAI 6x16vs dot-product kernel.
The change:

Updates KleidiAI from v1.20.0 to v1.30.0.
Adds native SVE2.1 capability detection:

Linux through HWCAP2_SVE2P1.
Windows through PF_ARM_SVE2_1_INSTRUCTIONS_AVAILABLE.

Preserves the architectural relationship that SVE2.1 implies SVE.
Enables only the HalfGemm overrides on SVE2.1 systems; other KleidiAI GEMM and convolution overrides remain restricted to SME/SME2.
Preserves SME/SME2 priority when both SME and SVE2.1 are available.

Motivation and Context

The new backend uses:

MatMul kernel: kai_matmul_clamp_f16_f16_f16p16vsx2bf16_6x16vs_sve2p1_dot
RHS packer: kai_rhs_pack_kxn_x16p16vsx2bx16_x16_x16_sve

Both supported B paths are covered:

Runtime packing of ordinary row-major B, including optional bias.
Direct consumption of backend-native prepacked B.

Execution is divided into six-row M tiles and vector-length-dependent N tiles, with support for M/N tails and MLAS thread-pool parallelism.

Copilot AI balanced review requested due to automatic review settings September 17, 2026 09:20
@melkap01-Arm
Melike Kaptan (melkap01-Arm) marked this pull request as draft September 17, 2026 09:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Native-packed batched execution can reject a later vector-length mismatch after earlier outputs have already been modified.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds KleidiAI SVE2.1 acceleration for MLAS FP16 HalfGemm while retaining SME/SME2 priority.

Changes:

  • Adds Linux/Windows SVE2.1 detection and dispatch.
  • Integrates SVE2.1 packing, execution, and vector-length handling.
  • Updates KleidiAI and adds targeted tests.
File summaries
File Description
cmake/deps.txt Updates KleidiAI to v1.30.0.
onnxruntime/core/common/cpuid_info.cc Detects SVE2.1 capabilities.
onnxruntime/core/common/cpuid_info.h Exposes SVE2.1 capability state.
onnxruntime/core/mlas/lib/platform.cpp Enables HalfGemm overrides on SVE2.1.
onnxruntime/core/mlas/lib/kleidiai/halfgemm_kleidiai.cpp Implements SVE2.1 packing and execution.
onnxruntime/core/mlas/lib/kleidiai/mlasi_kleidiai.h Declares test hooks.
onnxruntime/test/mlas/unittest/test_halfgemm.cpp Adds SVE2.1 kernel tests.
onnxruntime/test/mlas/unittest/test_halfgemm.h Adds stride, packing, and canary helpers.
Review details
  • Files reviewed: 8/8 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +468 to +469
if (!ReadSve2p1PackedRhsMetadata(data.B, rhs_vector_length, rhs_packed)) {
return false;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Signed-off-by: melkap01 <melike.kaptan@arm.com>
Signed-off-by: melkap01 <melike.kaptan@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