Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦
C
fix(autotune): COLI_NUMA is colibri.c's knob too
kevin9327535abbe8c718
diff --git a/c/autotune.py b/c/autotune.pyindex 6a22e0c3..b8f64e8b 100644--- a/c/autotune.py+++ b/c/autotune.py@@ -177,9 +177,10 @@ def save_profile(profile: dict, profile_dir: str | None = None) -> Path:def candidate_steps(plan: dict, base_env: dict, arch: str = "glm") -> list[tuple[str, dict]]:"""Return a bounded coordinate-descent sweep for this topology and engine.- `arch` gates the knobs that are not universal. OMP_NUM_THREADS and COLI_NUMA- are read by every engine (they are OpenMP and NUMA, not engine features), so- they are always eligible. PIPE and DIRECT are read by colibri alone --+ `arch` gates the knobs that are not universal. OMP_NUM_THREADS is read by+ every engine (it is OpenMP, not an engine feature), so it is always+ eligible. COLI_NUMA is not: it is colibri.c's own mbind of its expert slabs,+ and no other engine reads it. PIPE and DIRECT are read by colibri alone --`grep -c 'getenv("PIPE")'` is 3 in colibri.c and 0 in the other four -- sooffering them elsewhere would sweep candidates that cannot differ, spend thereplay budget proving it, and report a 0% gain as if it were a measurement@@ -192,7 +193,7 @@ def candidate_steps(plan: dict, base_env: dict, arch: str = "glm") -> list[tupleif threads != current_threads:steps.append((f"omp-{threads}", {"OMP_NUM_THREADS": str(threads)}))sockets = int(plan.get("cpu", {}).get("sockets", 1))- if sockets > 1 and base_env.get("COLI_NUMA") != "1":+ if sockets > 1 and arch == "glm" and base_env.get("COLI_NUMA") != "1":steps.append(("numa-on", {"COLI_NUMA": "1"}))has_gpu = bool(plan.get("tiers", {}).get("vram", {}).get("devices"))# Same rule for the CUDA knobs: COLI_CUDA_PIPE is read in colibri.c only,diff --git a/c/tests/test_autotune.py b/c/tests/test_autotune.pyindex 53e36f84..c1e40bf9 100644--- a/c/tests/test_autotune.py+++ b/c/tests/test_autotune.py@@ -108,25 +108,27 @@ class AutotuneUnitTest(unittest.TestCase):steps = dict(candidate_steps(plan, {}, arch))self.assertNotIn("direct-on", steps)self.assertNotIn("io-pipe-on", steps)- # OMP and NUMA are engine-agnostic and must survive, or the- # sweep has nothing left to measure on those engines.+ # OMP is engine-agnostic and must survive, or the sweep has+ # nothing left to measure on those engines.self.assertTrue(any(name.startswith("omp-") for name in steps), steps)- def test_cuda_knobs_are_not_swept_on_other_engines(self):- """COLI_CUDA_PIPE is read by colibri.c alone, and COLI_CUDA_ASYNC only- on the grouped-expert CUDA call colibri.c makes. A GPU in the plan- offered both to every engine, so a sibling tune measured identical- runs and could accept timing noise as a gain."""- gpu_plan = plan(gpu=True)+ def test_cuda_and_numa_knobs_are_not_swept_on_other_engines(self):+ """COLI_CUDA_PIPE and COLI_NUMA are read by colibri.c alone, and+ COLI_CUDA_ASYNC only on the grouped-expert CUDA call colibri.c makes.+ A GPU or a second socket in the plan offered them to every engine, so+ a sibling tune measured identical runs and could accept timing noise+ as a gain."""+ gpu_plan = plan(sockets=2, gpu=True)glm = dict(candidate_steps(gpu_plan, {}, "glm"))- for name in ("cuda-pipe-1", "cuda-pipe-2", "cuda-sync"):+ for name in ("numa-on", "cuda-pipe-1", "cuda-pipe-2", "cuda-sync"):self.assertIn(name, glm)for arch in ("glm53", "deepseek_v4", "deepseek_v41", "kimi", "inkling","olmoe", "qwen36", "qwen38"):with self.subTest(arch=arch):steps = dict(candidate_steps(gpu_plan, {}, arch))- self.assertFalse(any(name.startswith("cuda-") for name in steps), steps)- self.assertFalse({"COLI_CUDA_PIPE", "COLI_CUDA_ASYNC"}+ self.assertFalse(any(name.startswith(("cuda-", "numa-"))+ for name in steps), steps)+ self.assertFalse({"COLI_CUDA_PIPE", "COLI_CUDA_ASYNC", "COLI_NUMA"}& {key for change in steps.values() for key in change})self.assertTrue(any(name.startswith("omp-") for name in steps), steps)@@ -350,17 +352,17 @@ class ServeTuneTest(unittest.TestCase):self.assertEqual(FakeServeEngine.sessions,[["prompt-a", "prompt-b"]] * 4)- def test_sibling_tune_with_a_gpu_launches_no_cuda_candidates(self):+ def test_sibling_tune_with_a_gpu_and_two_sockets_launches_only_omp(self):FakeServeEngine.reset()- p = plan(cores=8, gpu=True)+ p = plan(cores=8, sockets=2, gpu=True)p["tiers"]["ram"] = {"cache_slots_per_layer": 16}profile, _ = self.run_serve_tune(arch="qwen36", plan=p,prompts=("prompt-a", "prompt-b"))names = [candidate["name"] for candidate in profile["candidates"]]self.assertEqual(names, ["baseline", "omp-4"])for launch in FakeServeEngine.launches:- self.assertNotIn("COLI_CUDA_PIPE", launch["env"])- self.assertNotIn("COLI_CUDA_ASYNC", launch["env"])+ for key in ("COLI_CUDA_PIPE", "COLI_CUDA_ASYNC", "COLI_NUMA"):+ self.assertNotIn(key, launch["env"])self.assertEqual(len(FakeServeEngine.launches), 4)def test_candidate_that_changes_output_is_disqualified(self):