Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦
C
qwen38: rebuild the trunk table per load; the fixture checks run the int8 trunk too
JustVugg85b7943dbe17
diff --git a/c/Makefile b/c/Makefileindex 2d487fa1..e51266e8 100644--- a/c/Makefile+++ b/c/Makefile@@ -1144,9 +1144,13 @@ qwen38-ple-prefetch-check: qwen38-tiny-generate qwen38$(EXE)done; done; done; \[ $$fail -eq 0 ] && echo "PLE prefetch: identical tokens on and off, 16 configurations" || exit 1+# Q38_TRUNK_MIN_KB=0 puts every dense matrix of the fixture (all under the+# default 1 MiB threshold) on the int8 trunk with integer dot products, the+# path the released checkpoint takes; 1024 leaves them BF16.qwen38-tiny-check: qwen38-tiny-generate qwen38$(EXE)- @for batch in 0 1; do for bf16 in 0 1; do for cap in 1 4; do \- Q38_PREFILL_BATCH=$$batch Q38_NATIVE_BF16=$$bf16 OMP_NUM_THREADS=2 SNAP=./qwen38_tiny ./qwen38$(EXE) $$cap 8 ./qwen38_tiny/ref.json || exit $$?; \+ @for trunk in 1024 0; do for batch in 0 1; do for bf16 in 0 1; do for cap in 1 4; do \+ Q38_TRUNK_MIN_KB=$$trunk Q38_PREFILL_BATCH=$$batch Q38_NATIVE_BF16=$$bf16 OMP_NUM_THREADS=2 SNAP=./qwen38_tiny ./qwen38$(EXE) $$cap 8 ./qwen38_tiny/ref.json || exit $$?; \+ done; \done; \done; \done@@ -1160,8 +1164,9 @@ qwen38-tiny-fp8-generate:$(PYTHON) tools/make_qwen38_tiny.py --out ./qwen38_tiny_fp8 --fp8-expertsqwen38-tiny-fp8-check: qwen38-tiny-fp8-generate qwen38$(EXE)- @for native in 1 0; do for cap in 1 2; do \- Q38_NATIVE_FP8=$$native OMP_NUM_THREADS=2 SNAP=./qwen38_tiny_fp8 ./qwen38$(EXE) $$cap 8 ./qwen38_tiny_fp8/ref.json || exit $$?; \+ @for trunk in 1024 0; do for native in 1 0; do for cap in 1 2; do \+ Q38_TRUNK_MIN_KB=$$trunk Q38_NATIVE_FP8=$$native OMP_NUM_THREADS=2 SNAP=./qwen38_tiny_fp8 ./qwen38$(EXE) $$cap 8 ./qwen38_tiny_fp8/ref.json || exit $$?; \+ done; \done; \donediff --git a/c/qwen38_core.h b/c/qwen38_core.hindex 34052a0d..221f9bcd 100644--- a/c/qwen38_core.h+++ b/c/qwen38_core.h@@ -140,6 +140,7 @@ typedef struct {int native_fp8, native_bf16, expert_prefetch, expert_parallel_reads;int prefill_batch;uint64_t resident_weight_bytes;+ int trunk_table_built; /* q38_trunk_offer_all ran for this load (the table is process-wide, the model is not) */double dense_load_s;/* vision. `vis_map` mappa la posizione ASSOLUTA nella sequenza alla riga di* `vis_rows`, oppure -1. Assoluta e non relativa al chunk: il prefill arriva@@ -1827,7 +1828,7 @@ static int q38_trunk_enabled(void) {* The same table feeds the CPU's int8 rows; the placer is told about the* matrices only when the GPU trunk is enabled (Q38_TRUNK_GPU). */static void q38_trunk_offer_all(Model *m) {- if(g_trunk_n)return;+ g_trunk_n=0; m->trunk_table_built=1; /* rebuilt per load: a test opens several models in one process */g_trunk_offer_gpu=q38_trunk_enabled();Cfg *c=&m->c;q38_trunk_add(&m->lm_head,"lmhead",0);@@ -1879,7 +1880,7 @@ static int q38_trunk_cpu_int8_wanted(void) {}static void q38_trunk_cpu_int8(Model *m) {if(!q38_trunk_cpu_int8_wanted())return;- q38_trunk_offer_all(m);+ if(!m->trunk_table_built)q38_trunk_offer_all(m); /* the tier may have built it already */double t0=now_s(); size_t bytes=0,released=0; int n=0;for(int i=0;i<g_trunk_n;i++){Q38Weight *w=g_trunk[i].w;