Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦
C
coli doctor: the checks that apply to a decision model
JustVugg14fb3160cb34
diff --git a/c/coli b/c/coliindex 6401cb61..2f52874b 100755--- a/c/coli+++ b/c/coli@@ -1504,6 +1504,11 @@ def cmd_doctor(a):report=run_image_doctor(a.model, engine)print(json.dumps(report,indent=2) if a.json else format_doctor(report))return exit_code(report)+ if is_decision_model(a.model) and engine_error is None:+ from doctor import run_decision_doctor+ report=run_decision_doctor(a.model, engine)+ print(json.dumps(report,indent=2) if a.json else format_doctor(report))+ return exit_code(report)report=run_doctor(# engine_path was hardcoded to GLM, so `coli doctor` inspected colibri# no matter which model it was pointed at: a built kimi_k3/inkling wasdiff --git a/c/doctor.py b/c/doctor.pyindex fd58b0c9..ce78fa0d 100644--- a/c/doctor.py+++ b/c/doctor.py@@ -839,6 +839,68 @@ def run_image_doctor(model, engine_path, available_memory=None):"checks": checks, "plan": None, "image_plan": plan}+def run_decision_doctor(model, engine_path, available_memory=None):+ """doctor for a decision model (Laya): no root config.json, no experts and+ no KV state. What can be wrong is a missing file of the checkpoint, an+ engine that is not built, or weights that do not fit in RAM as f32."""+ import json+ import struct+ model = Path(model).expanduser().resolve()+ checks = []+ readable = model.is_dir() and os.access(model, os.R_OK)+ checks.append(_check("model.path", "pass" if readable else "fail",+ "model directory is readable" if readable else+ "model directory is missing or not readable", path=str(model)))+ try:+ resolved = resolve_model(model)+ checks.append(_check("model.family", "pass",+ f"{resolved.descriptor.display_name} decision model is registered",+ family_id=resolved.descriptor.id, model_type=resolved.model_type,+ descriptor=public_metadata(resolved.descriptor)))+ tokenizer_file = resolved.descriptor.tokenizer_file+ except (FamilyConfigError, UnknownFamilyError) as error:+ checks.append(_check("model.family", "fail", str(error)))+ tokenizer_file = "tokenizer/tokenizer.json"+ for name in (tokenizer_file, "tokenizer/tokenizer_config.json", "encoder/config.json"):+ present = (model / name).is_file()+ checks.append(_check("model.files", "pass" if present else "fail",+ f"{name} found" if present else f"{name} is missing"))+ engine = Path(engine_path)+ engine_ok = engine.is_file() and (sys.platform == "win32" or os.access(engine, os.X_OK))+ checks.append(_check("engine.binary", "pass" if engine_ok else "fail",+ "engine executable is ready" if engine_ok else "engine is not built",+ path=str(engine)))+ try:+ with open(model / "model.safetensors", "rb") as handle:+ size = struct.unpack("<Q", handle.read(8))[0]+ if size > 64 << 20:+ raise ValueError("model.safetensors: implausible header size")+ header = json.loads(handle.read(size))+ params = 0+ for name, entry in header.items():+ if name != "__metadata__" and isinstance(entry, dict):+ count = 1+ for dim in entry.get("shape", []):+ count *= int(dim)+ params += count+ needed = params * 4+ available_memory = memory_available() if available_memory is None else available_memory+ if not available_memory:+ status, summary = "warn", "available RAM could not be measured"+ elif needed < available_memory:+ status, summary = "pass", f"{needed / 1e9:.1f} GB of f32 weights fit in RAM"+ else:+ status, summary = "fail", f"{needed / 1e9:.1f} GB of f32 weights do not fit in RAM"+ checks.append(_check("memory.ram", status, summary, available_bytes=available_memory,+ weight_bytes=needed, params=params))+ except (OSError, ValueError, struct.error) as error:+ checks.append(_check("model.weights", "fail", f"model.safetensors: {error}"))+ statuses = {item["status"] for item in checks}+ status = "error" if "fail" in statuses else "warning" if "warn" in statuses else "ok"+ return {"schema_version": 1, "status": status, "model": str(model), "mode": "standard",+ "checks": checks, "plan": None}++def format_doctor(report):icons = {"pass": "ok", "warn": "warn", "fail": "fail", "skip": "skip"}# model is null in the JSON when none was given (#724); say that rather than "None"diff --git a/c/tests/test_decision_serve.py b/c/tests/test_decision_serve.pyindex 3820d66e..c1aba8fd 100644--- a/c/tests/test_decision_serve.py+++ b/c/tests/test_decision_serve.py@@ -313,6 +313,56 @@ class DecisionGateway(unittest.TestCase):self.assertIn("only 3 of its 30", error["error"]["message"])+class DecisionRegistryAndLauncher(unittest.TestCase):+ """A Laya checkpoint has no root config.json: the registry knows it by its+ rl_agent_config.json and its encoder's config, and coli describes it and+ refuses to chat with it."""++ def checkpoint(self, encoder):+ import tempfile+ directory = tempfile.TemporaryDirectory()+ self.addCleanup(directory.cleanup)+ root = Path(directory.name)+ (root / "encoder").mkdir()+ (root / "rl_agent_config.json").write_text(json.dumps({"head_layers": 2}), encoding="utf-8")+ (root / "encoder" / "config.json").write_text(json.dumps(encoder), encoding="utf-8")+ return root++ def test_the_registry_knows_a_laya_checkpoint(self):+ from family_registry import UnknownFamilyError, default_model_id, display_for, resolve_model+ english = resolve_model(self.checkpoint({"model_type": "modernbert", "hidden_size": 1024,+ "num_hidden_layers": 28}))+ self.assertEqual((english.descriptor.id, english.descriptor.modality), ("laya", "decision"))+ self.assertTrue(english.descriptor.capabilities.decision)+ self.assertEqual(display_for(english), ("Laya", "421M"))+ multilingual = resolve_model(self.checkpoint({"model_type": "modernbert", "hidden_size": 768,+ "num_hidden_layers": 22}))+ self.assertEqual(display_for(multilingual), ("Laya multilingual", "322M"))+ self.assertEqual(default_model_id(multilingual), "laya-multilingual")+ with self.assertRaises(UnknownFamilyError):+ resolve_model(self.checkpoint({"model_type": "deberta-v2"}))++ def test_coli_describes_it_and_refuses_to_chat(self):+ import subprocess+ if not (FIXTURE / "rl_agent_config.json").exists():+ self.skipTest("laya_tiny missing")+ def coli(*args):+ return subprocess.run([sys.executable, str(HERE / "coli"), *args], capture_output=True,+ text=True, timeout=120, cwd=str(HERE))+ info = coli("info", "--model", str(FIXTURE))+ self.assertIn("decision model", info.stdout)+ plan = coli("plan", "--model", str(FIXTURE), "--json")+ self.assertEqual(json.loads(plan.stdout)["modality"], "decision")+ doctor = json.loads(coli("doctor", "--model", str(FIXTURE), "--json").stdout)+ self.assertIn({"id": "model.family", "status": "pass"},+ [{"id": c["id"], "status": c["status"]} for c in doctor["checks"]])+ for command in (("chat", "--model", str(FIXTURE), "--no-attach"),+ ("run", "--model", str(FIXTURE), "hello")):+ refused = coli(*command)+ self.assertNotEqual(refused.returncode, 0)+ self.assertIn("POST /v1/systemone", refused.stdout + refused.stderr)++def _laya_ready():return (FIXTURE / "model.safetensors").exists() and BINARY.exists()