Skip to content

Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦

C

tests(tier): the two remaining exp_bytes assertions follow the allocator footprint

kreuzzelg823caa8a762a
diff --git a/c/tests/test_qwen36_tier_int8.c b/c/tests/test_qwen36_tier_int8.c
index 8fae78d7..c893a0a7 100644
--- a/c/tests/test_qwen36_tier_int8.c
+++ b/c/tests/test_qwen36_tier_int8.c
@@ -48,7 +48,10 @@ int main(void) {
return 1;
}
check(G.wfmt == 1, "int8 deve usare fmt=1");
- check(G.exp_bytes > 3ull * D * IH,
+ /* charged at the allocator's granularity: three int8 matrices of D*IH
+ * bytes each plus three per-row scale tables */
+ check(G.exp_bytes == 3 * dev_alloc_footprint((size_t)D * IH)
+ + 3 * dev_alloc_footprint((2 * G.sc_gu + G.sc_d) / 3 * sizeof(float)),
"il budget int8 deve contare un byte per elemento, non mezzo");
int layers[8], eids[8];
@@ -91,7 +94,8 @@ int main(void) {
return 1;
}
check(G.wfmt == 4, "int4 deve restare fmt=4");
- check(G.exp_bytes < 3ull * D * IH + 4096 + (2 * G.sc_gu + G.sc_d) * sizeof(float),
+ check(G.exp_bytes == 3 * dev_alloc_footprint((size_t)D * IH / 2)
+ + 3 * dev_alloc_footprint((2 * G.sc_gu + G.sc_d) / 3 * sizeof(float)),
"int4 impacchettato deve contare mezzo byte per elemento");
qt_shutdown();
diff --git a/c/tests/test_qwen36_tier_shutdown.c b/c/tests/test_qwen36_tier_shutdown.c
index af8faf7b..f01d1f25 100644
--- a/c/tests/test_qwen36_tier_shutdown.c
+++ b/c/tests/test_qwen36_tier_shutdown.c
@@ -70,9 +70,12 @@ int main(void) {
setenv("COLI_CUDA", "1", 1);
setenv("COLI_GPUS", "0", 1);
setenv("QT_NO_WARMSTART", "1", 1);
- /* exp_bytes = 3*D*IH/2 + (2*IH+D)*4 + 4096 = 3072+512+4096 = 7680 B.
- * 0.00001 GiB ~= 10737 B: enough for one expert (7680), not two (15360). */
- setenv("CUDA_EXPERT_GB", "0.00001", 1);
+ /* budget for one expert and a half, at the allocator's granularity (three
+ * int4 matrices of D*32/2 bytes plus three scale tables, each charged
+ * what cudaMalloc takes): enough for one expert, not two */
+ size_t exp_bytes = 3 * dev_alloc_footprint((size_t)D * 32 / 2) + 3 * dev_alloc_footprint((2 * 32 + D) / 3 * sizeof(float));
+ char gb[64]; snprintf(gb, sizeof gb, "%.15f", (double)(exp_bytes + exp_bytes / 2) / 1073741824.0);
+ setenv("CUDA_EXPERT_GB", gb, 1);
fake_ndev = 1;
if (!qt_init(1, 2, D, 32, 2, 1, 0 /* per-row */, 1 /* int4 */)) {