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

build: enable DeepSeek V4 engine on aarch64 Linux

andres-gb104eadd93847cf
diff --git a/c/Makefile b/c/Makefile
index 6ab486bf..79770dca 100644
--- a/c/Makefile
+++ b/c/Makefile
@@ -200,14 +200,21 @@ PYTHON ?= python3
endif
CUDA_OBJ =
-# DeepSeek V4 is a separate x86-64 runtime. Portable infrastructure tests run
-# everywhere; the engine and token-exact fixture run only on Linux/Windows.
+# DeepSeek V4 is a separate x86-64/aarch64 runtime. Portable infrastructure
+# tests run everywhere; the engine and token-exact fixture run on x86-64
+# Linux/Windows and aarch64 Linux. SIMD fast paths are gated per-feature
+# inside the sources, so a plain armv8-a build stays correct.
COLI_V4_SUPPORTED :=
ifneq (,$(X86_64))
ifneq (,$(IS_WIN)$(LINUX))
COLI_V4_SUPPORTED := 1
endif
endif
+ifneq (,$(AARCH64))
+ifneq (,$(LINUX))
+COLI_V4_SUPPORTED := 1
+endif
+endif
V4_INFRA_TEST_BINS = tests/test_expert_store_ops$(EXE) \
tests/test_safetensors_index$(EXE) tests/test_native_quant$(EXE) \
@@ -303,11 +310,11 @@ deepseek-v4-oracle: deepseek-v4
--check-dspark
else
deepseek-v4 deepseek-v4-oracle:
- @echo "$@ is supported only on x86-64 Linux and Windows/MSYS2" >&2; exit 1
+ @echo "$@ is supported only on x86-64/aarch64 Linux and Windows/MSYS2" >&2; exit 1
deepseek-v4-clean:
@:
deepseek-v4-tiny-check:
- @echo "SKIP deepseek-v4-tiny-check: V4 runtime requires x86-64 Linux or Windows/MSYS2"
+ @echo "SKIP deepseek-v4-tiny-check: V4 runtime requires x86-64/aarch64 Linux or Windows/MSYS2"
endif
# phony targets β€” 'glm' kept for backward compatibility
diff --git a/c/Makefile.deepseek-v4 b/c/Makefile.deepseek-v4
index 75ff0d87..af79676b 100644
--- a/c/Makefile.deepseek-v4
+++ b/c/Makefile.deepseek-v4
@@ -1,4 +1,4 @@
-# DeepSeek V4 amalgamation build β€” x86-64 Linux and Windows/MSYS2 only.
+# DeepSeek V4 amalgamation build β€” x86-64/aarch64 Linux and Windows/MSYS2 only.
# Uses GNU ld -Wl,--wrap and gcc -march; do not invoke from macOS/PowerPC
# `make check` (the parent Makefile gates COLI_V4_SUPPORTED).
@@ -16,13 +16,13 @@ COLI_V4_OK :=
ifeq ($(IS_WIN),1)
COLI_V4_OK := 1
else ifeq ($(UNAME_S),Linux)
-ifneq (,$(filter x86_64 amd64,$(UNAME_M)))
+ifneq (,$(filter x86_64 amd64 aarch64 arm64,$(UNAME_M)))
COLI_V4_OK := 1
endif
endif
ifneq ($(COLI_V4_OK),1)
-$(error Makefile.deepseek-v4 supports only x86-64 Linux and Windows/MSYS2)
+$(error Makefile.deepseek-v4 supports only x86-64/aarch64 Linux and Windows/MSYS2)
endif
ifneq ($(IS_WIN),)
diff --git a/c/native_quant_batch_avx512.c b/c/native_quant_batch_avx512.c
index 4a0e051a..e83de669 100644
--- a/c/native_quant_batch_avx512.c
+++ b/c/native_quant_batch_avx512.c
@@ -1,4 +1,6 @@
+#ifdef __AVX512F__
#include <immintrin.h>
+#endif
#define coli_fp8_matmul_batch_ref coli_fp8_matmul_batch_baseline_v6
/* ---- begin inlined native_quant_batch_interleaved_v4.c ---- */
diff --git a/c/native_quant_fp4_rows16.c b/c/native_quant_fp4_rows16.c
index 0c1773d9..5be408a5 100644
--- a/c/native_quant_fp4_rows16.c
+++ b/c/native_quant_fp4_rows16.c
@@ -1,6 +1,8 @@
#include "native_quant_fp4_rows16.h"
+#ifdef __AVX512F__
#include <immintrin.h>
+#endif
#include <stdint.h>
#include <stdlib.h>