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

fix(doctor): recognize the expected Windows GPU backend

Kenneth-Javier Ortigozaad8a75be4155
diff --git a/c/doctor.py b/c/doctor.py
index 9f3252f3..02d8c2a6 100644
--- a/c/doctor.py
+++ b/c/doctor.py
@@ -365,18 +365,30 @@ def cuda_linkage(engine_path):
return {"linked": any("not found" not in line for line in lines),
"missing": any("not found" in line for line in lines)}
if sys.platform == "win32":
- # Windows CUDA_DLL=1 builds never link libcudart directly: glm.exe loads
- # coli_cuda.dll at runtime via LoadLibrary (backend_loader.c), so there's no
- # import-table entry for ldd/dumpbin to see. Detect the COLI_CUDA build via a
- # marker string baked into glm.c's #ifdef COLI_CUDA block instead, and require
- # coli_cuda.dll to actually sit next to glm.exe (else CUDA init fails at startup).
+ # Windows DLL-split builds never link the GPU runtime directly: the host
+ # LoadLibrary's its backend at runtime (backend_loader.c), so there's no
+ # import-table entry for ldd/dumpbin to see. Detect the GPU build via a
+ # marker string baked into the engine's #ifdef COLI_CUDA block, then
+ # require the backend artifact to sit next to the executable.
+ #
+ # WHICH artifact is not a guess. backend_loader.c compiles exactly one
+ # basename into the host -- COLI_BACKEND_DLL is "coli_hip.dll" under
+ # COLI_HIP_DLL and "coli_cuda.dll" otherwise -- so the binary states
+ # what it will load and we check for that. Asking for coli_cuda.dll
+ # unconditionally failed a working HIP host (a hard error, not a
+ # warning), and accepting either name would have passed a HIP host that
+ # only had a stray CUDA backend beside it.
try:
- built = b"[CUDA] mode: routed experts" in engine.read_bytes()
+ image = engine.read_bytes()
except OSError:
return {"linked": False, "missing": False}
- if not built:
+ if b"[CUDA] mode: routed experts" not in image:
return {"linked": False, "missing": False}
- dll_present = (engine.parent / "coli_cuda.dll").is_file()
+ expected = next((name for name in ("coli_hip.dll", "coli_cuda.dll")
+ if name.encode() in image), None)
+ if expected is None:
+ return {"linked": False, "missing": False}
+ dll_present = (engine.parent / expected).is_file()
return {"linked": dll_present, "missing": not dll_present}
return {"linked": False, "missing": False}
diff --git a/c/tests/test_doctor.py b/c/tests/test_doctor.py
index af35f172..418a734f 100644
--- a/c/tests/test_doctor.py
+++ b/c/tests/test_doctor.py
@@ -8,7 +8,7 @@ import unittest
from pathlib import Path
from unittest import mock
-from doctor import exit_code, format_doctor, run_doctor
+from doctor import cuda_linkage, exit_code, format_doctor, run_doctor
from resource_plan import GB
@@ -160,6 +160,73 @@ class DoctorTest(unittest.TestCase):
# #379: doctor surfaces the cached F_NOCACHE probe read-only (S4) -- it
# never re-measures storage itself, only reflects what colibri.c already wrote.
+ # --- Windows backend-artifact linkage ---------------------------------
+ # c/backend_loader.c compiles exactly one backend basename into the host:
+ # COLI_BACKEND_DLL is "coli_hip.dll" under COLI_HIP_DLL and "coli_cuda.dll"
+ # otherwise. So the binary states which artifact it will LoadLibrary, and
+ # doctor can check for that one instead of assuming CUDA. This validates the
+ # host/artifact contract only -- it says nothing about the runtime binding
+ # or about any GPU actually computing.
+
+ def _win_engine(self, backend_dll, artifacts=()):
+ engine = self.root / "colibri.exe"
+ engine.write_bytes(b"...[CUDA] mode: routed experts..."
+ + backend_dll.encode() + b"...")
+ for artifact in artifacts:
+ (self.root / artifact).write_bytes(b"")
+ return engine
+
+ def _win_linkage(self, engine):
+ with mock.patch.object(sys, "platform", "win32"), \
+ mock.patch.object(os, "name", "nt"):
+ return cuda_linkage(engine)
+
+ def test_windows_cuda_host_accepts_its_own_backend(self):
+ engine = self._win_engine("coli_cuda.dll", ["coli_cuda.dll"])
+ self.assertEqual(self._win_linkage(engine),
+ {"linked": True, "missing": False})
+
+ def test_windows_hip_host_accepts_its_own_backend(self):
+ engine = self._win_engine("coli_hip.dll", ["coli_hip.dll"])
+ self.assertEqual(self._win_linkage(engine),
+ {"linked": True, "missing": False})
+
+ def test_windows_hip_host_is_not_satisfied_by_the_cuda_backend(self):
+ engine = self._win_engine("coli_hip.dll", ["coli_cuda.dll"])
+ self.assertEqual(self._win_linkage(engine),
+ {"linked": False, "missing": True})
+
+ def test_windows_cuda_host_is_not_satisfied_by_the_hip_backend(self):
+ engine = self._win_engine("coli_cuda.dll", ["coli_hip.dll"])
+ self.assertEqual(self._win_linkage(engine),
+ {"linked": False, "missing": True})
+
+ def test_windows_missing_backend_artifact_still_fails(self):
+ engine = self._win_engine("coli_hip.dll")
+ self.assertEqual(self._win_linkage(engine),
+ {"linked": False, "missing": True})
+
+ def test_windows_cpu_only_engine_is_not_a_gpu_build(self):
+ engine = self.root / "colibri.exe"
+ engine.write_bytes(b"a plain CPU build with no backend loader")
+ self.assertEqual(self._win_linkage(engine),
+ {"linked": False, "missing": False})
+
+ def test_hip_host_with_its_backend_reports_gpu_available(self):
+ # End-to-end: the same host that previously reported a hard error
+ # ("GPU runtime library is missing") now passes, with #903's
+ # backend-neutral wording preserved.
+ engine = self._win_engine("coli_hip.dll", ["coli_hip.dll"])
+ report = self.report(gpu_indices=None, engine_path=engine,
+ gpus=[{"index": 0, "name": "AMD Radeon(TM) 8060S Graphics",
+ "total_bytes": 78 * GB, "free_bytes": None,
+ "unified_memory": True}],
+ linkage=self._win_linkage(engine))
+ check = self.checks_by_id(report)["accelerator.gpu"]
+ self.assertEqual(check["status"], "pass")
+ self.assertNotIn("CUDA", check["summary"])
+ self.assertNotIn("NVIDIA", check["summary"])
+
def test_ssd_probe_check_skips_when_not_yet_cached(self):
checks = self.checks_by_id(self.report())
self.assertEqual(checks["storage.ssd_probe"]["status"], "skip")