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

qwen36: the remaining cheap items from the review's C list

kreuzzelge755280fa6a7
diff --git a/c/Makefile b/c/Makefile
index 21f9e8e7..80189b34 100644
--- a/c/Makefile
+++ b/c/Makefile
@@ -879,8 +879,12 @@ olmoe$(EXE): olmoe.c st.h json.h compat.h sample.h tok.h tok_unicode.h tok_unico
# Qwen3.6-35B-A3B engine (hybrid Gated Attention + Gated DeltaNet + streaming
# MoE). CPU-only in this target; the optional CUDA expert tier is a separate
# follow-up (see docs/qwen36-phase01.md).
+# NOCUDA_*: this file contains no CUDA, so building it with -DCOLI_CUDA and
+# linking -lcudart only made `make qwen36 CUDA=1` depend on a toolkit it
+# never calls. Same shape as olmoe. (The CUDA expert tier is #713, which
+# adds its own sources and takes the CUDA flags back.)
qwen36$(EXE): qwen36.c st.h json.h compat.h
- $(CC) $(CFLAGS) qwen36.c -o qwen36$(EXE) $(LDFLAGS)
+ $(CC) $(NOCUDA_CFLAGS) qwen36.c -o qwen36$(EXE) $(NOCUDA_LDFLAGS)
# Context-size gates: KV layout, growth across requests, and the attention
# capacity. Includes qwen36.c directly, so no model file is needed.
diff --git a/c/qwen36.c b/c/qwen36.c
index de907c88..a557b1fd 100644
--- a/c/qwen36.c
+++ b/c/qwen36.c
@@ -2171,6 +2171,15 @@ static void serve_one(Model *m, ServeReq *q){
printf("ACCEPT %s %d\n",q->id,np); fflush(stdout);
m->max_t = np + q->max_tok;
reset_recurrent(m); ensure_kv(m); m->kv_len = 0;
+ /* Per-REQUEST state, not per-process: without this the server keeps the
+ * first request's prefill flag and expert-collection set forever, so
+ * COLIBRI_RESIDENT=1 collects on request #1 and never again, and the
+ * router EMA carries one conversation's history into the next. */
+ m->first_step = 1;
+ if (m->seen) memset(m->seen, 0, (size_t)m->c.n_layers * m->c.n_experts);
+ if (m->momentum_logits)
+ memset(m->momentum_logits, 0,
+ (size_t)m->c.n_layers * m->c.n_experts * sizeof(float));
float *lo = step(m, ids, np, 0);
int gen=0, limited=1;
int eos_ids[4]; int n_eos=serve_eos_ids(eos_ids,4);
diff --git a/docs/qwen36.md b/docs/qwen36.md
index 134f59d2..2148f7d4 100644
--- a/docs/qwen36.md
+++ b/docs/qwen36.md
@@ -60,3 +60,12 @@ controlled A/Bs — with `moe_intermediate_size=512`, Qwen's rows are short, so
per-row quantization error concentrates the same way. The gs64 container costs
~1.7 GB more on disk and a few percent on cold-start; warm decode speed is the
same or slightly better.
+
+## `--ram` is not honoured by this engine
+
+`coli --ram` sizes the RAM budget for engines that stream experts from disk on
+demand. qwen36 does not: the CUDA expert tier it is built for (#713) requires
+full RAM residency of the expert set, so the budget is decided by the container,
+not by a flag. The engine reads no `RAM_GB`, and passing `--ram` changes
+nothing. Said here rather than silently ignored, because a flag that appears to
+work and does not is worse than one that is documented as unsupported.