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

docs(experiments): fold the retractions in, add the controlled measurements

Nicolas0436bd25b9e1
diff --git a/docs/experiments/glm52-4xa6000-2026-08-02.md b/docs/experiments/glm52-4xa6000-2026-08-02.md
index 1d9b7a15..a6c84a4b 100644
--- a/docs/experiments/glm52-4xa6000-2026-08-02.md
+++ b/docs/experiments/glm52-4xa6000-2026-08-02.md
@@ -10,6 +10,13 @@ experiment set does not cover (6Γ—5090 Blackwell, Metal M5 Max, Strix Halo, 9950
Its main contribution is not a throughput number, however: it is a **methodological finding
that invalidates naive A/B benchmarking on this engine** (Β§6).
+> **Version and revision notice.** The Β§4 configuration matrix was measured on
+> `ecade075` (2026-07-30); `dev` was already 185 commits ahead. Two of its conclusions have
+> since been **retracted and replaced with controlled measurements** β€” the prefill I/O claim
+> in Β§5 and the CPU-fallback claim of issue #776. Both retractions are stated inline where
+> the original claim stood, rather than removed, because the way each was reached is the
+> useful part. Β§5–§8 were re-measured under the snapshot/restore protocol of Β§3.
+
---
## 1. Hardware
@@ -48,6 +55,26 @@ Median reported. RSS and VRAM sampled after load.
> engine produce erratic results (0.43–1.04 tok/s) because the engine serialises requests.
> Any concurrent measurement must be discarded.
+**Amended protocol, used for Β§5–§8.** The above is not sufficient on this engine, because
+`.coli_usage` carries state across restarts (Β§6). Every measurement from Β§5 onward adds:
+
+```sh
+cp -f "$MODEL/.coli_usage" snapshot # once, before the campaign
+# ... then, before every single configuration:
+systemctl stop colibri && sleep 35 # VRAM is not released immediately
+cp -f snapshot "$MODEL/.coli_usage" # restore the profile byte-for-byte
+systemctl start colibri
+```
+
+Two further rules learned the hard way, both of which produced a wrong published claim:
+
+1. **Never read cumulative log counters as current state.** Count matching lines *before* and
+ *after* the window under test and report the difference β€” a long-lived log file will
+ otherwise attribute months of history to the current configuration.
+2. **Never sample during a cold start.** Loading 429 GB takes minutes, during which GPU
+ utilisation is legitimately 0 % and one layer may take 45 s. A sample taken there
+ describes the loader, not the engine.
+
## 4. Configuration matrix (9 configs, same session, ~1 h)
| | Configuration | tok/s | RSS | VRAM |
@@ -100,9 +127,9 @@ Sampled during decode, after tuning:
CPU↔GPU round trips, tiny matmuls at S=1 β€” not any single bandwidth. This explains both the
failure of batching and the uselessness of maximising memory.
-### Prefill is a different regime entirely
+### Prefill is a different regime β€” but not for the reason stated in the first draft
-Decode activates 8 of 256 experts per layer; consecutive tokens reuse them, so the learned
+Decode activates 8 of 256 experts per layer and consecutive tokens reuse them, so the learned
pinned set covers them. Prefill does not:
```
@@ -110,19 +137,42 @@ P(an expert is missed by N tokens) = (1 βˆ’ 8/256)^N
P(512) β‰ˆ 1e-7 P(8595) β‰ˆ e^-273
```
-**A 512-token slice already touches every expert of every layer.** Prefill therefore gets no
-benefit from caching: it pays the non-resident fraction of the *entire model*, once per slice.
+A 512-token slice does touch every expert of every layer. **The first version of this report
+then drew a conclusion that the arithmetic does not support** β€” that prefill therefore
+*re-reads* the non-resident model once per slice. It does not: the cache retains what a slice
+loaded, so the sweep is paid **once**, not once per slice. Issue #153 measures this directly
+on a Zen 5 + 5090 host β€” when the prompt doubles, disk time stays **flat** (19.4 s β†’ 21.2 s)
+while attention doubles (49.2 s β†’ 118.0 s). Prefill is attention-bound, not I/O-bound.
+
+`COLI_PREFILL_CHUNK` still matters, but for the other reason: at chunk 512 the per-slice fixed
+costs and the `kvb_all` reconstruction dominate. Raising it to 2048 is worth taking.
-Measured: **2.6–4.3 tok/s prefill** at `--ctx 262144` with `COLI_PREFILL_CHUNK=512` β€” i.e.
-35–55 minutes before first token on an 8,595-token prompt. Raising the chunk to 2048 reduces
-the number of full-model sweeps from 17 to 5.
+Controlled prefill measurements on this host, `.coli_usage` snapshotted and restored before
+each level, ~1,190-token prompt:
-During prefill **only one GPU is active** (100 % / 200 W) while the other three sit at
-0 % / ~80 W: aggregate PCIe and compute budget is unused while the engine waits on expert
-loads.
+| `CTX` | prefill | decode | VRAM OOM messages |
+|---|---|---|---|
+| 32,768 | 198 tok/s | 1.56 tok/s | 0 |
+| 65,536 | 170 | 1.42 (βˆ’9 %) | 0 |
+| 98,304 | 198 | 1.33 (βˆ’15 %) | 0 |
+| 131,072 | 170 | **1.20** (βˆ’23 %) | 0 |
+| 196,608 | 148 | 1.03 (βˆ’34 %) | 0 |
-Prefix caching itself works correctly in steady state (`prefix 8556/8562 token, prefill 6`):
-the prefill cost is paid once per conversation, not per turn.
+**No cliff up to 196,608**, and prefill never leaves the 148–198 tok/s band. The earlier
+figure of 2.6–4.3 tok/s prefill belongs to `--ctx 262144` *with `RAM_GB=215`* β€” a level at
+which the engine collapses the expert cache to `cap=1` (see Β§7). It is a property of that
+one over-committed configuration, not of long context in general.
+
+**Recommended: `CTX=131072`** β€” four times the context for βˆ’23 % decode, prefill unchanged.
+
+> An earlier revision of this report, and issue #776, claimed prefill attention silently falls
+> back to CPU when VRAM is full of experts. **That was wrong and has been retracted.** The
+> evidence was `out of memory` counts read cumulatively from the top of a long log file and a
+> GPU sample taken *during a cold start*. The controlled sweep above shows zero new OOM
+> messages at every level.
+
+Prefix caching works correctly in steady state (`prefix 8556/8562 token, prefill 6`): the
+prefill cost is paid once per conversation, not per turn.
## 6. **The finding that invalidates naive A/B benchmarking**
@@ -162,6 +212,32 @@ bandwidth differential accounts for ~1.3 ms of the 77 ms per-token gap β€” under
let contributors report the metric that actually decides placement trade-offs instead of
reporting occupied gigabytes.
+### The protocol that was missing, and what it shows
+
+Snapshot `.coli_usage`, restore it byte-for-byte before every configuration, warm up on a
+fixed corpus, then measure. Three placements under that protocol:
+
+| | placement | VRAM / RAM (GB) | tok/s |
+|---|---|---|---|
+| A | VRAM-heavy | 188 / 200 | 2.81 |
+| B | balanced (= the config that once measured 5.46) | 176 / 205 | 2.78 |
+| C | RAM-heavy | 176 / **235** | **3.51** |
+
+**A and B are indistinguishable** (2.81 vs 2.78): moving 12 GB between the tiers changes
+nothing. **C wins by 25 %** β€” it is the *RAM budget* that matters, not the split.
+
+**The 5.46 tok/s figure is not reproducible, and now we know why.** Configuration B is
+byte-for-byte the one that produced it. Under a controlled profile it gives 2.78. The
+difference is not the machine: it is *specialisation*. On the day of the 5.46 measurement
+`.coli_usage` held 240 k selections from one repeated prompt; it now holds 18.2 M from mixed
+real use. **A specialised profile is worth β‰ˆ Γ—2** β€” the mechanism works, then stops working
+as the history dilutes it.
+
+That is the motivation for `COLI_USAGE_DECAY` (merged in #780): a typical turn contributes
+~38 k selections against a recorded history of 18.19 M β€” **0.2 %** β€” so recent workload can
+no longer move the pinned set. An opt-in geometric decay applied at save time restores the
+profile's ability to track what the machine is actually being asked to do.
+
## 7. Context vs residency trade-off
```
@@ -170,8 +246,10 @@ required = 407 (experts) + 83 (KV @262144) + 12 (dense) + 10 (OS) = 512 GB
deficit = 69 GB
```
-At `--ctx 32768` the KV costs 11 GB and everything fits. Measured: **5.46 tok/s at 32768 vs
-0.86 tok/s at 262144**. The engine reports the collapse itself:
+At `--ctx 32768` the KV costs 11 GB and everything fits. The uncontrolled session measured
+5.46 tok/s at 32768 against 0.86 at 262144; **only the second half of that pair survives
+re-measurement** β€” see Β§5 for the controlled curve and Β§6 for why 5.46 is not reproducible.
+What is solid is the failure mode at 262144, which the engine reports itself:
```
[RAM_GB=215.0] WARNING: cap=1 is the floor, projected peak 216.7 GB is 1.7 GB OVER
@@ -179,6 +257,13 @@ the budget (resident 132.2 GB + reserve 82.8 GB).
PIN_GB is inflating the resident set: lower it or drop it.
```
+`cap=1` means one cached expert slot per layer: every one of the 8 experts a token needs is a
+disk read. That is the collapse β€” and it is a **budget** failure, not a context failure. It
+was measured at `RAM_GB=215`; the controlled sweep at `RAM_GB=235` reaches 196,608 with no
+collapse at all. The honest statement is therefore: *long context costs decode throughput
+smoothly (βˆ’34 % at 6Γ— the context) until the expert cache is squeezed to its floor, at which
+point it falls off a cliff.*
+
### KV cache size
MLA stores `kv_lora_rank 512 + rope 64 = 576` values per token per layer, Γ—78 layers =
@@ -202,7 +287,49 @@ Comparison on the same model and same latent attention: llama.cpp with `-ctk f16
262,144. That is 83 % of the 69 GB deficit above: with an fp16 KV and no `kvb_all`, long
context and full expert residency would be simultaneously reachable on this host.
-## 8. Build notes (Linux, CUDA)
+## 8. What the learned routing profile actually looks like
+
+`.coli_usage` after real use: **19,324 experts across 76 layers, 18,189,640 recorded
+selections**. The placement heuristics assume a hot minority; the measured distribution
+does not have one.
+
+| top % of experts | count | share of selections |
+|---|---|---|
+| 1 % | 194 | 6.8 % |
+| 5 % | 967 | 19.6 % |
+| 10 % | 1,933 | 30.6 % |
+| 25 % | 4,831 | 53.4 % |
+| 50 % | 9,662 | 78.0 % |
+
+**This is not a power law.** Under one, the top 1 % would carry 30–50 % of traffic; it carries
+6.8 %. The max/median ratio is only 18.7, and **no expert is ever unused** β€” the router's
+`noaux_tc` load-balancing bias is doing its job, which is precisely what defeats hot/cold
+tiering.
+
+Consequences for placement, same profile:
+
+| VRAM tier | % of model | accesses captured | vs random placement |
+|---|---|---|---|
+| 8,288 experts | 42.9 % | 72.1 % | Γ—1.68 |
+| 6,000 | 31.0 % | 60.5 % | Γ—1.95 |
+| 4,000 | 20.7 % | 47.8 % | Γ—2.31 |
+
+Heat-based pinning works, but with **sharply diminishing returns**: each additional gigabyte
+captures less than the one before. This is the direct explanation for Β§6 β€” fine-tuning the
+VRAM/RAM split produces noise because the underlying distribution is nearly flat.
+
+And the uniform per-layer cap the engine already applies is close to optimal:
+
+| strategy, equal budget of 8,288 experts | accesses captured |
+|---|---|
+| uniform cap (109/layer β€” what the engine does) | 71.5 % |
+| global top-k across all layers | 72.1 % |
+
+**0.6 points.** A global ranking is not worth its complexity here. The lever that pays is not
+*which* experts are pinned β€” it is how many fit, and how well the profile matches the current
+workload (Β§6).
+
+## 9. Build notes (Linux, CUDA)
`nvcc` 12.6 + gcc 13 fails with `identifier "_Float32" is undefined`;
`-allow-unsupported-compiler` produces 100 errors. The `BUILD-cuda-glibc241.md` recipe works
@@ -217,25 +344,29 @@ make glm CUDA=1 CUDA_ARCH=sm_86 CUDA_HOME=~/cuda13
The web dashboard needs Node β‰₯ 20.12 (`styleText` from `node:util`); Ubuntu 24.04 ships
18.19, so `npm run build` fails on a stock install.
-## 9. Final configuration
+## 10. Final configuration
```sh
-CTX=32768 # 262144 measured 0.86 tok/s decode, 2.9 tok/s prefill
+CTX=32768 # 131072 also fine: βˆ’23 % decode, prefill unchanged (Β§5)
COLI_CUDA=1
COLI_GPUS=0,1,2,3
CUDA_DENSE=1 # Γ—2.8 β€” the decisive lever
COLI_CUDA_ATTN=1
COLI_CUDA_PIPE=2
COLI_CUDA_TC_W4A16=1
-CUDA_EXPERT_GB=188 # NOT "auto" β€” see issue on prefill scratch
+CUDA_EXPERT_GB=176 # NOT "auto" β€” see issue on prefill scratch
PIN=auto
PIN_GB=all
-RAM_GB=200
+RAM_GB=235 # +25 % over 205 under a controlled profile (Β§6)
DIRECT=1
PIPE=1 # no URING, no PILOT* β€” +26 % on this host
COLI_PREFILL_CHUNK=2048
```
+`MemoryMax=238G` on the systemd unit: at `RAM_GB=235` the engine's own accounting excludes
+allocations the kernel still charges to the cgroup, and the OOM killer arrives before the
+engine's internal cap does.
+
Operational notes: the engine does not release VRAM immediately on stop β€” restarting within
~30 s fails with `Failed with result 'exit-code'` (`Restart=on-failure` recovers). And
`coli plan` computes against *currently free* VRAM, so its output is meaningless while an