From 7713192434d2cf2b5547bc1b57a04ed42fcebdad Mon Sep 17 00:00:00 2001 From: 0z5a Date: Sat, 24 Oct 2026 22:10:26 +0200 Subject: [PATCH] fix(cutile): build the reference-cpu examples on aarch64 run_examples.sh always enables reference-cpu, which pulls in candle. candle's gemm-f16 uses FP16 arithmetic instructions (fmla .8h) that the generic aarch64 target does not enable, so on aarch64 every example fails to build ("instruction requires: fullfp16"), not only the two that need the CPU reference. When the CPU reports asimdhp, add -C target-feature=+fp16 to RUSTFLAGS: only that extension, so the rest of the build stays generic. Without asimdhp, drop reference-cpu and skip async_gemm and flash_attention. Signed-off-by: 0z5a --- cutile-rs/scripts/run_examples.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/cutile-rs/scripts/run_examples.sh b/cutile-rs/scripts/run_examples.sh index 92bfa695bd..f171f1c6e5 100755 --- a/cutile-rs/scripts/run_examples.sh +++ b/cutile-rs/scripts/run_examples.sh @@ -16,6 +16,23 @@ while [[ $# -gt 0 ]]; do esac done +# reference-cpu pulls in candle, whose gemm-f16 kernels use FP16 arithmetic +# instructions that the generic aarch64 target does not enable. Turn on just +# that extension when this CPU has it (asimdhp); otherwise build without +# reference-cpu and skip the examples that require it. +SKIP_EXAMPLES=() +if [[ "$(uname -m)" == "aarch64" && "$EXTRA_FEATURES" == *reference-cpu* ]]; then + if grep -qw asimdhp /proc/cpuinfo; then + export RUSTFLAGS="${RUSTFLAGS:+$RUSTFLAGS }-C target-feature=+fp16" + else + features="${EXTRA_FEATURES#--features }" + features=$(tr ',' '\n' <<< "$features" | grep -vx 'reference-cpu' | paste -sd, -) + EXTRA_FEATURES="${features:+--features $features}" + SKIP_EXAMPLES=(async_gemm flash_attention) + echo "No FP16 arithmetic on this aarch64 CPU: skipping the reference-cpu examples" + fi +fi + if [[ -n "$EXTRA_FEATURES" ]]; then print_header "Running examples ($EXTRA_FEATURES)" else @@ -28,7 +45,7 @@ run_step \ echo -e "${YELLOW}>>> Running cutile-examples (GPU)${NC}" cd "$REPO_ROOT/cutile-examples" || exit 1 -run_examples "$REPO_ROOT/cutile-examples/examples" $EXTRA_FEATURES +run_examples "$REPO_ROOT/cutile-examples/examples" $EXTRA_FEATURES "${SKIP_EXAMPLES[@]}" print_summary_and_exit \ "All supported examples passed (see skipped examples above)." \