Run frontier MoE models on hardware you already own — pure C, zero deps, experts streamed from disk. Tiny engine, immense model. 🐦
C
fix(deepseek-v41): the speculative rollback buffers were one row long
JustVugg826c6c0fb982
diff --git a/c/deepseek_v41.c b/c/deepseek_v41.cindex 50eb0d0a..660e421c 100644--- a/c/deepseek_v41.c+++ b/c/deepseek_v41.c@@ -931,7 +931,14 @@ static void model_load(Model *m, const char *snap, int ecap, int engram_cache_romemset(l->window, 0, (size_t)c->window * hd * sizeof(float));l->window_pos = xmalloc((size_t)c->window * sizeof(int), "window positions");for (int k = 0; k < c->window; k++) l->window_pos[k] = -1;- int rows = c->n_mtp > 0 ? c->spec_block + 1 : 1;+ /* Sized from spec_block, NOT from n_mtp: the released config.json+ * carries the block size and omits the stage count, so n_mtp is still+ * zero here and only becomes 3 inside spec_load, which runs after this+ * loop. Reading it here allocated one row and the first speculative+ * step then wrote six into it -- a heap overflow that the tiny fixture+ * could not show, because the config this repository writes for it+ * does declare n_mtp_layers. The block size is what bounds a batch. */+ int rows = c->spec_block > 0 ? c->spec_block + 1 : 1;l->ring_save = xmalloc((size_t)rows * hd * sizeof(float), "displaced ring keys");l->ring_save_pos = xmalloc((size_t)rows * sizeof(int), "displaced ring positions");int ratio = c->compress_ratio[i];diff --git a/c/tools/make_dsv41_tiny.py b/c/tools/make_dsv41_tiny.pyindex a570aeb8..71bd1411 100644--- a/c/tools/make_dsv41_tiny.py+++ b/c/tools/make_dsv41_tiny.py@@ -397,8 +397,15 @@ def build(out: Path, cfg: dict, ref_path: Path | None, max_new: int, prompt_len:save_file(tensors, str(out / "model.safetensors"))- # config.json in the released shape: everything under text_config, vision absent- text = {k: v for k, v in cfg.items() if k not in ("max_seq_len",)}+ # config.json in the released shape: everything under text_config, vision+ # absent -- and n_mtp_layers absent too, because the checkpoint DeepSeek+ # publishes does not carry it. It lives only in their inference/config.json,+ # which nobody who downloads the model ever sees. A fixture whose config is+ # richer than the real one hides exactly the defects that matter: this one+ # hid a heap overflow for a day, because the engine sized its speculative+ # rollback buffers from a stage count that is zero until the checkpoint is+ # probed for it.+ text = {k: v for k, v in cfg.items() if k not in ("max_seq_len", "n_mtp_layers")}config = {"architectures": ["DeepseekV41ForCausalLM"],"model_type": "deepseek_v41",