Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦
C
qwen36 planner: layer kinds from config, else qwen36_meta.json, else the interval
JustVuggaa5429b60efb
diff --git a/c/family_registry.py b/c/family_registry.pyindex a9cbb50b..a9a69dbe 100644--- a/c/family_registry.py+++ b/c/family_registry.py@@ -1,6 +1,7 @@#!/usr/bin/env python3"""Authoritative model-family registry for Colibri's Python control plane."""+import osfrom dataclasses import dataclassimport jsonimport math@@ -173,15 +174,41 @@ def _glm_geometry(config, context, _model_dir):return PlannerGeometry(state, 0, workspace, experts)+def _qwen36_layer_types(config, layers, model_dir):+ """The per-layer kinds, from wherever this container wrote them. The HF+ config carries `layer_types`; older converted containers carry them only in+ qwen36_meta.json (the engine reads that file, which is why chat worked+ while doctor and plan refused, #1532); and the upstream class derives them+ from `full_attention_interval` when neither list is present."""+ kinds = config.get("layer_types")+ if isinstance(kinds, list) and len(kinds) == layers:+ return kinds+ if model_dir:+ try:+ with open(os.path.join(model_dir, "qwen36_meta.json"), encoding="utf-8") as handle:+ meta = json.load(handle)+ except (OSError, ValueError):+ meta = None+ if isinstance(meta, dict):+ kinds = meta.get("layer_types")+ if isinstance(kinds, list) and len(kinds) == layers:+ return kinds+ interval = config.get("full_attention_interval")+ if isinstance(interval, int) and not isinstance(interval, bool) and interval >= 1:+ return ["full_attention" if (i + 1) % interval == 0 else "linear_attention"+ for i in range(layers)]+ raise ValueError("qwen36: missing or invalid planning key 'layer_types' "+ "(not in config.json, no qwen36_meta.json with it, and no "+ "full_attention_interval to derive it from)")++def _qwen36_geometry(config, context, _model_dir):"""Hybrid: only the full_attention layers hold a KV cache; the linear(DeltaNet) layers carry a recurrent state whose size does not depend on thecontext at all. One scaled context term would over-promise on a model where30 of 40 layers never grow."""layers = _required_int(config, "num_hidden_layers", "qwen36")- kinds = config.get("layer_types")- if not isinstance(kinds, list) or len(kinds) != layers:- raise ValueError("qwen36: missing or invalid planning key 'layer_types'")+ kinds = _qwen36_layer_types(config, layers, _model_dir)full = sum(kind == "full_attention" for kind in kinds)kv = (full * context * _required_int(config, "num_key_value_heads", "qwen36") *_required_int(config, "head_dim", "qwen36") * 2 * 4)diff --git a/c/tests/test_qwen36_layer_types.py b/c/tests/test_qwen36_layer_types.pynew file mode 100644index 00000000..0f3c6d7a--- /dev/null+++ b/c/tests/test_qwen36_layer_types.py@@ -0,0 +1,46 @@+"""#1532: the qwen36 planner geometry needs the per-layer kinds. The HF config+carries `layer_types`, but a converted container may carry them only in+qwen36_meta.json (the engine reads that, so chat worked while doctor and plan+refused), and the upstream class derives them from `full_attention_interval`.+All three sources must satisfy the planner; none of them, a clear error."""+import json+import os+import tempfile+import unittest++from family_registry import _qwen36_geometry, _qwen36_layer_types++BASE = {"num_hidden_layers": 8, "num_key_value_heads": 2, "head_dim": 256,+ "linear_num_key_heads": 16, "linear_key_head_dim": 128,+ "linear_num_value_heads": 32, "linear_value_head_dim": 128,+ "linear_conv_kernel_dim": 4, "num_experts": 256}+KINDS = ["linear_attention"] * 3 + ["full_attention"] + ["linear_attention"] * 3 + ["full_attention"]+++class Qwen36LayerTypesTest(unittest.TestCase):+ def test_config_list_wins(self):+ self.assertEqual(_qwen36_layer_types(dict(BASE, layer_types=KINDS), 8, None), KINDS)++ def test_meta_file_fills_the_gap(self):+ with tempfile.TemporaryDirectory() as d:+ with open(os.path.join(d, "qwen36_meta.json"), "w") as f:+ json.dump({"layer_types": KINDS, "n_layers": 8}, f)+ self.assertEqual(_qwen36_layer_types(dict(BASE), 8, d), KINDS)+ geometry = _qwen36_geometry(dict(BASE), 4096, d)+ self.assertGreater(geometry.context_state_bytes, 0)++ def test_interval_derives_the_kinds(self):+ self.assertEqual(_qwen36_layer_types(dict(BASE, full_attention_interval=4), 8, None), KINDS)++ def test_a_wrong_length_list_falls_through(self):+ self.assertEqual(_qwen36_layer_types(dict(BASE, layer_types=KINDS[:5], full_attention_interval=4), 8, None), KINDS)++ def test_nothing_known_is_a_clear_error(self):+ with tempfile.TemporaryDirectory() as d:+ with self.assertRaises(ValueError) as caught:+ _qwen36_layer_types(dict(BASE), 8, d)+ self.assertIn("full_attention_interval", str(caught.exception))+++if __name__ == "__main__":+ unittest.main()