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

loader: available_device_count is an optional export with a fallback

JustVugg28e988bbe885
diff --git a/c/backend_loader.c b/c/backend_loader.c
index 6932c649..91bc5cc3 100644
--- a/c/backend_loader.c
+++ b/c/backend_loader.c
@@ -1405,7 +1405,6 @@ static int coli_cuda_load(void){
RESOLVE(init, fn_init)
RESOLVE(shutdown, fn_shutdown)
RESOLVE(device_count, fn_device_count)
- RESOLVE(available_device_count, fn_available_device_count)
RESOLVE(device_at, fn_device_at)
RESOLVE(mem_info, fn_mem_info)
/* Optional: a DLL predating #653 leaves this NULL; the wrapper then reports
@@ -1430,6 +1429,7 @@ static int coli_cuda_load(void){
* nothing by this name, and the wrapper's 0 is the engine's own "fall back
* to CPU" result, so an older DLL still serves GLM and Qwen3.6 (#1405). */
RESOLVE_OPT(matmul_mxfp4, fn_matmul_mxfp4)
+ RESOLVE_OPT(available_device_count, fn_available_device_count) /* qwen36 tier (#1533); older DLLs fall back to device_count */
RESOLVE(tensor_free, fn_tensor_free)
RESOLVE(tensor_bytes, fn_tensor_bytes)
/* Optional, same reasoning as e8_set_grid above: a DLL predating #687
@@ -1521,6 +1521,7 @@ int coli_cuda_device_count(void){
* tier in failed to link (#1533). */
int coli_cuda_available_device_count(void){
if(!g_cuda.available) return 0;
+ if(!g_cuda.available_device_count) return g_cuda.device_count(); /* a DLL from before the export */
return g_cuda.available_device_count();
}
diff --git a/c/tests/test_backend_loader.py b/c/tests/test_backend_loader.py
index ec07d04f..6ce68e97 100644
--- a/c/tests/test_backend_loader.py
+++ b/c/tests/test_backend_loader.py
@@ -874,7 +874,7 @@ class LoaderStubFixtureTest(unittest.TestCase):
cls.fixture = None
def test_abi_is_derived_from_the_loader_source(self):
- """47 mandatory + 7 optional, parsed from backend_loader.c.
+ """47 mandatory + 8 optional, parsed from backend_loader.c.
The counts are a deliberate tripwire: adding a RESOLVE to the loader
widens the ABI every Windows DLL must satisfy, and that should be a
@@ -885,7 +885,7 @@ class LoaderStubFixtureTest(unittest.TestCase):
"""
f = self.fixture
self.assertEqual(len(f.mandatory), 47)
- self.assertEqual(len(f.optional), 7) # +matmul_mxfp4 (kimi_k3 via the DLL, #1405)
+ self.assertEqual(len(f.optional), 8) # +matmul_mxfp4 (kimi_k3 via the DLL, #1405), +available_device_count (qwen36 tier, #1533)
self.assertEqual(len(f.exports), 54)
self.assertEqual(len(f.exports), len(f.mandatory) + len(f.optional))
self.assertIn("coli_cuda_init", f.mandatory)