From 7d00f65ec37df58eb4fabe04a8b6c4f23522d38a Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Thu, 23 Oct 2025 18:23:37 -0700 Subject: [PATCH] Fix: Disable KleidiAI on systems with SME1 but not SME2 This PR fixes an issue where KleidiAI was incorrectly enabled on systems that support SME1 but not SME2, leading to crashes. The issue was reported in #26377. The fix involves changing the check in onnxruntime/core/mlas/lib/platform.cpp to use HasArm_SME2() instead of HasArm_SME(). This ensures that KleidiAI is only enabled on systems that have SME2 support. --- cmake/deps.txt | 2 +- cmake/vcpkg-ports/cpuinfo/portfile.cmake | 4 ++-- cmake/vcpkg-ports/cpuinfo/vcpkg.json | 4 ++-- onnxruntime/core/mlas/lib/platform.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmake/deps.txt b/cmake/deps.txt index bf76753c1b3c0..22c793705ddeb 100644 --- a/cmake/deps.txt +++ b/cmake/deps.txt @@ -47,7 +47,7 @@ protoc_mac_universal;https://github.com/protocolbuffers/protobuf/releases/downlo psimd;https://github.com/Maratyszcza/psimd/archive/072586a71b55b7f8c584153d223e95687148a900.zip;1f5454b01f06f9656b77e4a5e2e31d7422487013 pthreadpool;https://github.com/google/pthreadpool/archive/dcc9f28589066af0dbd4555579281230abbf74dd.zip;533a77943203ef15ca608bcd9dbe2c94da7451d2 pybind11;https://github.com/pybind/pybind11/archive/refs/tags/v2.13.6.zip;f780292da9db273c8ef06ccf5fd4b623624143e9 -pytorch_cpuinfo;https://github.com/pytorch/cpuinfo/archive/de0ce7c7251372892e53ce9bc891750d2c9a4fd8.zip;c45b8d3619b9bccbd26dc5f657959aee38b18b7a +pytorch_cpuinfo;https://github.com/pytorch/cpuinfo/archive/877328f188a3c7d1fa855871a278eb48d530c4c0.zip;9152d4bf6b8bde9f19b116de3bd8a745097ed9df re2;https://github.com/google/re2/archive/refs/tags/2024-07-02.zip;646e1728269cde7fcef990bf4a8e87b047882e88 safeint;https://github.com/dcleblanc/SafeInt/archive/refs/tags/3.0.28.zip;23f252040ff6cb9f1fd18575b32fa8fb5928daac tensorboard;https://github.com/tensorflow/tensorboard/archive/373eb09e4c5d2b3cc2493f0949dc4be6b6a45e81.zip;67b833913605a4f3f499894ab11528a702c2b381 diff --git a/cmake/vcpkg-ports/cpuinfo/portfile.cmake b/cmake/vcpkg-ports/cpuinfo/portfile.cmake index eeb0007195ca3..80192840ee9b0 100644 --- a/cmake/vcpkg-ports/cpuinfo/portfile.cmake +++ b/cmake/vcpkg-ports/cpuinfo/portfile.cmake @@ -6,8 +6,8 @@ endif() vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO pytorch/cpuinfo - REF de0ce7c7251372892e53ce9bc891750d2c9a4fd8 - SHA512 0fde9210b700d2648d37c8deeb0d5c0d007d8ca5689578dd3bce4c460886b20d7649f0194d2ea06b02238fe9d4f06193599ec3ab5cafb19f1f860b00404264fa + REF 877328f188a3c7d1fa855871a278eb48d530c4c0 + SHA512 b6d5a9ce9996eee3b2f09f39115f7ae178fe4d4814cc35b049a59d04a82228e268aa52d073c307ccb56a427428622940e1c77f004c99851dfca0d3a5d803658b HEAD_REF master PATCHES patch_cpuinfo_h_for_arm64ec.patch diff --git a/cmake/vcpkg-ports/cpuinfo/vcpkg.json b/cmake/vcpkg-ports/cpuinfo/vcpkg.json index ce93591dba5ac..f1ccda72679b1 100644 --- a/cmake/vcpkg-ports/cpuinfo/vcpkg.json +++ b/cmake/vcpkg-ports/cpuinfo/vcpkg.json @@ -1,7 +1,7 @@ { "name": "cpuinfo", - "version-date": "2024-12-09", - "port-version": 3, + "version-date": "2025-10-23", + "port-version": 4, "description": "CPU INFOrmation library (x86/x86-64/ARM/ARM64, Linux/Windows/Android/macOS/iOS)", "homepage": "https://github.com/pytorch/cpuinfo", "license": "BSD-2-Clause", diff --git a/onnxruntime/core/mlas/lib/platform.cpp b/onnxruntime/core/mlas/lib/platform.cpp index 796bfd13b47bf..c4550aab140df 100644 --- a/onnxruntime/core/mlas/lib/platform.cpp +++ b/onnxruntime/core/mlas/lib/platform.cpp @@ -601,7 +601,7 @@ Return Value: } #if defined(USE_KLEIDIAI) && !defined(_MSC_VER) - if(MLAS_CPUIDINFO::GetCPUIDInfo().HasArm_SME()){ + if(MLAS_CPUIDINFO::GetCPUIDInfo().HasArm_SME2()){ this->MlasGemmBatchOverride = ArmKleidiAI::MlasGemmBatch; this->MlasGemmPackBSizeOverride = ArmKleidiAI::MlasGemmPackBSize; this->MlasGemmPackBOverride = ArmKleidiAI::MlasGemmPackB;