Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦
C
qwen38 int4-g64: measured on the release, gated in CI
JustVugg27bc7cd345be
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex d3e8e19e..6dad14ae 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -1033,6 +1033,8 @@ jobs:run: make -C c qwen38-tiny-check- name: Routed experts as the release ships them (FP8 shards), then the engine on the fake CUDA tierrun: make -C c qwen38-tiny-fp8-check qwen38-tier-engine-check+ - name: Routed experts as int4-g64 from the converter's sidecar+ run: make -C c qwen38-tiny-int4-check- name: Repeat the eviction path under ASan and UBSanrun: |cd c@@ -1040,11 +1042,16 @@ jobs:ASAN_OPTIONS=detect_leaks=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- if grep -qE "ERROR: AddressSanitizer|runtime error:" qwen38-san.log; then- cat qwen38-san.log+ # the int4-g64 sidecar's load and matmul, evicting at cap 1+ ASAN_OPTIONS=detect_leaks=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+ cat qwen38-san.log qwen38-san-int4.logexit 1figrep -q "Matching tokens: 8/8" qwen38-san.log+ grep -q "Matching tokens: 8/8" qwen38-san-int4.log- name: Refuse config and tensor-shape disagreementrun: |cd cdiff --git a/c/tools/convert_fp8_to_int4.py b/c/tools/convert_fp8_to_int4.pyindex cedfc120..3906ab30 100644--- a/c/tools/convert_fp8_to_int4.py+++ b/c/tools/convert_fp8_to_int4.py@@ -48,12 +48,14 @@ GLM52_MODEL_TYPES = {"glm_moe_dsa", "glm5_moe", "glm"}OTHER_FAMILY_PATHS = {"glm5_next": "GLM-5.3-Flash: use tools/convert_glm53.py","glm5_next_text": "GLM-5.3-Flash: use tools/convert_glm53.py",- "qwen4_exp": "Qwen3.8-Flash-Next is NOT converted: download the official "- "FP8 checkpoint (Qwen/Qwen3.8-Flash-Next-FP8) and run it "- "directly; see docs/qwen38.md and issue #1304",- "qwen4_exp_text": "Qwen3.8-Flash-Next is NOT converted: download the official "- "FP8 checkpoint (Qwen/Qwen3.8-Flash-Next-FP8) and run it "- "directly; see docs/qwen38.md and issue #1304",+ "qwen4_exp": "Qwen3.8-Flash-Next is NOT converted by this tool: download the "+ "official FP8 checkpoint (Qwen/Qwen3.8-Flash-Next-FP8) and run it "+ "directly, optionally adding int4-g64 experts with "+ "tools/convert_qwen38_experts_int4.py; see docs/qwen38.md",+ "qwen4_exp_text": "Qwen3.8-Flash-Next is NOT converted by this tool: download the "+ "official FP8 checkpoint (Qwen/Qwen3.8-Flash-Next-FP8) and run it "+ "directly, optionally adding int4-g64 experts with "+ "tools/convert_qwen38_experts_int4.py; see docs/qwen38.md","qwen3_5_moe": "Qwen3.6: use tools/convert_qwen36.py","qwen3_5_moe_text":"Qwen3.6: use tools/convert_qwen36.py","qwen3_5": "Qwen3.8-27B (dense): use tools/convert_qwen36.py, see docs/qwen36.md",diff --git a/docs/qwen38.md b/docs/qwen38.mdindex 2be62741..dd3e61be 100644--- a/docs/qwen38.md+++ b/docs/qwen38.md@@ -184,8 +184,37 @@ w / scale, clamped to [-8, 7]. The codes are stored as v+8 in `expert_ffn.h`'splanar layout and multiplied by its f32 kernel, activations staying f32 as onthe FP8 path. On synthetic Gaussian weights at the release's geometry therelative L2 error is 10.9% per matrix; the converter prints the mean and the-worst per layer on the real weights. What that costs the model in perplexity-or answers has not been measured yet.+worst per layer on the real weights, where it measured 11-12% per layer and+17.5% for the worst single matrix.++Measured on the release (Ryzen 7 PRO 8700GE, 16 threads, 61 GiB, NVMe; the+same binary with `Q38_EXPERT_INT4=0` and `=1`, `OMP_NUM_THREADS=8`). Perplexity,+teacher-forced over four 504-token chunks at cap 96:++| chunk | FP8 | int4-g64 |+|---|---|---|+| 0 | 4.23 | 4.20 |+| 1 | 11.64 | 11.74 |+| 2 | 10.94 | 11.04 |+| 3 | 16.04 | 16.97 |++On average +0.017 nats per token. Three chunks move by under 1%; chunk 3 moves+by 5.8%. Greedy answers stay on the same reasoning with a few words changed.++Decode, 100 tokens of one prompt, the model's files dropped from the page cache+before every run, load average under 2.5:++| cap | FP8 | int4-g64 |+|---|---|---|+| 32 | 1.91 tok/s, 14.4 GB RSS, 45.8% hits | 2.87 tok/s, 11.6 GB, 46.4% |+| 64 | 2.27 tok/s, 21.4 GB, 59.1% | 3.25 tok/s, 15.2 GB, 59.4% |+| 96 | 2.56 tok/s, 28.5 GB, 68.0% | 3.55 tok/s, 19.2 GB, 67.8% |+| 170 | | 3.99 tok/s, 28.0 GB, 79.2% |++At the same cap int4 is 1.4-1.5x faster, because each miss reads 56% of the+bytes and the routed-expert compute halves (55 to 31 ms per decode forward at+cap 96). At the same RAM, FP8 at cap 96 (28.5 GB) against int4 at cap 170+(28.0 GB), it is 1.56x faster: the RAM that held 96 experts per layer holds 170.The converter streams: one expert per worker in flight, so peak RAM is a fewhundred MB for the writer (records queue there while the disk catches up; at