Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦
C
ci(qwen36), docs: the mixed expert layout on the tiny fixture, and the #1370 numbers in "Which container?"
kreuzzelge1d51beb94a2
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 32c7c79e..37d35906 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -547,6 +547,31 @@ jobs:echo "cap=$cap: identical ($(cat ids_${cap}_1.txt))"donemake tests/test_expert_ffn && ./tests/test_expert_ffn+ - name: Mixed expert layout (int4 gs64 gate/up, int8 down) loads and is cap-independent+ run: |+ cd c+ # The #1370 experiment knob: one slab per expert with int4 gate/up and int8+ # down (2*inter*hidden bytes). The engine must tell it apart from int4 and+ # int8 by size, read every matrix in its own format, and give the same ids+ # at every cache capacity (cap=1 recycles the single slot after each expert,+ # which is where a wrong slab offset would show). The ids are not compared to+ # the torch oracle: int4 gate/up drift from f32 by design, as in the A/B above.+ python3 tools/convert_qwen36.py --model qwen36_tiny64 --out qwen36_tiny64_d8 --ebits 4 --gs 64 --down-bits 8+ python3 - <<'PY'+ import json; m = json.load(open("qwen36_tiny64_d8/qwen36_meta.json"))+ assert m["expert_down_bits"] == 8 and m["expert_down_gs"] == 0 and m["expert_gs"] == 64, m+ PY+ for cap in 1 2 8; do+ COLI_DENSE_I8=0 SNAP=qwen36_tiny64_d8 ./qwen36 "$cap" 4 qwen36_tiny64/ref_full.json > mixed_$cap.log 2>&1 || true+ grep -q "expert format on disk: int4 gate/up + int8 down" mixed_$cap.log || { echo "FAIL: mixed layout not detected at cap=$cap"; cat mixed_$cap.log; exit 1; }+ grep -E "^C engine" mixed_$cap.log > mixed_ids_$cap.txt+ test -s mixed_ids_$cap.txt || { echo "FAIL: no ids at cap=$cap"; cat mixed_$cap.log; exit 1; }+ done+ cmp mixed_ids_1.txt mixed_ids_8.txt && cmp mixed_ids_2.txt mixed_ids_8.txt || { echo "FAIL: ids differ across caps"; cat mixed_ids_*.txt; exit 1; }+ echo "mixed layout: identical ids at cap 1/2/8 ($(cat mixed_ids_8.txt))"+ # COLI_CUDA=1 on a mixed container is refused with a line, the CPU path stands+ COLI_CUDA=1 COLI_DENSE_I8=0 SNAP=qwen36_tiny64_d8 ./qwen36 8 4 qwen36_tiny64/ref_full.json > mixed_cuda.log 2>&1 || true+ grep -q "COLI_CUDA=1 ignored: the VRAM expert tier does not take the mixed layout" mixed_cuda.log || { echo "FAIL: tier refusal line missing"; cat mixed_cuda.log; exit 1; }- name: A malformed container is refused, not readrun: |cd cdiff --git a/docs/qwen36.md b/docs/qwen36.mdindex c23f7871..98dd906e 100644--- a/docs/qwen36.md+++ b/docs/qwen36.md@@ -179,6 +179,19 @@ per-row quantization error concentrates the same way. The gs64 container costs~1.7 GB more on disk and a few percent on cold-start; warm decode speed is thesame or slightly better.+**Mixed: int8 `down`, int4 gate/up.** `convert_qwen36.py --ebits 4 --gs 64+--down-bits 8` (`--down-gs` for grouped down scales, 0 = per row) writes one+slab per expert with `down_proj` in int8 and gate/up as above -- 5.7 bits per+weight against gs64's 4.5. It is the knob that produced the #1370 numbers on+wikitext-2 (16 x 512 tokens): gs64 7.325, mixed 7.281, all experts int8 7.153,+Ollama's Q4_K_M 7.147 -- `down` alone recovers a quarter of the gap to int8,+the rest sits in gate/up, and at equal bits Q4_K_M's asymmetric quantizer is+ahead. Keep it as a measurement tool and a middle step for boxes with RAM to+spare; it is not the answer to the gap. The engine tells the layout apart by+size and reads each matrix in its own format on the CPU path; the CUDA VRAM+tier takes one format per expert and refuses a mixed container with a line+(`COLI_CUDA=1 ignored`), so such a container runs CPU-only for now.+## Which checkpoints, and what the banner calls themTwo Qwen checkpoints declare `model_type: qwen3_5_moe_text` and resolve to