Run frontier MoE models on hardware you already own β pure C, zero deps, experts streamed from disk. Tiny engine, immense model. π¦
C
Merge branch 'feat/vk-tier-deepseek' into feat/vk-tier-all-engines
JustVugg5071e0fb06a5
diff --cc .github/workflows/ci.ymlindex 2039f784,473b28ec..b04b635e--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@@ -178,12 -175,10 +178,16 @@@ jobs- family: deepseekreq: c/tools/requirements-deepseek-v4-tiny.txtextra: sympy pillow # the V4.1 fixture's reference and its vision tower+ # the routed-expert tier of deepseek_v41 and deepseek_v4 under ASan and UBSan+ - family: deepseek-sanitize+ req: c/tools/requirements-deepseek-v4-tiny.txt+ extra: sympy pillow+ # Kimi K3's routed experts on the shared tier, and its and MiMo's tier under+ # ASan and UBSan (MiMo's tier runs in mimo-qwenimage)+ - family: kimi+ req: c/tools/requirements-kimi-k3-tiny.txt+ - family: kimi-mimo-sanitize+ req: c/tools/requirements-mimo-tiny.txtsteps:- uses: actions/checkout@v4- uses: actions/setup-python@v5diff --cc c/tests/vulkan_engines.shindex 1c894a89,a864c537..e99ef4e9--- a/c/tests/vulkan_engines.sh+++ b/c/tests/vulkan_engines.sh@@@ -2,8 -2,8 +2,8 @@@# Every engine's Vulkan path against its own CPU run, on Lavapipe (Mesa's software# Vulkan), one family per call so CI can run them side by side:#--# bash tests/vulkan_engines.sh qwen | qwen-sanitize | inkling-olmoe | mimo-qwenimage | deepseek- # bash tests/vulkan_engines.sh kimi | kimi-mimo-sanitize-# bash tests/vulkan_engines.sh deepseek-sanitize++# bash tests/vulkan_engines.sh qwen | qwen-sanitize | inkling-olmoe | inkling-olmoe-sanitize++# bash tests/vulkan_engines.sh mimo-qwenimage | kimi | kimi-mimo-sanitize | deepseek | deepseek-sanitize# bash tests/vulkan_engines.sh shader # the qmatmul formats, the expert batch and the tier, no engine## Needs libvulkan-dev, glslc and mesa-vulkan-drivers, plus the Python packages of@@@ -662,125 -494,154 +692,264 @@@ print("OK deepseek_v4 session: ids = CPsys.exit(0 if ok else 1)PYneed_gpu deepseek_v4 v4-vk.err "deepseek_v4 session"- echo "OK deepseek_v4: $(vk_count deepseek_v4 v4-vk.err) matmuls on the GPU"+ echo "OK deepseek_v4: $(vk_count deepseek_v4 v4-vk.err) matmuls on the GPU, $(grep -a -o 'device [0-9]* of [0-9]* routed experts' v4-vk.err | tail -1)"++ # The routed-expert tier on deepseek_v4's fp4 experts (fmt 7) with its own+ # activation (VKT_ACT_SWIGLU_V4: the CPU kernel's bf16 and E4M3 roundings and the+ # route weight before down, on the device). Every oracle case against the CPU run:+ # ids equal to the CPU's and the reference's, teacher-forced predictions equal,+ # routed experts served by the device. The history is the store's own .coli_usage+ # in the fixture, removed before each run unless WARM=1 (the tier then warm-starts+ # from the CPU run's): the runs use a copy of the fixture, whose committed history+ # stays as it is. An 8-expert variant of the fixture has room for pinned hot+ # experts, which the store keeps in its rows16 layout: the tier gets them unpacked.+ rm -rf deepseek_v4_tiny_t && cp -r deepseek_v4_tiny deepseek_v4_tiny_t+ $PY - tools/make_deepseek_v4_tiny.py deepseek_v4_tiny_e8 <<'PY'+ import importlib.util, sys+ spec = importlib.util.spec_from_file_location("gen", sys.argv[1])+ gen = importlib.util.module_from_spec(spec); spec.loader.exec_module(gen)+ gen.EXPERTS = 8 # 8 routed experts a layer: two cache slots a layer for pins+ sys.argv = ["make_deepseek_v4_tiny.py", "--output", sys.argv[2], "--force"]+ gen.main()+ PY+ v4_tier() { # <tag> <fixture> <case> <env...>+ local tag=$1 fx=$2 c=$3; shift 3+ local p mt+ p=$($PY -c 'import json,sys; c=json.load(open(sys.argv[1]+"/ref.json"))["cases"][sys.argv[2]]; print("".join("<t%03d>" % t for t in c["prompt_ids"]))' $fx $c)+ mt=$($PY -c 'import json,sys; print(json.load(open(sys.argv[1]+"/ref.json"))["cases"][sys.argv[2]]["max_new_tokens"])' $fx $c)+ rm -f $fx/.coli_usage+ env "$@" ./deepseek_v4 ./$fx "$p" --raw-prompt --max-tokens $mt --record-oracle v4-cpu.json > /dev/null 2> v4-cpu.err ||+ { cat v4-cpu.err; fail "deepseek_v4 tier $tag: CPU run"; }+ [ "${WARM:-0}" = 1 ] || rm -f $fx/.coli_usage+ env "$@" COLI_VK_TIER_SYNC=1 COLI_VULKAN=1 ./deepseek_v4 ./$fx "$p" --raw-prompt --max-tokens $mt --record-oracle v4-vk.json > /dev/null 2> v4-vk.err ||+ { cat v4-vk.err; fail "deepseek_v4 tier $tag: Vulkan run"; }+ rm -f $fx/.coli_usage+ $PY - $fx $c <<'PY' || fail "deepseek_v4 tier $tag: the Vulkan session differs from the CPU's"+ import json, sys+ a, b = json.load(open("v4-cpu.json")), json.load(open("v4-vk.json"))+ ref = json.load(open(sys.argv[1] + "/ref.json"))["cases"][sys.argv[2]]["greedy_full_ids"]+ ok = a["full_ids"] == b["full_ids"] == ref and a["tf_pred"] == b["tf_pred"]+ if not ok: print("CPU", a, "VK", b, "ref", ref)+ sys.exit(0 if ok else 1)+ PY+ [ "$(tier_count deepseek_v4 v4-vk.err)" -gt 0 ] || { cat v4-vk.err; fail "deepseek_v4 tier $tag: no routed expert ran on the device"; }+ if [ "${EVICT:-0}" = 1 ]; then+ [ "$(tier_evictions deepseek_v4 v4-vk.err)" -gt 0 ] || { grep '\[VK\] tier' v4-vk.err; fail "deepseek_v4 tier $tag: the budget forced no eviction"; }+ fi+ if [ "${WARM:-0}" = 1 ]; then+ grep -q '^\[VK\] tier deepseek_v4: warm start' v4-vk.err || { grep '\[VK\] tier' v4-vk.err; fail "deepseek_v4 tier $tag: no warm start"; }+ fi+ echo "OK deepseek_v4 tier $tag ($c): ids = CPU = reference, $(grep -a -o 'device [0-9]* of [0-9]* routed experts' v4-vk.err | tail -1), $(grep -a -o 'evictions [0-9]*' v4-vk.err | tail -1), $(grep -a -o 'packed_slots=[0-9]*' v4-vk.err) rows16"+ }+ for c in short compressed long; do+ v4_tier "4 experts" deepseek_v4_tiny_t $c+ v4_tier "8 experts, pinned rows16" deepseek_v4_tiny_e8 $c+ done+ EVICT=1 v4_tier "a budget of three experts" deepseek_v4_tiny_e8 long COLI_VK_TIER_GB=0.00009+ v4_tier "trunk on the device too" deepseek_v4_tiny_t long COLI_VK_DENSE=1+ v4_tier "the GEMM route from 2 rows" deepseek_v4_tiny_t long COLI_VK_TIER_GEMM_ROWS=2+ WARM=1 v4_tier "warm start from the CPU run's history" deepseek_v4_tiny_e8 long+ # A served prompt with every routed expert on the device (warm start from the CPU+ # run's history): its per-position logprob echoes against the CPU's. Measured on+ # Lavapipe they are the same bytes; the gate allows 1e-3, for an exp() that rounds+ # one hidden value to the other bf16 neighbour on another driver.+ $PY - deepseek_v4_tiny_e8 <<'PY' || fail "deepseek_v4 tier: served logprobs differ from the CPU's"+ import json, os, sys+ from pathlib import Path+ sys.path.insert(0, "tests")+ import test_deepseek_v4_brio as b+ fx = Path(sys.argv[1])+ case = json.load(open(fx / "ref.json"))["cases"]["long"]+ def echoes(vk):+ os.environ.pop("COLI_VULKAN", None)+ if vk: os.environ.update(COLI_VULKAN="1", COLI_VK_TIER_SYNC="1")+ else:+ try: os.remove(fx / ".coli_usage")+ except FileNotFoundError: pass+ s = b.Serve(Path("deepseek_v4").resolve(), fx)+ try: return s.submit(b.token_prompt(case["prompt_ids"]), 0, logprobs=5).echoes+ finally:+ s.close()+ tier = [l for l in s.process.stderr.read().decode(errors="replace").splitlines() if "tier deepseek_v4 turn:" in l]+ if vk: print(" ", tier[-1][:90] if tier else "no tier line")+ cpu, dev = echoes(False), echoes(True)+ os.environ.pop("COLI_VULKAN", None)+ same = sum(cpu[p] == dev.get(p) for p in cpu)+ worst = max(abs(cpu[p]["lp"] - dev[p]["lp"]) for p in cpu) if len(cpu) == len(dev) else 1.0+ print(f"OK deepseek_v4 tier served: {same} of {len(cpu)} positions' logprob echoes identical to the CPU's, worst |delta| {worst:.2e}")+ sys.exit(0 if len(cpu) == len(dev) and worst <= 1e-3 else 1)+ PY+ rm -rf deepseek_v4_tiny_t deepseek_v4_tiny_e8+ }++ # The routed-expert tier of both deepseek engines under ASan and UBSan: sanitized VK=1+ # builds, the tier's configurations on Lavapipe (decode and prefill, eviction, DSpark,+ # pinned rows16 experts, the warm start, the trunk on the device). Memory safety is+ # the gate; each run must still put experts on the device.+ family_deepseek_sanitize() {+ local SAN="-fsanitize=address,undefined -fno-omit-frame-pointer -g"+ make clean >/dev/null 2>&1 || true+ make deepseek_v41 VK=1 EXTRA_CFLAGS="$SAN"+ make deepseek-v4 VK=1 LTO=0 EXTRA_CFLAGS="$SAN" EXTRA_LDFLAGS="$SAN"+ $PY tools/make_dsv41_tiny.py --out dsv41_tiny --emit-ref dsv41_tiny/ref.json+ $PY tools/make_dsv41_tiny.py --out dsv41_long --emit-ref dsv41_long/ref.json --prompt-len 40 --max-new 6+ $PY tools/make_deepseek_v4_tiny.py --output deepseek_v4_tiny_t --force+ $PY - tools/make_deepseek_v4_tiny.py deepseek_v4_tiny_e8 <<'PY'+ import importlib.util, sys+ spec = importlib.util.spec_from_file_location("gen", sys.argv[1])+ gen = importlib.util.module_from_spec(spec); spec.loader.exec_module(gen)+ gen.EXPERTS = 8+ sys.argv = ["make_deepseek_v4_tiny.py", "--output", sys.argv[2], "--force"]+ gen.main()+ 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 \+ 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"; }+ echo "OK $tag: sanitizers clean, $(grep -a -o 'device [0-9]* of [0-9]* routed experts' san.log | tail -1), $(grep -a -o 'evictions [0-9]*' san.log | tail -1)"+ }+ local cap force p+ for cap in 1 8; do san deepseek_v41 "asan deepseek_v41 cap=$cap" SNAP=dsv41_long ./deepseek_v41 $cap dsv41_long/ref.json; done+ for force in 2 4; do san deepseek_v41 "asan deepseek_v41 DSpark spec=$force" SNAP=dsv41_tiny V41_DSPARK=1 V41_SPEC_FORCE=$force ./deepseek_v41 1 dsv41_tiny/ref.json; done+ san deepseek_v41 "asan deepseek_v41 eviction" COLI_VK_TIER_GB=0.00005 SNAP=dsv41_long ./deepseek_v41 8 dsv41_long/ref.json+ san deepseek_v41 "asan deepseek_v41 trunk on the device" COLI_VK_DENSE=1 SNAP=dsv41_tiny ./deepseek_v41 2 dsv41_tiny/ref.json+ p=$($PY -c 'import json; c=json.load(open("deepseek_v4_tiny_t/ref.json"))["cases"]["long"]; print("".join("<t%03d>" % t for t in c["prompt_ids"]))')+ san deepseek_v4 "asan deepseek_v4" ./deepseek_v4 ./deepseek_v4_tiny_t "$p" --raw-prompt --max-tokens 4 --record-oracle san.json+ san deepseek_v4 "asan deepseek_v4 pinned rows16" ./deepseek_v4 ./deepseek_v4_tiny_e8 "$p" --raw-prompt --max-tokens 4 --record-oracle san.json+ san deepseek_v4 "asan deepseek_v4 eviction" COLI_VK_TIER_GB=0.00009 ./deepseek_v4 ./deepseek_v4_tiny_e8 "$p" --raw-prompt --max-tokens 4 --record-oracle san.json+ 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 \+ ./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"; }+ echo "OK asan deepseek_v4 warm start: sanitizers clean, $(grep -a -o 'device [0-9]* of [0-9]* routed experts' san.log | tail -1)"+ rm -rf deepseek_v4_tiny_t deepseek_v4_tiny_e8 san.json+ make clean >/dev/null 2>&1 || true+ make deepseek-v4-clean >/dev/null 2>&1 || true}+# Kimi K3: the routed experts on the shared tier (MXFP4 with ue8m0 scales, fmt 7,+# SiTU-GLU in the latent space), against Moonshot's vendor oracle and the CPU run.+# K3_IDOT=0 everywhere: the CPU's default int8-activation expert kernel is an+# approximation the device does not make (the oracle's engine_env sets it too).+family_kimi() {+ make kimi_k3 VK=1+ $PY tools/make_kimi_k3_tiny.py --output ./kimi_k3_tiny --force+ # Moonshot's oracle (greedy, teacher forcing at every position, determinism, the+ # bite) with the tier on, the shared experts where the default puts them (the CPU+ # on Lavapipe) and on the device+ COLI_USAGE=$PWD/k3.usage USAGE_SAVE=0 COLI_VULKAN=1 COLI_VK_TIER_SYNC=1 \+ $PY tests/test_kimi_k3_tiny.py --binary ./kimi_k3 --fixture ./kimi_k3_tiny+ COLI_USAGE=$PWD/k3.usage USAGE_SAVE=0 COLI_VULKAN=1 COLI_VK_TIER_SYNC=1 COLI_VK_DENSE=1 \+ $PY tests/test_kimi_k3_tiny.py --binary ./kimi_k3 --fixture ./kimi_k3_tiny+ k3ids() { $PY -c "import json,sys;print(' '.join(map(str,json.load(open('kimi_k3_tiny/ref.json'))['cases'][sys.argv[1]]['prompt_ids'])))" "$1"; }+ # k3_gate <tag> <env...>: the tokens of the CPU run, the tier served some experts,+ # the shared experts where they were asked to be (dense_where); EVICT=1: it evicted+ k3_gate() {+ local tag=$1 c; shift+ for c in short chunk long; do+ rm -f k3.usage+ env "$@" COLI_USAGE=$PWD/k3.usage USAGE_SAVE=0 ./kimi_k3 kimi_k3_tiny --ids "$(k3ids $c)" --ngen 8 2>/dev/null | sed 's/ *TUNE.*//' > cpu.tok+ env "$@" COLI_USAGE=$PWD/k3.usage USAGE_SAVE=0 COLI_VK_TIER_SYNC=1 COLI_VULKAN=1 \+ ./kimi_k3 kimi_k3_tiny --ids "$(k3ids $c)" --ngen 8 2> vk.log | sed 's/ *TUNE.*//' > vk.tok+ { [ -s cpu.tok ] && cmp -s cpu.tok vk.tok; } || { cat cpu.tok vk.tok vk.log; fail "$tag $c: Vulkan tokens differ from the CPU"; }+ [ "$(tier_count kimi_k3 vk.log)" -gt 0 ] || { cat vk.log; fail "$tag $c: no routed expert ran on the device"; }+ if [ "${EVICT:-0}" = 1 ]; then+ [ "$(tier_evictions kimi_k3 vk.log)" -gt 0 ] || { grep '\[VK\] tier' vk.log; fail "$tag $c: the budget forced no eviction"; }+ grep -q ' failed 0 ' vk.log || { grep '\[VK\] tier' vk.log; fail "$tag $c: an upload failed"; }+ fi+ local where; where=$(dense_where kimi_k3 vk.log "$tag $c" "$@") || { echo "$where"; exit 1; }+ echo "OK $tag $c: tokens = CPU, $(grep -a -o 'device [0-9]* of [0-9]* routed experts' vk.log | tail -1), $(grep -a -o 'evictions [0-9]*' vk.log | tail -1), shared experts on the $where"+ done+ }+ local O="K3_BITS=32 K3_MLA_BITS=32 K3_HEAD_BITS=32 K3_IDOT=0 COLI_TEMP=0" b+ k3_gate "kimi_k3 tier f32" $O+ k3_gate "kimi_k3 tier f32, shared experts on the device" $O COLI_VK_DENSE=1+ for b in 8 4; do # the shared experts as int8 rows (fmt 1) and int4-g64 (fmt 4) on the device+ k3_gate "kimi_k3 tier K3_BITS=$b, shared experts on the device" K3_BITS=$b K3_MLA_BITS=$b K3_HEAD_BITS=$b K3_IDOT=0 COLI_TEMP=0 COLI_VK_DENSE=1+ done+ k3_gate "kimi_k3 tier, prefill one token at a time" $O K3_CHUNK=1+ k3_gate "kimi_k3 tier, loads not pipelined" $O K3_PIPE=0+ EVICT=1 k3_gate "kimi_k3 tier, a budget of two experts" $O COLI_VK_TIER_GB=0.000005+ # the old switches: K3_VK=1 opens the device as COLI_VULKAN=1 does and K3_VK_GB caps+ # the tier; K3_VK=0 keeps it closed whatever COLI_VULKAN says+ rm -f k3.usage+ env $O COLI_USAGE=$PWD/k3.usage USAGE_SAVE=0 ./kimi_k3 kimi_k3_tiny --ids "$(k3ids long)" --ngen 8 2>/dev/null | sed 's/ *TUNE.*//' > cpu.tok+ env $O COLI_USAGE=$PWD/k3.usage USAGE_SAVE=0 COLI_VK_TIER_SYNC=1 K3_VK=1 K3_VK_GB=0.000005 \+ ./kimi_k3 kimi_k3_tiny --ids "$(k3ids long)" --ngen 8 2> vk.log | sed 's/ *TUNE.*//' > vk.tok+ cmp -s cpu.tok vk.tok || { cat vk.log; fail "kimi_k3 K3_VK=1: tokens differ from the CPU"; }+ grep -q 'K3_VK=1 read as COLI_VULKAN=1' vk.log && grep -q 'budget [0-9.]* KiB = 2 experts' vk.log &&+ [ "$(tier_count kimi_k3 vk.log)" -gt 0 ] || { cat vk.log; fail "kimi_k3 K3_VK=1 K3_VK_GB: not the tier it asked for"; }+ env $O COLI_USAGE=$PWD/k3.usage USAGE_SAVE=0 K3_VK=0 COLI_VULKAN=1 \+ ./kimi_k3 kimi_k3_tiny --ids "$(k3ids long)" --ngen 8 2> vk.log | sed 's/ *TUNE.*//' > vk.tok+ cmp -s cpu.tok vk.tok && ! grep -q '^\[VK\]' vk.log || { cat vk.log; fail "kimi_k3 K3_VK=0: the device opened"; }+ echo "OK kimi_k3 K3_VK=1 / K3_VK_GB / K3_VK=0: the shared tier's switches"+ # a warm start from the history of the run before: the tier starts full, serves+ # every routed expert of the same prompt, and the tokens stay the CPU's+ rm -f k3.usage+ env $O COLI_USAGE=$PWD/k3.usage COLI_VULKAN=1 COLI_VK_TIER_SYNC=1 ./kimi_k3 kimi_k3_tiny --ids "$(k3ids long)" --ngen 8 > /dev/null 2>&1+ env $O COLI_USAGE=$PWD/k3.usage USAGE_SAVE=0 COLI_VULKAN=1 COLI_VK_TIER_SYNC=1 \+ ./kimi_k3 kimi_k3_tiny --ids "$(k3ids long)" --ngen 8 2> vk.log | sed 's/ *TUNE.*//' > vk.tok+ cmp -s cpu.tok vk.tok || { cat vk.log; fail "kimi_k3 warm start: tokens differ from the CPU"; }+ grep -q 'tier kimi_k3: warm start, [1-9]' vk.log || { cat vk.log; fail "kimi_k3: no warm start from the history"; }+ echo "OK kimi_k3 warm start: tokens = CPU, $(grep -a -o 'warm start, [0-9]* experts' vk.log), $(grep -a -o 'device [0-9]* of [0-9]* routed experts' vk.log | tail -1)"+ # COLI_VK_TIER=0: the shared experts alone on the device, as before the tier+ env $O COLI_USAGE=$PWD/k3.usage USAGE_SAVE=0 COLI_VK_TIER=0 COLI_VULKAN=1 \+ ./kimi_k3 kimi_k3_tiny --ids "$(k3ids long)" --ngen 8 2> vk.log | sed 's/ *TUNE.*//' > vk.tok+ cmp -s cpu.tok vk.tok || { cat vk.log; fail "kimi_k3 COLI_VK_TIER=0: tokens differ from the CPU"; }+ ! grep -q '^\[VK\] tier' vk.log || { cat vk.log; fail "kimi_k3 COLI_VK_TIER=0: the tier started"; }+ need_gpu kimi_k3 vk.log "kimi_k3 COLI_VK_TIER=0"+ echo "OK kimi_k3 COLI_VK_TIER=0: tokens = CPU, no tier, $(vk_count kimi_k3 vk.log) matmuls on the GPU"+}++# The Kimi K3 and MiMo expert tiers under ASan and UBSan, as qwen-sanitize does for+# the qwen engines: memory safety is the gate, and each run must still put routed+# experts on the device.+family_kimi_mimo_sanitize() {+ make clean >/dev/null 2>&1 || true+ make kimi_k3 mimo VK=1 EXTRA_CFLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer -g"+ $PY tools/make_kimi_k3_tiny.py --output ./kimi_k3_tiny --force+ $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 \+ 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"; }+ echo "OK $tag: sanitizers clean, $(grep -a -o 'device [0-9]* of [0-9]* routed experts' san.log | tail -1), $(grep -a -o 'evictions [0-9]*' san.log | tail -1)"+ }+ local O="K3_BITS=32 K3_MLA_BITS=32 K3_HEAD_BITS=32 K3_IDOT=0 COLI_TEMP=0" K3IDS MIDS IMG GRID+ K3IDS=$($PY -c "import json;print(' '.join(map(str,json.load(open('kimi_k3_tiny/ref.json'))['cases']['long']['prompt_ids'])))")+ MIDS=$($PY -c "import json;print(' '.join(map(str,json.load(open('mimo_tiny/ref.json'))['cases']['long']['prompt_ids'])))")+ IMG=$($PY -c "import json;print(' '.join(map(str,json.load(open('mimo_tiny/ref.json'))['image']['prompt_ids'])))")+ GRID=$($PY -c "import json;i=json.load(open('mimo_tiny/ref.json'))['image'];print(i['grid_h'],i['grid_w'])")+ rm -f k3.usage+ ksan kimi_k3 "asan kimi_k3 tier" $O COLI_USAGE=$PWD/k3.usage ./kimi_k3 kimi_k3_tiny --ids "$K3IDS" --ngen 8+ ksan kimi_k3 "asan kimi_k3 warm start, shared experts on the device" $O COLI_USAGE=$PWD/k3.usage COLI_VK_DENSE=1 ./kimi_k3 kimi_k3_tiny --ids "$K3IDS" --ngen 8+ ksan kimi_k3 "asan kimi_k3 eviction, int8 shared experts" K3_BITS=8 K3_IDOT=0 COLI_USAGE=$PWD/k3e.usage USAGE_SAVE=0 COLI_VK_TIER_GB=0.000005 COLI_VK_DENSE=1 ./kimi_k3 kimi_k3_tiny --ids "$K3IDS" --ngen 8+ ksan kimi_k3 "asan kimi_k3 prefill one token at a time, no pipeline" $O COLI_USAGE=$PWD/k3e.usage USAGE_SAVE=0 K3_CHUNK=1 K3_PIPE=0 ./kimi_k3 kimi_k3_tiny --ids "$K3IDS" --ngen 8+ ksan mimo "asan mimo tier" MIMO_DENSE_BITS=32 COLI_TEMP=0 ./mimo mimo_tiny --ids "$MIDS" --ngen 6+ ksan mimo "asan mimo eviction (MIMO_VK_EXPERTS=2)" MIMO_DENSE_BITS=32 COLI_TEMP=0 MIMO_VK_EXPERTS=2 ./mimo mimo_tiny --ids "$MIDS" --ngen 6+ ksan mimo "asan mimo picture, native dense on the device" MIMO_DENSE_BITS=0 COLI_TEMP=0 COLI_VK_DENSE=1 ./mimo mimo_tiny --ids "$IMG" --ngen 6 --image mimo_tiny/patches.f32 --grid $GRID+ ksan mimo "asan mimo prefill blocks of 3, cache 4" MIMO_DENSE_BITS=32 COLI_TEMP=0 MIMO_CHUNK=3 MIMO_CAP=4 ./mimo mimo_tiny --ids "$MIDS" --ngen 6+ make clean >/dev/null 2>&1 || true+}+case "${1:-}" inshader) shader_formats ;;qwen) family_qwen ;;qwen-sanitize) family_qwen_sanitize ;;inkling-olmoe) family_inkling_olmoe ;;+ inkling-olmoe-sanitize) family_inkling_olmoe_sanitize ;;mimo-qwenimage) family_mimo_qwenimage ;;deepseek) family_deepseek ;;+ deepseek-sanitize) family_deepseek_sanitize ;;- *) echo "usage: $0 shader|qwen|qwen-sanitize|inkling-olmoe|mimo-qwenimage|deepseek|deepseek-sanitize" >&2; exit 2 ;;+ kimi) family_kimi ;;+ kimi-mimo-sanitize) family_kimi_mimo_sanitize ;;- *) echo "usage: $0 shader|qwen|qwen-sanitize|inkling-olmoe|mimo-qwenimage|deepseek|kimi|kimi-mimo-sanitize" >&2; exit 2 ;;++ *) echo "usage: $0 shader|qwen|qwen-sanitize|inkling-olmoe|inkling-olmoe-sanitize|mimo-qwenimage|deepseek|deepseek-sanitize|kimi|kimi-mimo-sanitize" >&2; exit 2 ;;esacdiff --cc docs/ENVIRONMENT.mdindex 02b2bf23,1e21b197..772ef804--- a/docs/ENVIRONMENT.md+++ b/docs/ENVIRONMENT.md@@@ -14,14 -14,14 +14,14 @@@ what follows, but the sister engines re|---|---|---|| `colibri` | `c/colibri.c` | everything below except the three sections named for another engine || `glm53` | `c/glm53.c` | the `GLM53_*` family and `COLI_MAP_EXPERTS`: see [GLM-5.3-Flash engine](#glm-53-flash-engine-glm53) |-| `kimi_k3` | `c/kimi_k3.c` | the `K3_*` family β see [Kimi K3 engine](#kimi-k3-engine-kimi_k3) |-| `inkling` | `c/inkling.c` | `INK_*`, plus `CTX_MAX`, `PIN_N`, `REP_PEN`, `GPU_DEV`, `NOGPU` β see [Inkling engine](#inkling-engine-inkling) |+| `kimi_k3` | `c/kimi_k3.c` | the `K3_*` family, and the Vulkan expert tier's `COLI_VK_TIER*` β see [Kimi K3 engine](#kimi-k3-engine-kimi_k3) |+| `inkling` | `c/inkling.c` | `INK_*`, plus `CTX_MAX`, `PIN_N`, `REP_PEN`, `GPU_DEV`, `NOGPU`, the Vulkan expert tier's `COLI_VK_TIER*` β see [Inkling engine](#inkling-engine-inkling) || `qwen36` | `c/qwen36.c` | `QWEN_*`, `Q36_*`, its dense/CUDA-tier controls, the `CACHE_ROUTE` family (VRAM tier over RAM cache), and the Vulkan expert tier's `COLI_VK_TIER*` β see [Qwen3.6 engine](#qwen36-engine-qwen36) || `qwen38` | `c/qwen38.c` | `Q38_MAXT`, `Q38_EOS`, `Q38_NATIVE_FP8`, `Q38_NATIVE_BF16`, `Q38_EXPERT_INT4`, `Q38_MTP`, `Q38_PREFILL_BATCH`, `Q38_TRUNK_CPU_INT8`, `Q38_FP8_KERNEL`, `COLI_TIMERS`, the Vulkan expert tier's `COLI_VK_TIER*` β see [Qwen3.8 engine](#qwen38-engine-qwen38) |-| `olmoe` | `c/olmoe.c` | `HOT`, `WIDE`, `SMOOTH`, `CONF_LIMIT`, `MAX_NEW`, `CHAT`, `EXPERT_DROP`, `WARMUP` β see [OLMoE engine](#olmoe-engine-olmoe) |+| `olmoe` | `c/olmoe.c` | `HOT`, `WIDE`, `SMOOTH`, `CONF_LIMIT`, `MAX_NEW`, `CHAT`, `EXPERT_DROP`, `WARMUP`, the Vulkan expert tier's `COLI_VK_TIER*` β see [OLMoE engine](#olmoe-engine-olmoe) |- | `deepseek_v4` | `c/deepseek_v4.c` | `CTX`, the `V4_*` / `DSV4_*` families and the two `COLI_CUDA_*_BATCH` gates β see [DeepSeek V4 engine](#deepseek-v4-engine-deepseek_v4); note that the CUDA section below describes `colibri.c` knobs (`COLI_CUDA`, `CUDA_DENSE`, ...) which the V4 engine does not read β its GPU switch is `DSV4_CUDA` |- | `deepseek_v41` | `c/deepseek_v41.c` | the `V41_*` family: see [DeepSeek V4.1 engine](#deepseek-v41-engine-deepseek_v41) |+ | `deepseek_v4` | `c/deepseek_v4.c` | `CTX`, the `V4_*` / `DSV4_*` families, the two `COLI_CUDA_*_BATCH` gates and the Vulkan expert tier's `COLI_VK_TIER*` β see [DeepSeek V4 engine](#deepseek-v4-engine-deepseek_v4); note that the CUDA section below describes `colibri.c` knobs (`COLI_CUDA`, `CUDA_DENSE`, ...) which the V4 engine does not read β its GPU switch is `DSV4_CUDA` |+ | `deepseek_v41` | `c/deepseek_v41.c` | the `V41_*` family and the Vulkan expert tier's `COLI_VK_TIER*`: see [DeepSeek V4.1 engine](#deepseek-v41-engine-deepseek_v41) |-| `mimo` | `c/mimo.c` | the `MIMO_*` family: see [MiMo-V2.6 engine](#mimo-v26-engine-mimo) |+| `mimo` | `c/mimo.c` | the `MIMO_*` family, and the Vulkan expert tier's `COLI_VK_TIER*`: see [MiMo-V2.6 engine](#mimo-v26-engine-mimo) |Setting an `INK_*` variable while running `colibri` does nothing, and viceversa; nothing warns you about it. A few variables are genuinely shared because@@@ -229,7 -229,7 +229,7 @@@ Per-drive byte counts are reported in| `COLI_VK_GEMM_TILE` | measured | `bm,bn,bk,tm,tn[,pf]`: one tile for every width of the fp32 GEMM instead of the measured pair. Tuning only (`COLI_VK_TEST_GEMM_BENCH`). || `COLI_VK_COOP_TILE` | measured | `bm,bn,wm,wn,bk`: one tile for every width of the cooperative-matrix GEMM. Tuning only. |- ### The routed-expert tier (`vk_tier.c`; qwen36, qwen38, inkling, olmoe, kimi_k3, mimo)-### The routed-expert tier (`vk_tier.c`; qwen36, qwen38)++### The routed-expert tier (`vk_tier.c`; qwen36, qwen38, inkling, olmoe, kimi_k3, mimo, deepseek_v41, deepseek_v4)With `COLI_VULKAN=1` the engines on the shared tier keep a cache of routed experts on the device that adapts while you chat, and compute the resident ones of each layer step while the CPU computes the rest. See [vulkan.md](vulkan.md#the-routed-expert-tier-vk_tierc). With the CUDA expert tier also on, CUDA wins and this tier stays off.@@@ -244,7 -244,7 +244,7 @@@| `COLI_VK_TIER_BALANCE` | on | `0`: the device takes every resident expert of a step. On, when a join keeps waiting for the device, the step's resident experts the CPU also holds in RAM go back to the CPU beyond the device's share, which moves with every join (down when the CPU waited more than a tenth of its own time, up when the device finished before 80% of it). || `COLI_VK_TIER_GEMM_ROWS` | `16` | Rows from which an expert of a step takes the tiled GEMM (prefill) instead of the per-row GEMV; `0` never. Below it a row's bits do not depend on how many rows share the dispatch. || `COLI_VK_TIER_QUEUE` | a second queue | `0`: the tier's batches share the main queue with the dense matmuls (they then serialize). Unset: a second queue of the main family, else a compute-only family's (RADV), else shared (Lavapipe). |- | `COLI_VK_DENSE` | on; off on a device sharing the CPU's RAM while the tier is on | Where the dense (non-expert) matrices of qwen36, qwen38, inkling, olmoe, mimo, deepseek_v41, deepseek_v4 and qwenimage run. `0`: on the CPU (with the tier on, the device takes the routed experts only); `1`: on the device whatever the device. Unset: on the device, except on an integrated GPU or a CPU device (Lavapipe) while the engine runs the expert tier (today qwen36, qwen38, inkling, olmoe, kimi_k3 and mimo), where they stay on the CPU: there the dense matmuls cost more than the tier gains (measured on a Radeon 780M). The `[VK] <engine>: device ready, dense matrices on the ...` line says which and why. The GLM engine reads it through the same rule with its own default, off (see above). |-| `COLI_VK_DENSE` | on; off on a device sharing the CPU's RAM while the tier is on | Where the dense (non-expert) matrices of qwen36, qwen38, inkling, olmoe, mimo, deepseek_v41, deepseek_v4 and qwenimage run. `0`: on the CPU (with the tier on, the device takes the routed experts only); `1`: on the device whatever the device. Unset: on the device, except on an integrated GPU or a CPU device (Lavapipe) while the engine runs the expert tier (today qwen36, qwen38, deepseek_v41 and deepseek_v4), where they stay on the CPU: there the dense matmuls cost more than the tier gains (measured on a Radeon 780M). The `[VK] <engine>: device ready, dense matrices on the ...` line says which and why. The GLM engine reads it through the same rule with its own default, off (see above). |++| `COLI_VK_DENSE` | on; off on a device sharing the CPU's RAM while the tier is on | Where the dense (non-expert) matrices of qwen36, qwen38, inkling, olmoe, mimo, deepseek_v41, deepseek_v4 and qwenimage run. `0`: on the CPU (with the tier on, the device takes the routed experts only); `1`: on the device whatever the device. Unset: on the device, except on an integrated GPU or a CPU device (Lavapipe) while the engine runs the expert tier (today qwen36, qwen38, inkling, olmoe, kimi_k3, mimo, deepseek_v41 and deepseek_v4), where they stay on the CPU: there the dense matmuls cost more than the tier gains (measured on a Radeon 780M). The `[VK] <engine>: device ready, dense matrices on the ...` line says which and why. The GLM engine reads it through the same rule with its own default, off (see above). |### Second Vulkan device (opt-in)diff --cc docs/vulkan.mdindex 2913670e,33f69298..94ad588a--- a/docs/vulkan.md+++ b/docs/vulkan.md@@@ -101,27 -101,26 +101,28 @@@ runs the routed-expert tier ([below](#tstay on the CPU and the device takes the experts. On a Radeon 780M the dense matmuls,one synchronous call each at the GPU's 800 MHz floor, cost more than the tier gained(Qwen3.8 decode at 2.35 tok/s with them on the device, 3.80 without). Today that- case is qwen36, qwen38, inkling, olmoe, kimi_k3 and mimo; an engine that moves to the- tier inherits it. A discrete GPU keeps the dense matrices on the device by default. The- GLM engine above reads the same variable through the same function with its own- default, off.-case is qwen36, qwen38, deepseek_v41 and deepseek_v4; an engine that moves to the tier inherits it. A discrete-GPU keeps the dense matrices on the device by default. The GLM engine above reads-the same variable through the same function with its own default, off.++case is qwen36, qwen38, inkling, olmoe, kimi_k3, mimo, deepseek_v41 and deepseek_v4;++an engine that moves to the tier inherits it. A discrete GPU keeps the dense matrices++on the device by default. The GLM engine above reads the same variable through the++same function with its own default, off.What these engines put on the device is their **resident** matrices, in the form-they already hold in RAM, uploaded at the first multiply (MiMo uploads them at-startup). Routed experts arrive from disk on every miss; qwen36, qwen38, deepseek_v41-and deepseek_v4 keep a cache of them on the device with the shared expert tier-([below](#the-routed-expert-tier-vk_tierc)), MiMo an opt-in one of its own, the-others none yet.+they already hold in RAM, uploaded at the first multiply (MiMo and Kimi K3 upload+them at startup). Routed experts arrive from disk on every miss; qwen36, qwen38,- inkling, olmoe, Kimi K3 and MiMo keep a cache of them on the device with the shared- expert tier ([below](#the-routed-expert-tier-vk_tierc)), the others none yet.++inkling, olmoe, Kimi K3, MiMo, deepseek_v41 and deepseek_v4 keep a cache of them on++the device with the shared expert tier ([below](#the-routed-expert-tier-vk_tierc)),++the others none yet.| Engine | On the device | Weight formats | Stays on the CPU ||---|---|---|---|| qwen36 (Qwen3.6, Qwen3-Coder, Qwen3.8-27B) | the dense trunk; routed experts on the expert tier | int8 rows; int4-g64 with `COLI_DENSE_BITS=4`; f32 with `COLI_DENSE_I8=0`; experts int4-g64, int4 per row, int8 per row or gs64 | DeltaNet `dn_a`/`dn_b`, vision tower, the experts the tier does not hold || qwen38 (Qwen3.8 Flash Next) | the trunk; routed experts on the expert tier | int8 trunk rows, bf16, f32 (`Q38_NATIVE_BF16=0`); experts int4-g64 (sidecar), FP8 128x128 blocks, bf16 | the MTP head's experts, the experts the tier does not hold |-| inkling | dense and shared-expert matrices | int8 and int4-g64 (dense-int4g64 container), f32, bf16 | routed experts, embedding and audio lookups, CUDA residents; bf16 on CPUs with the AVX512-BF16 dot (see below) |-| olmoe | attention q/k/v/o, router, lm_head | f32 | routed experts, embedding |+| inkling | dense and shared-expert matrices; routed experts on the expert tier | int8 and int4-g64 (dense-int4g64 container), f32, bf16; experts int4 or int8 per row (container or runtime quantization), f32 | embedding and audio lookups, CUDA residents (with CUDA or Metal on, the experts too); bf16 on CPUs with the AVX512-BF16 dot (see below); the experts the tier does not hold |+| olmoe | attention q/k/v/o, router, lm_head; routed experts on the expert tier | f32; experts int8 per row | embedding, the experts the tier does not hold |- | deepseek_v41 | the trunk, vision included | fp8 in 32x32 ue8m0 tiles, bf16 | routed experts |- | deepseek_v4 | resident dense layers, head, router, compressors | fp8 in 128x128 blocks, bf16 | routed experts, the indexer's `weights_proj`, DSpark stages, the `--oracle` path |+ | deepseek_v41 | the trunk, vision included; routed experts on the expert tier | fp8 in 32x32 ue8m0 tiles, bf16; experts MXFP4 (fp4, a ue8m0 scale per 32) | the DSpark stages and their experts, the experts the tier does not hold |+ | deepseek_v4 | resident dense layers, head, router, compressors; routed experts on the expert tier | fp8 in 128x128 blocks, bf16; experts MXFP4 (fp4, a ue8m0 scale per 32) with [an activation of its own](#deepseek-v4s-activation) | the indexer's `weights_proj`, DSpark stages, the `--oracle` path's dense layers, the experts the tier does not hold |-| mimo | trunk and vision tower; up to `MIMO_VK_EXPERTS=N` routed experts | native fp8/bf16, int8, f32 (`MIMO_DENSE_BITS`); experts as MXFP4 | router |+| kimi_k3 (Kimi K3) | the shared experts' matrices (one row at a time: decode); routed experts on the expert tier | shared experts int8 rows, int4-g64, f32 (`K3_BITS`); experts MXFP4 with ue8m0 scales (fmt 7), SiTU-GLU in the latent space | KDA, MLA, the latent projections, router, head, prefill's shared experts, the experts the tier does not hold |+| mimo | trunk and vision tower; routed experts on the expert tier | native fp8/bf16, int8, f32 (`MIMO_DENSE_BITS`); experts MXFP4 with e8m0 scales (fmt 7) | router, the experts the tier does not hold || qwenimage | the DiT's matrices | int8, bf16, f32 (`COLI_IMG_BITS`) | text encoder, VAE, attention |Each engine ends a run, and each serve turn, with@@@ -139,13 -138,11 +140,14 @@@ them by f32 activationskernel (`QWEN_EXPERT_ACT`, int8 by default): the expert tier's experts match`QWEN_EXPERT_ACT=f32`, to 2.5e-7 of the logits on the test fixture;- qwen38's int8 trunk;- - qwenimage's `COLI_IMG_ACT8`.+ - qwenimage's `COLI_IMG_ACT8`;+ - Kimi K3's routed-expert kernel (`K3_IDOT`, on by default): the tier's experts+ match `K3_IDOT=0`, the configuration of its vendor oracle;+ - MiMo's `MIMO_IDOT=1` (off by default).- Two engines keep the CPU's exact arithmetic instead:- deepseek_v4 rounds activations to E4M3 on the host before the call, as its CPU- kernel does.+ kernel does; its routed experts on the expert tier make every rounding its CPU+ expert makes ([DeepSeek V4's activation](#deepseek-v4s-activation)).- inkling leaves its bf16 matrices on the CPU when the build has the AVX512-BF16dot (Zen 4/5, Sapphire Rapids), because that dot rounds activations to bf16.@@@ -307,28 -304,22 +309,35 @@@ of them on the device the way a GPU-equqwen36 and qwen38 fixture configuration are the bytes of the build before thetier (110 configurations: bf16, FP8, int4-g64, int8, the MTP head, every prefillmode, both qwen36 expert kernels, the mixed container, four model geometries).- The same holds for kimi_k3 (30 configurations, every step's logits) and mimo (32,- text and picture, every prompt position's logits). One default moved with it: a- `VK=1` build of Kimi K3 used to open the device without being asked (`K3_VK=1` was- the default); it now waits for `COLI_VULKAN=1` (or `K3_VK=1`) like every engine.- The same holds for deepseek_v41 and deepseek_v4 (40 comparisons per build: every- tiny oracle, the 40-token prompt, DSpark at every forced acceptance, the three V4- cases' oracle records on the 4- and the 8-expert fixture, served logprob echoes, and- the engines' C tests).++ The same holds for kimi_k3 (30 configurations, every step's logits), mimo (32,++ text and picture, every prompt position's logits), and deepseek_v41 and deepseek_v4++ (40 comparisons per build: every tiny oracle, the 40-token prompt, DSpark at every++ forced acceptance, the three V4 cases' oracle records on the 4- and the 8-expert++ fixture, served logprob echoes, and the engines' C tests). One default moved with++ it: a `VK=1` build of Kimi K3 used to open the device without being asked (`K3_VK=1`++ was the default); it now waits for `COLI_VULKAN=1` (or `K3_VK=1`) like every engine.Engines on the tier today: **qwen36** (Qwen3.6, Qwen3-Coder, the 2.4T geometry: int8per row or gs64, int4 per row or gs64 from either expert kernel, the mixed int4/int8container) and **qwen38** (Qwen3.8 Flash Next: the int4-g64 sidecar, the release'sFP8 with 128x128 block scales, BF16). The MTP head's layer of qwen38 stays on the CPU-(its experts are FP8 beside an int4 sidecar). **deepseek_v41** (DeepSeek V4.1 Flash) and+(its experts are FP8 beside an int4 sidecar). **inkling** and **olmoe** as well, see+[Inkling and OLMoE](#inkling-and-olmoe). **kimi_k3** (Kimi K3: the checkpoint's+MXFP4 with ue8m0 scales, SiTU-GLU on the device, the experts in the latent space,+warm-started from its expert history) and **mimo** (MiMo-V2.6 Flash and Pro: the+release's MXFP4, SwiGLU; no history, so the tier fills as experts pass by) joined+it from their own tiers, which filled once and never evicted: Kimi K3's `K3_VK`,+`K3_VK_GB`, `K3_VK_UP` and MiMo's `MIMO_VK_EXPERTS` are now read as this tier's+switches ([ENVIRONMENT.md](ENVIRONMENT.md)). Both add every pair of a row in the+CPU run's order (Kimi K3: its union's disk-offset order; MiMo: the row's routing+order), and offer the experts the CPU computed after the join, so that a promotion- that displaces a resident frees it at once. GLM-5.2's `COLI_VK_EXPERTS` is the older++that displaces a resident frees it at once. **deepseek_v41** (DeepSeek V4.1 Flash) and+ **deepseek_v4** (DeepSeek V4 Flash) put their fp4 experts (MXFP4 with ue8m0 scales) on+ it as the checkpoint stores them; their DSpark stages keep their own experts on the+ CPU, and deepseek_v4's experts take [an activation of their own](#deepseek-v4s-activation).-GLM-5.2's `COLI_VK_EXPERTS`, Kimi K3's-`K3_VK` and MiMo's `MIMO_VK_EXPERTS` are the older per-engine tiers; the others move-to this one in the next phase, see [Adding an engine](#adding-an-engine-to-the-tier).++GLM-5.2's `COLI_VK_EXPERTS` is the older+per-engine tier; the others move to this one in the next phase, see [Adding an+engine](#adding-an-engine-to-the-tier).With the CUDA expert tier built and on (`COLI_CUDA=1`) as well, **CUDA wins**: theVulkan tier stays off and says so (`[VK] tier <engine>: the CUDA expert tier is on@@@ -580,8 -591,12 +629,6 @@@ What each remaining engine needs, from|---|---|---|---|---|| colibri.c (GLM-5.2) | int4 per row `I4U_PAIRS_ROW`, int4-gs `I4U_PAIRS_GS`, int3-g64 `I3_G64`; gate, up, down separate | SwiGLU | `moe()`'s Vulkan block replaces the `COLI_VK_EXPERTS` registry | sums per expert in union order today: move to rank order; fmt 6 (E8/IQ3, rotated input) stays on the CPU; the MTP layer is int8 (another format); the block now serves only S <= 4 || glm53 | int4 gs64 `I4U_PAIRS_GS` 64 | SwiGLU with `swiglu_limit` | `ffn_layer` | its CPU clamps even at limit 0 (no guard), the shader treats 0 as no clamp: pass the config's value and check `L > 0` on the CPU side first; shared expert written first |- | deepseek_v41 | MXFP4 `MXFP4_E8M0` 32 | SwiGLU with limit | `moe_run_at` (already sums per (row, rank) in rank order) | DSpark stages have caches of their own |- | deepseek_v4 | FP4 + ue8m0/32 = `MXFP4_E8M0` 32; pinned experts are repacked rows16 | SwiGLU with limit, **plus** bf16 rounding of gate/up, the route weight applied before down and bf16 rounding of the output | `moe_token_pipeline` (ascending expert id), `v4_moe_batch_union` | needs an activation variant with those roundings and the host's E4M3 rounding of x (as its fp8 dense path does); undo rows16 or keep pinned experts off the tier; hash-routed layers |-| inkling | one `gate_up` tensor [2I, D], rows 0..I-1 gate: pass `g = p13`, `u = p13 + I rows`; int4 per row `I4U_PAIRS_ROW` or int8 `I8_ROW` | SwiGLU | `moe` | routed and shared weights normalized together, `route_scale x rgs` already in the weights |-| kimi_k3 | MXFP4 `MXFP4_E8M0` 32, gate `w1`, up `w3`, down `w2` | SiTU-GLU, a = 4, b = 25 (`VKT_ACT_SITU`) | `moe_forward` / `expert_apply` (experts in the latent space) | replaces `K3_VK` (synchronous, never evicts); the CPU's `K3_IDOT` rounds activations to int8 |-| deepseek_v41 | MXFP4 `MXFP4_E8M0` 32 | SwiGLU with limit | `moe_run_at` (already sums per (row, rank) in rank order) | **on the tier**: backbone layers only, the DSpark stages keep their caches |-| deepseek_v4 | FP4 + ue8m0/32 = `MXFP4_E8M0` 32; pinned experts are repacked rows16 | `VKT_ACT_SWIGLU_V4` ([its activation](#deepseek-v4s-activation)) | `moe_token_pipeline` (ascending expert id), `v4_moe_batch_union` | **on the tier**: x rounded to E4M3 on the host, rows16 unpacked when the tier takes one, hash-routed layers as any other |-| mimo | MXFP4 `MXFP4_E8M0` 32, stored down, ds, gate, gs, up, us | SwiGLU | `moe` | replaces `MIMO_VK_EXPERTS` (synchronous, never evicts) |-| olmoe | int8 per row `I8_ROW`, one merged tensor g, u, d | SwiGLU | `moe` | history only with `COLI_USAGE` |## Correctness@@@ -605,15 -620,12 +652,21 @@@in flight. `tests/vulkan_engines.sh qwen` gives the CPU's tokens with the tier onin every qwen36 and qwen38 expert format, under eviction, with MTP and with thetrunk on the CPU; `qwen-sanitize` runs the same under ASan and UBSan.+ `tests/vulkan_engines.sh inkling-olmoe` does the same for inkling (every expert+ format above, under the f32, bf16 and dense-int4g64 snapshots, `TOPP`) and olmoe+ (with `PILOT`'s worker), under eviction, with a warm start, and through both+ engines' serve tests (prefix reuse, the dashboard, Brio); `inkling-olmoe-sanitize`+ runs them under ASan and UBSan. `kimi` and the mimo half of `mimo-qwenimage` do it+ for Kimi K3 and MiMo: Moonshot's and Xiaomi's oracles with the tier on, the CPU's+ tokens in every dense format with the trunk on the device and on the CPU, a budget+ of two experts that must evict, the old switches, Kimi K3's warm start;+ `kimi-mimo-sanitize` runs the tier's configurations under ASan and UBSan.+ `tests/vulkan_engines.sh deepseek` does it for deepseek_v41 (every tiny oracle, the+ 40-token prompt, DSpark, eviction) and deepseek_v4 (the three oracle cases on a 4-+ and an 8-expert fixture with pinned rows16 experts, eviction, the warm start, the+ served logprobs), and `deepseek-sanitize` under ASan and UBSan. DeepSeek V4's+ activation has a case of its own in the harness, checked bit for bit, and in+ `vk-tier-check`.- int4 weights decode as offset-binary (nibbleβ8), byte-identical layout tothe CPU path β no repacking.- Khronos validation layers: the backend never enables them, so the loader