Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦
C
test: guard router benchmark equivalence
EricSpencer00855baac929bf
diff --git a/c/tests/bench_router_select.c b/c/tests/bench_router_select.cindex 6e79af07..44902ecf 100644--- a/c/tests/bench_router_select.c+++ b/c/tests/bench_router_select.c@@ -2,8 +2,8 @@** This measures only top-K expert selection. The input is prepared before each* timed call, and both arms use the same finite score arrays and fallback path.- * The full run uses 11 seeds and 2,000 repetitions per cell; correctness is- * covered separately by test_router_nan.c.+ * The full run uses 11 seeds and 2,000 repetitions per cell. Each cell also+ * checks that both selectors return the same ordered expert ids before timing.*/#define main coli_glm_main_unused#include "../colibri.c"@@ -81,6 +81,19 @@ static double bench_new(const float *choice, int E, int K, int *idx, float *workreturn samples[N_REPEAT/2];}+static int verify_selection(const float *choice, int E, int K, int layer){+ int old_idx[32], new_idx[32]; float work[256];+ select_old(choice,E,K,old_idx,layer);+ memcpy(work,choice,(size_t)E*sizeof(float));+ router_select_topk(work,E,K,new_idx,layer);+ for(int kk=0;kk<K;kk++) if(old_idx[kk]!=new_idx[kk]){+ fprintf(stderr,"selection mismatch: E=%d K=%d slot=%d old=%d new=%d\n",+ E,K,kk,old_idx[kk],new_idx[kk]);+ return 0;+ }+ return 1;+}+int main(void){const int cases[][2]={{64,8},{256,8},{256,32}};const char *shapes[]={"random","peaked","plateau"};@@ -95,6 +108,7 @@ int main(void){for(int seed=0;seed<N_SEEDS;seed++){seed_rng(0xA5A5A5A5u+(uint32_t)(seed*0x9E3779B9u));fill_scores(choice,E,shape);+ if(!verify_selection(choice,E,K,0)) return 2;old_seed[seed]=bench_old(choice,E,K,idx);new_seed[seed]=bench_new(choice,E,K,idx,work);}diff --git a/docs/experiments/sparse-routing-2026-09-13.json b/docs/experiments/sparse-routing-2026-09-13.jsonindex c94c7756..f088f83f 100644--- a/docs/experiments/sparse-routing-2026-09-13.json+++ b/docs/experiments/sparse-routing-2026-09-13.json@@ -21,14 +21,14 @@"samples": {"tok_s": [1000000.0,- 250000.0,- 14084.50704225352,+ 200000.0,+ 13333.333333333334,1000000.0,200000.0,- 14084.50704225352,+ 10752.68817204301,1000000.0,200000.0,- 12987.012987012987+ 10204.08163265306]},"median_tok_s": 200000.0,@@ -38,7 +38,7 @@},"evidence": {"uri": "docs/experiments/sparse-routing-2026-09-13.txt",- "sha256": "350dc67288a496f8eab469a1b4feca5619d8f169ad0cb0bd0a9d37f1e7abc7a2"+ "sha256": "9815b4437e0beeb7a2731cf3deadd21f4bf8266cbfc7c83ac558556d7466c3bd"}},"trial": {@@ -53,10 +53,10 @@76923.07692307692,1000000.0,250000.0,- 71428.57142857143,+ 58823.5294117647,1000000.0,333333.3333333333,- 83333.33333333333+ 62500.0]},"median_tok_s": 333333.3333333333,@@ -66,7 +66,7 @@},"evidence": {"uri": "docs/experiments/sparse-routing-2026-09-13.txt",- "sha256": "350dc67288a496f8eab469a1b4feca5619d8f169ad0cb0bd0a9d37f1e7abc7a2"+ "sha256": "9815b4437e0beeb7a2731cf3deadd21f4bf8266cbfc7c83ac558556d7466c3bd"}},"outcome": "improvement"diff --git a/docs/experiments/sparse-routing-2026-09-13.txt b/docs/experiments/sparse-routing-2026-09-13.txtindex 81b83aa5..7ad32049 100644--- a/docs/experiments/sparse-routing-2026-09-13.txt+++ b/docs/experiments/sparse-routing-2026-09-13.txt@@ -26,14 +26,14 @@ bench_router_select: old duplicate scan vs marked-score scan (median of 11 seedsshape E K old ns/call new ns/call speedup---------------------------------------------------------------------random 64 8 1000 1000 1.00x-random 256 8 4000 3000 1.33x-random 256 32 71000 13000 5.46x+random 256 8 5000 3000 1.67x+random 256 32 75000 13000 5.77xpeaked 64 8 1000 1000 1.00xpeaked 256 8 5000 4000 1.25x-peaked 256 32 71000 14000 5.07x+peaked 256 32 93000 17000 5.47xplateau 64 8 1000 1000 1.00xplateau 256 8 5000 3000 1.67x-plateau 256 32 77000 12000 6.42x+plateau 256 32 98000 16000 6.13xbench_router_select: done (lower ns is better; speedup = old/new)Full DSA benchmark output (11 seeds x 2,000 repetitions per cell):