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

tests: sanitizer runs and inkling's tier gate on AVX-512 runners

JustVuggdf9900d013f0
diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml
index 3d5f2bf6..1940b3ec 100644
--- a/.github/workflows/check.yml
+++ b/.github/workflows/check.yml
@@ -104,9 +104,9 @@ jobs:
run: |
make -C c clean >/dev/null
make -C c mimo EXTRA_CFLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer -g"
- ASAN_OPTIONS=detect_leaks=0 UBSAN_OPTIONS=halt_on_error=1:print_stacktrace=1 \
+ ASAN_OPTIONS=detect_leaks=0:detect_stack_use_after_return=0 UBSAN_OPTIONS=halt_on_error=1:print_stacktrace=1 \
python c/tests/mimo_tiny_harness.py --binary c/mimo --fixture c/mimo_tiny
- cd c && ASAN_OPTIONS=detect_leaks=0 UBSAN_OPTIONS=halt_on_error=1:print_stacktrace=1 \
+ cd c && ASAN_OPTIONS=detect_leaks=0:detect_stack_use_after_return=0 UBSAN_OPTIONS=halt_on_error=1:print_stacktrace=1 \
python -m unittest tests.test_mimo_prefix_serve tests.test_brio_serve.MimoBrioServe \
tests.test_brio_api.MimoBrioEndToEnd
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 036a071f..fcca6c41 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -652,7 +652,7 @@ jobs:
make clean >/dev/null 2>&1 || true
make qwen36 EXTRA_CFLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer -g"
for fx in qwen36_tiny qwen38_2p4t_tiny; do
- ASAN_OPTIONS=detect_leaks=0 UBSAN_OPTIONS=print_stacktrace=1 \
+ ASAN_OPTIONS=detect_leaks=0:detect_stack_use_after_return=0 UBSAN_OPTIONS=print_stacktrace=1 \
COLI_DENSE_I8=0 SNAP=${fx}_c PILOT=1 WIDE=2 \
./qwen36 1 8 $fx/ref_full.json > san.log 2>&1 || true
if grep -qE "ERROR: AddressSanitizer|runtime error:" san.log; then
@@ -663,7 +663,7 @@ jobs:
# Same sanitized binary on hostile weights: an all-NaN router row and an
# oversized e_score_correction_bias must degrade or be refused, never
# reach the heap.
- ASAN_OPTIONS=detect_leaks=0 QWEN36_TINY_C=qwen36_tiny_c \
+ ASAN_OPTIONS=detect_leaks=0:detect_stack_use_after_return=0 QWEN36_TINY_C=qwen36_tiny_c \
QWEN36_TINY_REF=qwen36_tiny/ref_full.json \
python3 -m unittest -v tests.test_qwen36_hostile_weights
- name: KV prefix reuse is token-identical (serve, several turns)
@@ -1063,11 +1063,11 @@ jobs:
run: |
cd c
make -B qwen38 EXTRA_CFLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer -g"
- ASAN_OPTIONS=detect_leaks=0 UBSAN_OPTIONS=print_stacktrace=1 \
+ ASAN_OPTIONS=detect_leaks=0:detect_stack_use_after_return=0 UBSAN_OPTIONS=print_stacktrace=1 \
OMP_NUM_THREADS=2 SNAP=./qwen38_tiny \
./qwen38 1 8 ./qwen38_tiny/ref.json > qwen38-san.log 2>&1
# the int4-g64 sidecar's load and matmul, evicting at cap 1
- ASAN_OPTIONS=detect_leaks=0 UBSAN_OPTIONS=print_stacktrace=1 \
+ ASAN_OPTIONS=detect_leaks=0:detect_stack_use_after_return=0 UBSAN_OPTIONS=print_stacktrace=1 \
Q38_EXPERT_INT4=1 OMP_NUM_THREADS=2 SNAP=./qwen38_tiny_int4 \
./qwen38 1 8 ./qwen38_tiny_int4/ref_int4.json > qwen38-san-int4.log 2>&1
if grep -qE "ERROR: AddressSanitizer|runtime error:" qwen38-san.log qwen38-san-int4.log; then
@@ -1077,7 +1077,7 @@ jobs:
grep -q "Matching tokens: 8/8" qwen38-san.log
grep -q "Matching tokens: 8/8" qwen38-san-int4.log
# the MTP head, the S=2 verify and the rollback on every fixture kind
- ASAN_OPTIONS=detect_leaks=0 UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 \
+ ASAN_OPTIONS=detect_leaks=0:detect_stack_use_after_return=0 UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 \
python3 tests/qwen38_mtp_harness.py --engine ./qwen38 --bf16 ./qwen38_tiny_mtp \
--fp8 ./qwen38_tiny_fp8_mtp --int4 ./qwen38_tiny_int4_mtp
- name: Refuse config and tensor-shape disagreement
@@ -1147,7 +1147,7 @@ jobs:
run: |
cd c
make -B qwenimage EXTRA_CFLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer -g"
- export ASAN_OPTIONS=detect_leaks=0 UBSAN_OPTIONS=print_stacktrace=1 OMP_NUM_THREADS=2
+ export ASAN_OPTIONS=detect_leaks=0:detect_stack_use_after_return=0 UBSAN_OPTIONS=print_stacktrace=1 OMP_NUM_THREADS=2
COLI_IMG_BITS=16 COLI_IMG_ACT8=0 ./qwenimage --model qwenimage_tiny --ref qwenimage_tiny/ref > qwenimage-san.log 2>&1 || true
QWENIMAGE_TINY=qwenimage_tiny python3 -m unittest tests.test_qwenimage_engine_serve >> qwenimage-san.log 2>&1 || true
if grep -qE "ERROR: AddressSanitizer|runtime error:" qwenimage-san.log; then
diff --git a/c/Makefile b/c/Makefile
index d92f5255..bcb7136d 100644
--- a/c/Makefile
+++ b/c/Makefile
@@ -2630,7 +2630,11 @@ bench-omp-grain: tests/bench_omp_grain.c
# that a test run does not need.
ASAN_CFLAGS = -O1 -g -fno-omit-frame-pointer -fsanitize=address,undefined
ASAN_LDFLAGS = -fsanitize=address,undefined
-ASAN_ENV = ASAN_OPTIONS=detect_leaks=0 UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1
+# detect_stack_use_after_return=0: ASan's fake stack frames are only 32-byte aligned,
+# and on an AVX-512 host (-march=native) GCC keeps 64-byte aligned locals there and
+# stores them with vmovdqa64, which faults (inkling's matmul_w on a Zen 4 runner).
+# Every other check stays on; this file's sanitizer runs and the CI's use the same.
+ASAN_ENV = ASAN_OPTIONS=detect_leaks=0:detect_stack_use_after_return=0 UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1
# `make clean` first is not optional: tools/clean.py had to be fixed to remove
# Unix test binaries at all (it globbed only *.exe), and without that step this
diff --git a/c/tests/vulkan_engines.sh b/c/tests/vulkan_engines.sh
index 62bf31a2..ca311ad2 100755
--- a/c/tests/vulkan_engines.sh
+++ b/c/tests/vulkan_engines.sh
@@ -28,6 +28,11 @@ PY=${PY:-python3}
fail() { echo "FAIL: $*"; exit 1; }
+# Every sanitized run below sets ASAN_OPTIONS with detect_stack_use_after_return=0:
+# ASan's fake stack frames are only 32-byte aligned, and on an AVX-512 runner
+# (-march=native) GCC keeps 64-byte aligned locals there and stores them with
+# vmovdqa64, which faults (c/Makefile, ASAN_ENV, has the details).
+
# vk_count <engine> <log>: N from the last "[VK] <engine>: N matmuls on the GPU" line
vk_count() {
local n
@@ -84,7 +89,12 @@ tier_failed() {
dense_where() {
local eng=$1 log=$2 tag=$3 where; shift 3
if grep -qa "^\[VK\] $eng: device ready, dense matrices on the device" "$log"; then
- need_gpu "$eng" "$log" "$tag"; where=device
+ # inkling places none when the host keeps them by design (bf16 weights under the
+ # AVX512-BF16 dot, which rounds the activations as the shader does not): its
+ # placement line then says "0 resident matrices go to the GPU", and the count is
+ # not required, as in family_inkling_olmoe's own bf16 check.
+ grep -qa "^\[VK\] $eng: 0 resident matrices go to the GPU" "$log" || need_gpu "$eng" "$log" "$tag"
+ where=device
else
[ "$(vk_count "$eng" "$log")" = 0 ] || { cat "$log"; fail "$tag: dense matmuls ran on the device with the trunk on the CPU"; }
where=CPU
@@ -262,7 +272,7 @@ family_qwen_sanitize() {
san() { # <engine> <tag> <env and argv...>
local eng=$1 tag=$2; shift 2
rm -f tier.usage
- env ASAN_OPTIONS=detect_leaks=0 UBSAN_OPTIONS=print_stacktrace=1 OMP_NUM_THREADS=2 \
+ env ASAN_OPTIONS=detect_leaks=0:detect_stack_use_after_return=0 UBSAN_OPTIONS=print_stacktrace=1 OMP_NUM_THREADS=2 \
COLI_USAGE=tier.usage COLI_VK_TIER_SYNC=1 COLI_VULKAN=1 "$@" > san.log 2>&1 || true
if grep -qE "ERROR: AddressSanitizer|runtime error:" san.log; then cat san.log; fail "$tag: sanitizer diagnostic"; fi
[ "$(tier_count "$eng" san.log)" -gt 0 ] || { cat san.log; fail "$tag: no routed expert ran on the device"; }
@@ -469,7 +479,7 @@ family_inkling_olmoe_sanitize() {
san_io() { # <engine> <tag> <env and argv...>; KEEP=1 keeps the history of the run before
local eng=$1 tag=$2; shift 2
[ "${KEEP:-0}" = 1 ] || rm -f tier.usage
- env ASAN_OPTIONS=detect_leaks=0 UBSAN_OPTIONS=print_stacktrace=1 OMP_NUM_THREADS=2 \
+ env ASAN_OPTIONS=detect_leaks=0:detect_stack_use_after_return=0 UBSAN_OPTIONS=print_stacktrace=1 OMP_NUM_THREADS=2 \
COLI_USAGE=tier.usage COLI_VK_TIER_SYNC=1 COLI_VULKAN=1 "$@" > san.log 2>&1 || true
if grep -qE "ERROR: AddressSanitizer|runtime error:" san.log; then cat san.log; fail "$tag: sanitizer diagnostic"; fi
[ "$(tier_count "$eng" san.log)" -gt 0 ] || { cat san.log; fail "$tag: no routed expert ran on the device"; }
@@ -506,7 +516,7 @@ import os, subprocess, sys, threading
eng = sys.argv[1]
snap, argv = ("tiny_inkling", ["8"]) if eng == "inkling" else ("olmoe_tiny_c", ["4", "8"])
env = dict(os.environ, SNAP=snap, SERVE="1", PIN="tier.usage", COLI_USAGE="tier.usage", COLI_VULKAN="1",
- COLI_VK_TIER_SYNC="1", OMP_NUM_THREADS="2", ASAN_OPTIONS="detect_leaks=0",
+ COLI_VK_TIER_SYNC="1", OMP_NUM_THREADS="2", ASAN_OPTIONS="detect_leaks=0:detect_stack_use_after_return=0",
UBSAN_OPTIONS="print_stacktrace=1")
for run in range(2):
p = subprocess.Popen(["./" + eng] + argv, env=env, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
@@ -817,7 +827,7 @@ PY
san() { # <engine> <tag> <env and argv...>
local eng=$1 tag=$2; shift 2
rm -f tier.usage deepseek_v4_tiny_t/.coli_usage deepseek_v4_tiny_e8/.coli_usage
- env ASAN_OPTIONS=detect_leaks=0 UBSAN_OPTIONS=print_stacktrace=1 OMP_NUM_THREADS=2 \
+ env ASAN_OPTIONS=detect_leaks=0:detect_stack_use_after_return=0 UBSAN_OPTIONS=print_stacktrace=1 OMP_NUM_THREADS=2 \
COLI_USAGE=tier.usage COLI_VK_TIER_SYNC=1 COLI_VULKAN=1 "$@" > san.log 2>&1 || true
if grep -qE "ERROR: AddressSanitizer|runtime error:" san.log; then cat san.log; fail "$tag: sanitizer diagnostic"; fi
[ "$(tier_count "$eng" san.log)" -gt 0 ] || { cat san.log; fail "$tag: no routed expert ran on the device"; }
@@ -835,7 +845,7 @@ PY
san deepseek_v4 "asan deepseek_v4 trunk on the device" COLI_VK_DENSE=1 ./deepseek_v4 ./deepseek_v4_tiny_t "$p" --raw-prompt --max-tokens 4
# the warm start: a run that leaves its history, then one that starts from it
./deepseek_v4 ./deepseek_v4_tiny_e8 "$p" --raw-prompt --max-tokens 4 > /dev/null 2>&1 || true
- env ASAN_OPTIONS=detect_leaks=0 UBSAN_OPTIONS=print_stacktrace=1 OMP_NUM_THREADS=2 COLI_VK_TIER_SYNC=1 COLI_VULKAN=1 \
+ env ASAN_OPTIONS=detect_leaks=0:detect_stack_use_after_return=0 UBSAN_OPTIONS=print_stacktrace=1 OMP_NUM_THREADS=2 COLI_VK_TIER_SYNC=1 COLI_VULKAN=1 \
./deepseek_v4 ./deepseek_v4_tiny_e8 "$p" --raw-prompt --max-tokens 4 > san.log 2>&1 || true
if grep -qE "ERROR: AddressSanitizer|runtime error:" san.log; then cat san.log; fail "asan deepseek_v4 warm start: sanitizer diagnostic"; fi
grep -q '^\[VK\] tier deepseek_v4: warm start' san.log || { cat san.log; fail "asan deepseek_v4 warm start: no warm start"; }
@@ -929,7 +939,7 @@ family_kimi_mimo_sanitize() {
$PY tools/make_mimo_tiny.py --output ./mimo_tiny --force --vision
ksan() { # <engine> <tag> <env and argv...>
local eng=$1 tag=$2; shift 2
- env ASAN_OPTIONS=detect_leaks=0 UBSAN_OPTIONS=print_stacktrace=1 OMP_NUM_THREADS=2 \
+ env ASAN_OPTIONS=detect_leaks=0:detect_stack_use_after_return=0 UBSAN_OPTIONS=print_stacktrace=1 OMP_NUM_THREADS=2 \
COLI_VK_TIER_SYNC=1 COLI_VULKAN=1 "$@" > san.log 2>&1 || true
if grep -qE "ERROR: AddressSanitizer|runtime error:" san.log; then cat san.log; fail "$tag: sanitizer diagnostic"; fi
[ "$(tier_count "$eng" san.log)" -gt 0 ] || { cat san.log; fail "$tag: no routed expert ran on the device"; }
@@ -1116,7 +1126,7 @@ family_glm_sanitize() {
if [ "$snap" = - ]; then env COLI_USAGE=g53.usage "${a[@]}" > /dev/null 2>&1 || true
else env STATS=$snap/.coli_usage "${a[@]}" > /dev/null 2>&1 || true; fi
fi
- env ASAN_OPTIONS=detect_leaks=0 UBSAN_OPTIONS=print_stacktrace=1 COLI_USAGE=g53.usage \
+ env ASAN_OPTIONS=detect_leaks=0:detect_stack_use_after_return=0 UBSAN_OPTIONS=print_stacktrace=1 COLI_USAGE=g53.usage \
COLI_VK_TIER_SYNC=1 COLI_VULKAN=1 "$@" > san.log 2>&1 || true
rm -f g53.usage; [ "$snap" = - ] || rm -f "$snap/.coli_usage"
if grep -qE "ERROR: AddressSanitizer|runtime error:" san.log; then cat san.log; fail "$tag: sanitizer diagnostic"; fi