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(plan): count dense weights as they will sit in RAM, not as they sit on disk

JustVugg49282fd46040
diff --git a/README.md b/README.md
index 7a235192..78885504 100644
--- a/README.md
+++ b/README.md
@@ -419,6 +419,7 @@ the model's `config.json`):
|---|---|---|---|---|
| **GLM-5.2** | 744B / 40B | [`mastouri/…-int4-g64-with-int8-mtp`](https://huggingface.co/mastouri/GLM-5.2-colibri-int4-g64-with-int8-mtp) (372 GB) | `make -C c glm` | this page |
| **Inkling** (Thinking Machines) | 975B / 41B | [`nbeerbower/Inkling-colibri-int4`](https://huggingface.co/nbeerbower/Inkling-colibri-int4) (469 GB) | `make -C c inkling` | [inkling.md](docs/inkling.md) |
+| **GLM-5.3-Flash** (Z.ai) | 321B / 40B | [`zai-org/GLM-5.3-Flash`](https://huggingface.co/zai-org/GLM-5.3-Flash) β€” converted to **int4-gs64** routed experts, dense stays BF16 and the precision is a load-time choice; vision included | `make -C c glm53` | [glm53-flash.md](docs/glm53-flash.md) |
| **Kimi K3** (Moonshot) | 2.8T / 104B | [`moonshotai/Kimi-K3`](https://huggingface.co/moonshotai/Kimi-K3) β€” original checkpoint, routed experts stay **native MXFP4** | `make -C c kimi_k3` | [kimi_k3.md](docs/kimi_k3.md) |
| **DeepSeek V4 Flash** | 284B / 13B | official sharded checkpoint β€” routed experts stay **native fp4**, dense stays fp8-e4m3 | `make -C c deepseek-v4` | [deepseek-v4.md](docs/deepseek-v4.md) |
| **Qwen3.6** (Alibaba) | 35B / 3B | [`Kreuzzelg/qwen36-35b-a3b-colibri-i4-gs64`](https://huggingface.co/Kreuzzelg/qwen36-35b-a3b-colibri-i4-gs64) (~20 GB, **recommended**) β€” hybrid Gated Attention + Gated DeltaNet | `make -C c qwen36` (`CUDA=1` for the VRAM expert tier) | [qwen36.md](docs/qwen36.md) |
diff --git a/c/family_registry.py b/c/family_registry.py
index efa4242d..d1000a67 100644
--- a/c/family_registry.py
+++ b/c/family_registry.py
@@ -72,6 +72,11 @@ class FamilyDescriptor:
config_section: str
limits: FamilyLimits
capabilities: FamilyCapabilities
+ # Quanto pesano in RAM i pesi densi rispetto a come stanno su disco.
+ # Vale 1.0 per chi li carica cosi' come sono; un motore che li riquantizza
+ # a load time pesa meno, e senza questo il pianificatore direbbe che il
+ # modello non ci sta quando invece ci sta.
+ dense_load_ratio: object = None # callable(bytes_su_disco) -> bytes in RAM
has_gateway_adapter: bool = False
has_cli_adapter: bool = False
tune_prompt_template: str = "{prompt}"
@@ -232,6 +237,23 @@ def _kimi_geometry(config, context, _model_dir):
_GLM53_PREFILL_CHUNK = 128
+def _glm53_dense_in_ram(on_disk_bytes):
+ """I densi di GLM-5.3 non restano come sul disco.
+
+ Il checkpoint li porta in BF16 e il motore li quantizza al caricamento
+ secondo GLM53_BITS (default 4), che e' int4 con una scala ogni 64 colonne:
+ 0,5625 byte per parametro contro i 2 del file. Contarli come stanno su
+ disco fa dire al pianificatore che manca RAM per un solo esperto per layer,
+ quando ce ne stanno diciassette."""
+ import os
+ try:
+ bits = int(os.environ.get("GLM53_BITS", "4"))
+ except ValueError:
+ bits = 4
+ per_parameter = {4: 0.5625, 8: 1.0, 32: 4.0}.get(bits, 0.5625)
+ return int(on_disk_bytes * per_parameter / 2.0) # il file e' BF16
+
+
def _glm53_geometry(config, context, _model_dir):
"""GLM-5.3-Flash: 34 layer KDA ricorrenti piu' 11 layer MLA con DSA.
@@ -521,6 +543,7 @@ FAMILIES = (
cli_adapter="glm53",
gateway_adapter="glm53",
planner_id="glm53_hybrid",
+ dense_load_ratio=_glm53_dense_in_ram,
planner_geometry=_glm53_geometry,
planner_unsupported_reason="",
expert_inventory=_individual_expert_inventory(_GLM53_EXPERT),
diff --git a/c/resource_plan.py b/c/resource_plan.py
index fe2f8da8..f9b97e8b 100644
--- a/c/resource_plan.py
+++ b/c/resource_plan.py
@@ -26,6 +26,21 @@ _ANALYSIS_CACHE_NAME = ".coli_analysis.json"
_ANALYSIS_CACHE_VERSION = 1
+def _dense_in_ram(descriptor, on_disk_bytes):
+ """I byte che i pesi densi occuperanno, non quelli che occupano sul disco.
+
+ Coincidono per chi li carica come stanno; una famiglia che li riquantizza
+ al caricamento lo dichiara nel registro. Un errore qui non e' cosmetico:
+ e' la differenza fra dire a qualcuno che il modello ci sta e dirgli di no."""
+ ratio = getattr(descriptor, "dense_load_ratio", None)
+ if ratio is None:
+ return on_disk_bytes
+ try:
+ return max(0, int(ratio(on_disk_bytes)))
+ except Exception:
+ return on_disk_bytes
+
+
def _analysis_signature(shards, config_path):
parts = [f"v{_ANALYSIS_CACHE_VERSION}"]
st = config_path.stat()
@@ -150,7 +165,11 @@ def analyze_model(model):
"path": str(model),
"shards": len(shards),
"model_bytes": model_bytes,
- "dense_bytes": dense_bytes,
+ # Come pesano DAVVERO in RAM: un motore che riquantizza al caricamento
+ # ne occupa meno di quanto ne occupino sul disco, e il pianificatore
+ # serve a rispondere "ci sta?", non "quanto pesa il file".
+ "dense_bytes": _dense_in_ram(resolved.descriptor, dense_bytes),
+ "dense_disk_bytes": dense_bytes,
"expert_bytes": sum(expert_groups.values()),
"expert_count": len(expert_groups),
"expert_layers": len(per_layer),