[ARM CPU] SVE support for Sgemm kernel#26027
Conversation
@microsoft-github-policy-service agree company=“Fujitsu Research of India Private Ltd” |
7ebfed8 to
ff2a6a4
Compare
|
CC: @edgchen1 , @hariharans29 |
6ee2ffc to
5dd2161
Compare
|
Please address the build failures and please run onnxruntime_mlas_test in your env with your change and report any failures if any here. |
|
|
/azp run Linux QNN CI Pipeline, Win_TRT_Minimal_CUDA_Test_CI, Windows ARM64 QNN CI Pipeline, Windows GPU Doc Gen CI Pipeline, Windows x64 QNN CI Pipeline |
|
Azure Pipelines successfully started running 4 pipeline(s). |
|
Have you tried this on multiple Gemm problem shapes - Please submit comprehensive micro-benchmarks for all SVE platforms. I tried taking this change on a Graviton4 and for a Conv heavy model (which uses Im2Col + SGemm for the Conv implementation), it slows down the model very much - when I build with |
Yes. I have tried on different shapes ,and for large shapes tuning is required. This PR is added as patch to enable sve for gemm kernel and for larger shapes this gemm implementation has to be tuned and we are currently working on that. |
|
Hi @akote123: Any plan to resume this work ? Or at the very least, can you please guide what remains to be done for perf tuning ? |
|
@hariharans29 ,Thank you. We will resume this work .This PR we planned as SVE sgemm enablement work and do performance tuning as future task and contribute |
7f3180f to
2e2c6db
Compare
2e2c6db to
e21b7b5
Compare
|
@hariharans29 ,Thank you Below table shows shape wise timing: GEMM Performance Comparison (time in ms)
|
|
Thanks for this. I have a few PRs ahead of this in the review queue and I will get to this soon ! Meanwhile, I am happy to kick off CI and Copilot reviewing in the background. Also there is another SVE based Gemm implementation coming in (from KleidiAI) - Need to study the overlap and synergize |
|
/azp run Linux QNN CI Pipeline, Win_TRT_Minimal_CUDA_Test_CI, Windows ARM64 QNN CI Pipeline, Windows GPU Doc Gen CI Pipeline, Windows x64 QNN CI Pipeline |
|
No pipelines are associated with this pull request. |
There was a problem hiding this comment.
Pull request overview
This PR adds ARM SVE (Scalable Vector Extension) support for the MLAS SGEMM (single-precision GEMM) path by introducing SVE-specific SGEMM kernels and wiring them into the existing packing/transposition and kernel dispatch logic.
Changes:
- Introduces new SVE SGEMM kernel + helper routines (compute, transpose/pack, load/store, zero-init).
- Integrates runtime dispatch to SVE implementations when
MLAS_USE_SVEis enabled and the CPU reports SVE support. - Updates the MLAS CMake wiring to compile and include the new SVE SGEMM source.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| onnxruntime/core/mlas/lib/sve/sgemm_sve.cpp | Adds SVE SGEMM kernels plus SVE packing/transpose helpers. |
| onnxruntime/core/mlas/lib/sve/mlasi_sve.h | Declares new SVE SGEMM/packing entrypoints and constants. |
| onnxruntime/core/mlas/lib/sgemm.cpp | Routes packing/transposition and kernel dispatch to SVE at runtime when available. |
| onnxruntime/core/mlas/lib/mlasi.h | Extends the fallback CPUID info class (non-ORT build) with SVE-related capability accessors/state. |
| cmake/onnxruntime_mlas.cmake | Adds the new SVE SGEMM source file and compilation flags to the build. |
Comments suppressed due to low confidence (1)
onnxruntime/core/mlas/lib/mlasi.h:204
- The BUILD_MLAS_NO_ONNXRUNTIME fallback CPUID class now defines HasArmSVE() (twice) but the rest of MLAS uses HasArmSve(). This introduces a duplicate method definition and will also break builds that compile MLAS outside ONNX Runtime. Rename/restore the method to HasArmSve() (single definition) to match existing call sites.
// ARM
bool HasArmNeonDot() const { return has_arm_neon_dot_; }
bool HasArmSVE() const { return has_arm_sve_; }
bool HasFp16VectorAcceleration() const { return has_fp16_; }
uint32_t GetCurrentCoreIdx() const { return 0xFFFFFFFF; }
int32_t GetCurrentUarch() const { return -1; }
int32_t GetCoreUarch(uint32_t coreId) const { return -1; }
bool IsCoreArmv8NarrowLd(uint32_t coreId) const { return false; }
bool IsCurrentCoreArmv8NarrowLd() const { return false; }
bool HasArmNeon_I8MM() const { return has_arm_neon_i8mm_; }
bool HasArmSVE() const { return has_arm_sve_; }
bool HasArmSVE_I8MM() const { return has_arm_sve_i8mm_; }
bool HasArmNeon_BF16() const { return has_arm_neon_bf16_; }
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Ok. Thank you hariharans29. |
99f8800 to
3940ea6
Compare
|
Please update/resolve the comments if you are addressing them in a commit. It is very hard to gauge which comments have been addressed just by looking at the commit. Please address the conflict too so that the next run can be kicked off. |
|
@hariharans29,Resolved all the comments and merge conflicts . |
Hi Aruna - I still see some comments from sept 2025 and I still see conflicts too. Can you please take a look ? |
|
Btw - since KleidiAI is also supporting SVE based SGemm, is this PR needed ? Do you know the perf compairson between the KleidiAI SVE SGemm implementation vs this implementation ? |
hariharans29, |
Thanks @akote123. We already have an existing dependency on KleidiAI - please hold off of any more updates/effort to this PR. I will have to check internally what the guidance is from my leadership and get back. |
|
@hariharans29,During benchmarking on AWS Graviton4, I observed that the Kleidi-sgemm path is currently slower than the NEON baseline for the tested workload(T5,Jina,E5). |
Hi @hariharans29 ,just following up on this—Any update on this ? Please let me know if any updates or further changes are needed from my side |
Thanks @akote123 for the follow up. Let me get back by the end of this week. |
Thank you @hariharans29. |
|
Hi @akote123 - I would like to run this by one of our contacts to get more feedback. Could you please give me one more week ? One thought I had was to see if we could use the Mlas Backend Kernel Selector (with default to off for sve gemm) ? I feel like we have limited perf data to turn this on by default. What are your thoughts on this ? |
@hariharans29, Thank you for update. |
Sorry - re-visiting this just now. Do we have perf data across a large bunch of representative M,N,K shapes for SVE 256 and 512 - or have you measured perf only across the 4 models listed in the PR description ? Personally, I am leaning towards including SVE SGemm support in MLAS and defaulting it to off (via the Mlas backend kernel selector) and allowing the user to opt-in to using this feature - atleast for 1 or 2 releases. We can announce the feature via release notes and get perf feedback. We can turn it on my default in a future release once we are satisifed it hasn't broken anything. |
|
Could you please re-base with main (and integrate with the Mlas backend kernel selector) ? Once done, I will prioritize merging this - thanks |
Sure .I will update with patch to integrate with the Mlas backend kernel selector. |
Update session option for packing kernel
759bcce to
6c52be6
Compare
|
@hariharans29,
|
This PR ports the SGEMM kernel and associated packing kernels to the ARM SVE (Scalable Vector Extension) backend. Specifically, it introduces new wrapper implementations for SVE functions in lib/sve/sgemm_sve.cpp and integrates these wrappers within the existing kernel implementations.
Motivation and Context
This work is part of an ongoing effort to enhance ONNX Runtime's performance and architecture-awareness on ARM platforms. By leveraging ARM SVE, we aim to unlock better computational efficiency and scalability on modern ARM hardware.
This PR builds upon and extends the SVE work introduced in PR #25238
Performance Analysis:

Results are captured from sve 256,128 and SVE 512 supported machines.
This PR is a joint contribution by: