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

inkling: read the embedding norm under the name transformers 5.18 writes

JustVuggd49304080121
diff --git a/c/inkling.c b/c/inkling.c
index c7ce91ff..146dd368 100644
--- a/c/inkling.c
+++ b/c/inkling.c
@@ -719,6 +719,17 @@ static void load_cfg(Cfg *c, const char *snap) {
}
/* ---------- weight loading ---------- */
+/* The embedding norm has two names. The converter and every container written with
+ * transformers up to 5.17 call it model.embed_norm.weight; transformers 5.18 saves
+ * the same tensor as model.embed_tokens.embed_norm.weight. Read by the old name
+ * only, a checkpoint saved by 5.18 loaded with no embedding norm at all -- no
+ * error, and every answer wrong (the tiny oracle: 1 of 36 positions). */
+static const char *embed_norm_name(shards *S) {
+ if (st_has(S, "model.embed_norm.weight")) return "model.embed_norm.weight";
+ if (st_has(S, "model.embed_tokens.embed_norm.weight")) return "model.embed_tokens.embed_norm.weight";
+ return NULL;
+}
+
static float *load_t(Model *m, const char *name) {
int64_t n = st_numel(&m->S, name);
if (n < 0) { fprintf(stderr, "missing %s\n", name); exit(1); }
@@ -952,7 +963,7 @@ static void model_init_range(Model *m, const char *snap, int cap, int bits,
#endif
if (load_boundaries) {
m->embed = load_w(m, "model.embed_tokens.weight", 0);
- m->embed_norm = st_has(&m->S,"model.embed_norm.weight") ? load_t(m,"model.embed_norm.weight") : NULL;
+ { const char *en = embed_norm_name(&m->S); m->embed_norm = en ? load_t(m, en) : NULL; }
m->final_norm = load_t(m, "model.norm.weight");
m->lm_head = load_w(m, "lm_head.weight", 1);
}
@@ -3269,8 +3280,8 @@ static int inkling_edge_engine_open(
model->has_q = model->Sq.n > 0;
}
model->embed = load_w(model, "model.embed_tokens.weight", 0);
- model->embed_norm = st_has(&model->S, "model.embed_norm.weight")
- ? load_t(model, "model.embed_norm.weight") : NULL;
+ const char *embed_norm = embed_norm_name(&model->S);
+ model->embed_norm = embed_norm ? load_t(model, embed_norm) : NULL;
model->final_norm = load_t(model, "model.norm.weight");
model->lm_head = load_w(model, "lm_head.weight", 1);
char tokenizer_path[4096];