Skip to content

Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦

C

ci: prove the NEON FP4 arms bit-exact against the scalar arm on the ARM runner

JustVugg4087d5a3e249
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 1669a01b..1471b14d 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -1301,6 +1301,12 @@ jobs:
run: pip install -r c/tools/oracle-requirements.txt
- name: Build every engine (NEON branches must compile)
run: make -C c colibri inkling kimi_k3 olmoe
+ - name: "DeepSeek V4 FP4 expert kernels: NEON arm bit-exact against the scalar arm (#1696)"
+ run: |
+ cd c
+ # batch (prefill) and S=1 (the matvec the decode uses)
+ bash tools/bench_fp4_matmul.sh 32 256 128 1
+ bash tools/bench_fp4_matmul.sh 1 256 128 1
- name: Integer-kernel exactness, NEON branches live (#1081)
run: |
cd c
diff --git a/c/tools/bench_fp4_matmul.sh b/c/tools/bench_fp4_matmul.sh
index 37df8b79..fd7fb8e9 100755
--- a/c/tools/bench_fp4_matmul.sh
+++ b/c/tools/bench_fp4_matmul.sh
@@ -19,9 +19,9 @@ SCALAR=""
AB=1
case "$(uname -m)" in
x86_64*|amd64) ARCH=x86-64-v3 ; SCALAR="-mno-avx2" ;;
- arm64|aarch64) AB=0 ;; # no SIMD arm in this kernel on NEON yet (#1696):
- # arm64 builds only the scalar arm; this is the
- # baseline a future NEON arm must beat
+ arm64|aarch64) SCALAR="-march=armv8-a+nosimd" ;; # +nosimd undefines __ARM_NEON:
+ # the scalar #else arm, against which
+ # the NEON arm must be bit-exact (#1696)
*) echo "unsupported arch $(uname -m)"; exit 1 ;;
esac
@@ -41,14 +41,15 @@ $CC /tmp/bk_unit_simd.o /tmp/bk_main_simd.o -o /tmp/bk_simd -lm -fopenmp
REF=/tmp/bk_ref.f32
rm -f "$REF"
if [ "$AB" = 1 ]; then
- echo "== building scalar-arm unit (-mno-avx2) =="
+ echo "== building scalar-arm unit ($SCALAR) =="
$CC $COMMON -march=$ARCH $SCALAR $UNIT -c deepseek_v4.c -o /tmp/bk_unit_sca.o
$CC $COMMON -march=$ARCH $SCALAR -c tools/bench_fp4_matmul.c -o /tmp/bk_main_sca.o
$CC /tmp/bk_unit_sca.o /tmp/bk_main_sca.o -o /tmp/bk_sca -lm -fopenmp
echo "== SIMD arm (writes reference) =="
/tmp/bk_simd "$S" "$I" "$O" "$IT" "$REF"
echo "== scalar arm (compares bit-exactly + times) =="
- /tmp/bk_sca "$S" "$I" "$O" "$IT" "$REF"
+ /tmp/bk_sca "$S" "$I" "$O" "$IT" "$REF" | tee /tmp/bk_sca.log
+ grep -q "BITEXACT vs .*: IDENTICAL" /tmp/bk_sca.log || { echo "FAIL: SIMD and scalar arms differ"; exit 1; }
echo "Done. Repeat /tmp/bk_simd ... to re-verify bit-exactness."
else
echo "== no SIMD arm on this arch/kernel yet (#1696); scalar baseline only =="