From db8ea663c7a53e5f5afc8a5341f6add9e721d649 Mon Sep 17 00:00:00 2001 From: Martin Klacer Date: Fri, 6 Mar 2026 16:45:01 +0000 Subject: [PATCH 1/3] kleidiai: add cpu feature detection to CI run script Signed-off-by: Martin Klacer Change-Id: I663adc3a7691a98e7dac5488962c13cc344f034a --- ci/run.sh | 56 ++++++++++++++++++++++-- requirements/requirements-tool_bench.txt | 3 +- 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/ci/run.sh b/ci/run.sh index 96755ea13e..dc62f3b251 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -135,14 +135,62 @@ fi if [ -n "${GG_BUILD_KLEIDIAI}" ]; then echo ">>===== Enabling KleidiAI support" + # Detect candidate arch options for the current CPU + I8MM="" + FP16="" + SME="" + SVE="" + if [ "$(uname -s)" == "Darwin" ]; then + # Detect i8mm + if [ $(sysctl -n hw.optional.arm.FEAT_I8MM) -eq 1 ]; then + I8MM="+i8mm" + fi + # Detect FP16 + if [ $(sysctl -n hw.optional.arm.FEAT_FP16) -eq 1 ]; then + FP16="+fp16" + fi + # Detect SME version + if [ $(sysctl -n hw.optional.arm.FEAT_SME2) -eq 1 ]; then + SME="+sme2" + elif [ $(sysctl -n hw.optional.arm.FEAT_SME) -eq 1 ]; then + SME="+sme" + fi + # Disable SVE on Darwin + SVE="+nosve" + elif [ "$(uname -s)" == "Linux" ]; then + # Detect i8mm + if grep "i8mm" /proc/cpuinfo -q; then + I8MM="+i8mm" + fi + # Detect FP16 + if grep "fphp" /proc/cpuinfo -q; then + FP16="+fp16" + fi + # Detect SME version + if grep "sme2" /proc/cpuinfo -q; then + SME="+sme2" + elif grep "sme" /proc/cpuinfo -q; then + SME="+sme" + fi + # Detect SVE version if allowed + if [ -z ${GG_BUILD_NO_SVE} ]; then + if grep "sve2" /proc/cpuinfo -q; then + SVE="+sve2" + elif grep "sve" /proc/cpuinfo -q; then + SVE="+sve" + fi + + fi + fi + + # Configure usable candidates based on CPU options CANDIDATES=( - "armv9-a+dotprod+i8mm+sve2" - "armv9-a+dotprod+i8mm" - "armv8.6-a+dotprod+i8mm" + "armv9-a+dotprod${FP16}${I8MM}${SME}${SVE}" + "armv8.6-a+dotprod${FP16}${I8MM}${SME}${SVE}" + "armv8.2-a+dotprod${FP16}${I8MM}${SME}${SVE}" "armv8.2-a+dotprod" ) CPU="" - for cpu in "${CANDIDATES[@]}"; do if echo 'int main(){}' | ${CXX:-c++} -march="$cpu" -x c++ - -c -o /dev/null >/dev/null 2>&1; then CPU="$cpu" diff --git a/requirements/requirements-tool_bench.txt b/requirements/requirements-tool_bench.txt index 3bb74fb9d0..94e28006f7 100644 --- a/requirements/requirements-tool_bench.txt +++ b/requirements/requirements-tool_bench.txt @@ -1,7 +1,8 @@ aiohttp~=3.9.3 pytest~=8.3.3 huggingface_hub>=0.34.0,<1.0 -matplotlib~=3.10.0 +matplotlib~=3.10.0; python_version>="3.10" +matplotlib>=3.9.0; python_version<"3.10" numpy~=1.26.4 openai~=2.14.0 pandas~=2.2.3 From b1f856af724afde2380223e1ae6e05399c6a8fe2 Mon Sep 17 00:00:00 2001 From: Martin Klacer Date: Wed, 11 Mar 2026 15:24:43 +0000 Subject: [PATCH 2/3] kleidiai: revert unrelated requirements change Signed-off-by: Martin Klacer --- requirements/requirements-tool_bench.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/requirements/requirements-tool_bench.txt b/requirements/requirements-tool_bench.txt index 94e28006f7..3bb74fb9d0 100644 --- a/requirements/requirements-tool_bench.txt +++ b/requirements/requirements-tool_bench.txt @@ -1,8 +1,7 @@ aiohttp~=3.9.3 pytest~=8.3.3 huggingface_hub>=0.34.0,<1.0 -matplotlib~=3.10.0; python_version>="3.10" -matplotlib>=3.9.0; python_version<"3.10" +matplotlib~=3.10.0 numpy~=1.26.4 openai~=2.14.0 pandas~=2.2.3 From 07a6fd8775dbdd89b93e3b97a3fe00a95ba764ae Mon Sep 17 00:00:00 2001 From: Martin Klacer Date: Tue, 24 Mar 2026 17:24:41 +0000 Subject: [PATCH 3/3] kleidiai: removed cpu feature detection from CI run script * As per the maintainers' suggestion, removed cpu feature detection from CI run script as CMake handles it already Signed-off-by: Martin Klacer --- ci/run.sh | 78 +------------------------------------------------------ 1 file changed, 1 insertion(+), 77 deletions(-) diff --git a/ci/run.sh b/ci/run.sh index dc62f3b251..ac6c40aa56 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -134,83 +134,7 @@ fi if [ -n "${GG_BUILD_KLEIDIAI}" ]; then echo ">>===== Enabling KleidiAI support" - - # Detect candidate arch options for the current CPU - I8MM="" - FP16="" - SME="" - SVE="" - if [ "$(uname -s)" == "Darwin" ]; then - # Detect i8mm - if [ $(sysctl -n hw.optional.arm.FEAT_I8MM) -eq 1 ]; then - I8MM="+i8mm" - fi - # Detect FP16 - if [ $(sysctl -n hw.optional.arm.FEAT_FP16) -eq 1 ]; then - FP16="+fp16" - fi - # Detect SME version - if [ $(sysctl -n hw.optional.arm.FEAT_SME2) -eq 1 ]; then - SME="+sme2" - elif [ $(sysctl -n hw.optional.arm.FEAT_SME) -eq 1 ]; then - SME="+sme" - fi - # Disable SVE on Darwin - SVE="+nosve" - elif [ "$(uname -s)" == "Linux" ]; then - # Detect i8mm - if grep "i8mm" /proc/cpuinfo -q; then - I8MM="+i8mm" - fi - # Detect FP16 - if grep "fphp" /proc/cpuinfo -q; then - FP16="+fp16" - fi - # Detect SME version - if grep "sme2" /proc/cpuinfo -q; then - SME="+sme2" - elif grep "sme" /proc/cpuinfo -q; then - SME="+sme" - fi - # Detect SVE version if allowed - if [ -z ${GG_BUILD_NO_SVE} ]; then - if grep "sve2" /proc/cpuinfo -q; then - SVE="+sve2" - elif grep "sve" /proc/cpuinfo -q; then - SVE="+sve" - fi - - fi - fi - - # Configure usable candidates based on CPU options - CANDIDATES=( - "armv9-a+dotprod${FP16}${I8MM}${SME}${SVE}" - "armv8.6-a+dotprod${FP16}${I8MM}${SME}${SVE}" - "armv8.2-a+dotprod${FP16}${I8MM}${SME}${SVE}" - "armv8.2-a+dotprod" - ) - CPU="" - for cpu in "${CANDIDATES[@]}"; do - if echo 'int main(){}' | ${CXX:-c++} -march="$cpu" -x c++ - -c -o /dev/null >/dev/null 2>&1; then - CPU="$cpu" - break - fi - done - - if [ -z "$CPU" ]; then - echo "ERROR: None of the required ARM baselines (armv9/armv8.6/armv8.2 + dotprod) are supported by this compiler." - exit 1 - fi - - echo ">>===== Using ARM baseline: ${CPU}" - - CMAKE_EXTRA="${CMAKE_EXTRA:+$CMAKE_EXTRA } \ - -DGGML_NATIVE=OFF \ - -DGGML_CPU_KLEIDIAI=ON \ - -DGGML_CPU_AARCH64=ON \ - -DGGML_CPU_ARM_ARCH=${CPU} \ - -DBUILD_SHARED_LIBS=OFF" + CMAKE_EXTRA="${CMAKE_EXTRA:+$CMAKE_EXTRA } -DGGML_CPU_KLEIDIAI=ON" fi ## helpers