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(planner): no qwen38 prediction on a device whose memory is unknown

JustVugg418e0aa5c402
diff --git a/c/resource_plan.py b/c/resource_plan.py
index 82a5c305..6881ccea 100644
--- a/c/resource_plan.py
+++ b/c/resource_plan.py
@@ -778,7 +778,13 @@ def _q38_vk_fmt(tensor, tag, env):
def _q38_chain_layout(info, env, vulkan):
- """qwen38_chain.h: q38c_fit_layer, q38c_fit_fixed, q38c_fit_tail."""
+ """qwen38_chain.h: q38c_fit_layer, q38c_fit_fixed, q38c_fit_tail. None for a device
+ whose memory the plan does not know (no budget, no heap size, no cap) unless N is
+ forced: no prediction, the plan as before (every layer and every host copy)."""
+ device = vulkan or {}
+ known = _vk_cap_bytes(env) or device.get("budget_bytes") or device.get("device_local_bytes")
+ if not known and (env.get("COLI_VK_CHAIN_LAYERS") or "").strip() in ("", "auto"):
+ return None
c = info.get("config") or {}
c = c.get("text_config") or c
try:
diff --git a/c/tests/test_resource_plan.py b/c/tests/test_resource_plan.py
index 7ef82c85..a2eca22e 100644
--- a/c/tests/test_resource_plan.py
+++ b/c/tests/test_resource_plan.py
@@ -2058,9 +2058,12 @@ class Qwen38PartialChainTest(unittest.TestCase):
c = dict(self.CONFIG, mtp_num_hidden_layers=1)
(self.model / "config.json").write_text(json.dumps(c))
info = dict(info, config=c)
- self.assertEqual(_q38_chain_layout(info, {"Q38_MTP": "1"}, None).tail, 43008)
- self.assertEqual(_q38_chain_layout(info, {"Q38_MTP": "1", "Q38_TRUNK_MIN_KB": "0"}, None).tail, 27392)
- self.assertEqual(_q38_chain_layout(info, {}, None).tail, 8960)
+ self.assertEqual(_q38_chain_layout(info, {"Q38_MTP": "1"}, device).tail, 43008)
+ self.assertEqual(_q38_chain_layout(info, {"Q38_MTP": "1", "Q38_TRUNK_MIN_KB": "0"}, device).tail, 27392)
+ self.assertEqual(_q38_chain_layout(info, {}, device).tail, 8960)
+ # a device whose memory the plan does not know: no prediction unless N is forced
+ self.assertIsNone(_q38_chain_layout(info, {}, {"type": "integrated"}))
+ self.assertIsNotNone(_q38_chain_layout(info, {"COLI_VK_CHAIN_LAYERS": "2"}, {"type": "integrated"}))
# COLI_VK_CHAIN_ROWS lowers the chunk the fit counts: the scratch and the attention
# layers' read-back rows
small = vk_chain_fit(info, "qwen38", dict(on, COLI_VK_CHAIN_ROWS="3"), device)