Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦
C
setup: a rerun switches to the GPU once its packages are installed
JustVugg17a823255d0e
diff --git a/c/setup_catalog.py b/c/setup_catalog.pyindex 240a367b..a2e27a5b 100644--- a/c/setup_catalog.py+++ b/c/setup_catalog.py@@ -273,5 +273,5 @@ def as_dict(row):}-FITS_EXPLAINED = ("fits = the always-resident weights (the dense part) plus a minimum "- "expert cache fit in RAM, and the download fits on the disk")+FITS_EXPLAINED = ("fits = the dense part, which always stays in RAM, plus a minimum expert "+ "cache fit in RAM, and the download fits on the disk")diff --git a/c/setup_flow.py b/c/setup_flow.pyindex c6f84e9a..793d8ffb 100644--- a/c/setup_flow.py+++ b/c/setup_flow.py@@ -289,7 +289,7 @@ def choose_backend(hw, family, tc, requested="auto"):return decisionif cuda_engine:needs = ["cuda"] if tc.get("can_build") else ["build", "cuda"]- decision["missing"].append(("cuda", package_hint(needs, hw.get("os"))))+ decision["missing"].append(("cuda", _gpu_hint(needs, hw, tc)))elif requested == "cuda" and not cuda_engine:decision["missing"].append(("cuda", f"{family.display_name} has no CUDA path here; ""Vulkan or the CPU run it"))@@ -300,8 +300,7 @@ def choose_backend(hw, family, tc, requested="auto"):reason=f"{vk['name']} ({kind}) through Vulkan")return decisionneeds = ["vulkan"] if tc.get("can_build") else ["build", "vulkan"]- if tc.get("source_checkout") or sys.platform == "win32":- decision["missing"].append(("vulkan", package_hint(needs, hw.get("os"))))+ decision["missing"].append(("vulkan", _gpu_hint(needs, hw, tc)))if not vk and not nvidia:decision["reason"] = "no GPU found: the engine runs on the CPU"elif requested == "vulkan" and not vk:@@ -311,6 +310,15 @@ def choose_backend(hw, family, tc, requested="auto"):return decision+def _gpu_hint(needs, hw, tc):+ hint = package_hint(needs, hw.get("os"))+ if not tc.get("source_checkout"):+ # A release archive has the engines but no Makefile to rebuild them.+ hint += (" ; then run the setup from a source checkout "+ "(git clone https://github.com/JustVugg/colibri)")+ return hint++def binary_links(path, needles):"""Does the binary name one of these libraries? Cheap and portable: thedynamic section (ELF), import table (PE) or load commands (Mach-O) all carry@@ -999,7 +1007,8 @@ def choose_model(ui, rows, wanted=None, show_all=False):if not fitting:raise SetupError("no model in the catalog fits this machine:\n" +"\n".join(f" {r['entry'].name}: {r['reason']}" for r in rows))- ui.say(f"Models that fit ({setup_catalog.FITS_EXPLAINED}):")+ ui.say("Models that fit this machine")+ ui.say(f" ({setup_catalog.FITS_EXPLAINED})")for number, row in enumerate(fitting, 1):entry = row["entry"]runs = "runs from RAM" if entry.size_class == "small" else "streams from the SSD"@@ -1152,6 +1161,17 @@ def describe_existing(cfg):return f"{model.get('name') or cfg.get('family')} in {cfg.get('model_dir')} ({cfg.get('backend')})"+def gpu_now_buildable(cfg, tc=None):+ """True when the last setup ran on the CPU for want of a GPU package and+ that package is here now. Looks at the toolchain only: no hardware probe,+ so a plain rerun stays a fast start."""+ pending = cfg.get("gpu_pending") or []+ if not pending or cfg.get("backend") != "cpu":+ return False+ tc = tc or toolchain()+ return any(tc.get(f"can_build_{kind}") for kind in pending)++def config_ready(cfg):if not cfg or cfg.get("status") != "ready":return False@@ -1182,8 +1202,11 @@ def cmd_setup(a, ui=None):return 0if cfg and not picking and config_ready(cfg):- ui.say(f"Already set up: {describe_existing(cfg)}")- return _finish(ui, cfg, a)+ if gpu_now_buildable(cfg):+ ui.say("The GPU packages are installed now: rebuilding the engine for the GPU.\n")+ else:+ ui.say(f"Already set up: {describe_existing(cfg)}")+ return _finish(ui, cfg, a)# A setup that stopped half way (pending), or a finished one whose engine or# files went missing (ready, but not runnable): continue with the same choice.resume = cfg if (cfg and cfg.get("status") in ("pending", "ready") and not picking) else None@@ -1274,6 +1297,10 @@ def cmd_setup(a, ui=None):cfg = make_config(model_dir=model_dir, family=family, entry=entry, engine_info=engine_info,hw=hw, host=host, port=port)cfg["requested_backend"] = requested+ # A GPU this setup found but could not build for: a rerun checks whether+ # the packages arrived and rebuilds (gpu_now_buildable).+ cfg["gpu_pending"] = ([kind for kind, _hint in decision["missing"]]+ if engine_info["backend"] == "cpu" and requested == "auto" else [])cfg = save_config(cfg)write_state("ready", model=cfg["model"].get("id"), model_dir=model_dir)ui.say(f"\nSaved the run configuration: {config_path()}")diff --git a/c/tests/test_setup_flow.py b/c/tests/test_setup_flow.pyindex dd251c5e..44af7afa 100644--- a/c/tests/test_setup_flow.py+++ b/c/tests/test_setup_flow.py@@ -140,6 +140,7 @@ class BackendChoice(unittest.TestCase):self.assertIn("msys2.org", hint)self.assertIn("mingw-w64-ucrt-x86_64-gcc", hint)self.assertIn("mingw-w64-ucrt-x86_64-shaderc", hint)+ self.assertIn("source checkout", hint) # a release archive cannot rebuild itselfclass PackageHints(unittest.TestCase):@@ -469,6 +470,33 @@ class WholeSetup(HomeTestCase):build.assert_called_once()self.assertEqual(sum("/cdn/" in r["path"] for r in self.hub.requests), shard_fetches)+ def test_a_rerun_switches_to_the_gpu_once_its_packages_are_there(self):+ no_vulkan = dict(TC_ALL, vulkan_headers=False, glslc=None, can_build_vulkan=False)+ Path(self.engines, "qwen36").write_bytes(b"\x7fELF plain") # a CPU build+ with mock.patch.object(setup_flow, "toolchain", return_value=no_vulkan):+ code, text = self.run_setup(pick="tiny")+ self.assertEqual(code, 0, text)+ self.assertIn("to use the GPU through VULKAN, first run:", text)+ cfg = setup_flow.load_config()+ self.assertEqual((cfg["backend"], cfg["gpu_pending"]), ("cpu", ["vulkan"]))+ # Still no packages: a rerun only starts.+ with mock.patch.object(setup_flow, "toolchain", return_value=no_vulkan):+ code, text = self.run_setup()+ self.assertIn("Already set up", text)++ def rebuild(family, backend, tc, out=print):+ self.assertEqual(backend, "vulkan")+ Path(self.engines, "qwen36").write_bytes(b"libvulkan.so.1")+ return os.path.join(self.engines, "qwen36")++ with mock.patch.object(setup_flow, "build_engine", side_effect=rebuild):+ code, text = self.run_setup() # the packages are here now+ self.assertEqual(code, 0, text)+ self.assertIn("rebuilding the engine for the GPU", text)+ cfg = setup_flow.load_config()+ self.assertEqual((cfg["backend"], cfg["gpu_pending"]), ("vulkan", []))+ self.assertEqual(cfg["env"]["COLI_VULKAN"], "1")+def test_wsl_download_through_windows_when_faster(self):entry = setup_catalog.by_id("tiny")files = [{"path": "model-00000.safetensors", "size": 400_000}]