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): the tuning campaign, and why PIN_GB=all is not a safe default

Nicolas9402d8b538a2
diff --git a/docs/experiments/glm52-4xa6000-2026-08-02.md b/docs/experiments/glm52-4xa6000-2026-08-02.md
index 35d00803..2e1d4349 100644
--- a/docs/experiments/glm52-4xa6000-2026-08-02.md
+++ b/docs/experiments/glm52-4xa6000-2026-08-02.md
@@ -504,7 +504,72 @@ llama.cpp splits by *layer count*, not by bytes, and MoE layers weigh ~4.6 GB ag
hundred MB for dense ones, so an even layer split is a wildly uneven byte split. Re-running
with the cursor pulled back.
-## 13. Build notes (Linux, CUDA)
+## 13. Tuning campaign: 2.35 -> 3.64 tok/s
+
+Everything above measures the engine as configured. This section is what changed the
+number. Same protocol throughout: `.coli_usage` restored byte-for-byte before every
+condition, `CTX=32768`, 64 tokens greedy, `PROF=1`.
+
+| | tok/s | CPU expert read | `route_agree` | `swap` |
+|---|---|---|---|---|
+| baseline (48 threads, no CACHE_ROUTE) | 2.35 | 22.66 GB/s | β€” | β€” |
+| `OMP_NUM_THREADS=24` | 2.70 | 23.49 | β€” | β€” |
+| `+ CACHE_ROUTE=1 ROUTE_M=16 ROUTE_J=1` | 3.59 | 32.98 | 99.1 % | 0.9 % |
+| `+ CUDA_EXPERT_GB=188` | **3.64** | 32.98 | 99.1 % | 0.9 % |
+
+**+55 %, from three settings.** Two of them are documented nowhere a user would look.
+
+### `OMP_NUM_THREADS` (see #805)
+
+Never set on Linux. The C-side OMP block sets `OMP_WAIT_POLICY` and `GOMP_SPINCOUNT`
+but not the thread count, and skips itself entirely under CUDA β€” so libgomp falls back
+to `nproc`, the **logical** count. On this 24c/48t host that is a 2x over-subscription:
+
+| threads | CPU expert read | decode | per thread |
+|---|---|---|---|
+| 4 | 6.48 GB/s | 1.28 tok/s | 1.62 GB/s |
+| 16 | 23.97 | 2.63 | 1.49 |
+| **24 (physical)** | **30.10** | **2.90** | 1.25 |
+| 48 (logical) | 17.35 | 2.06 | **0.36** |
+
+Near-linear to the physical core count, then collapse. **~1.4 GB/s per Zen 2 core is the
+ceiling of this kernel**, and 24 cores x 1.4 = 34 GB/s is where the host sits β€” so the
+8-channel DDR4-2400's ~85 GB/s is unreachable here. The CPU expert path is compute-bound
+per core, not memory-bound. That single fact sets the machine's ceiling (below).
+
+### `CACHE_ROUTE` (see #811)
+
+The largest lever, and off by default. Parameters barely matter β€” `M` 12/16/24 all land
+within 1 %, because at 45.6 % residency the resident experts that outrank the true top-8
+are already inside rank 12. `J=0` and `ROUTE_ALPHA` likewise. **The defaults are right;
+the only real decision is on/off.**
+
+### `CUDA_EXPERT_GB`
+
+| requested | tok/s | VRAM actually used | VRAM OOM |
+|---|---|---|---|
+| 176 | 3.55 | 175.98 GB | 0 |
+| 182 | 3.63 | 181.99 | 0 |
+| **188** | **3.64** | **182.99** | 0 |
+| 190 | 3.62 | 182.99 | 0 |
+
+The tier saturates at ~183 GB regardless of what is asked. Worth +2.6 % over 176, with
+no errors at any level.
+
+### Where the ceiling is
+
+At 3.64 tok/s a token takes 275 ms, of which the CPU-side expert read is ~200 ms:
+
+```
+6.6 GB non-resident per token / 32.98 GB/s = 200 ms (73 % of the token)
+```
+
+Since ~1.4 GB/s per core is a per-core compute limit and all 24 are in use, that term
+cannot be reduced by tuning. **The realistic ceiling for this host is ~4.5 tok/s.** Going
+beyond it requires changing the arithmetic, not the configuration: more VRAM (386 GB of
+experts against 192 GB installed), or a narrower quantization.
+
+## 14. 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
@@ -519,25 +584,58 @@ 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.
-## 14. Final configuration
+## 15. Final configuration
```sh
-CTX=32768 # 131072 also fine: βˆ’23 % decode, prefill unchanged (Β§5)
+CTX=32768
COLI_CUDA=1
COLI_GPUS=0,1,2,3
-CUDA_DENSE=1 # Γ—2.8 β€” the decisive lever
+CUDA_DENSE=1 # x2.8 -- the decisive lever before the campaign below
COLI_CUDA_ATTN=1
COLI_CUDA_PIPE=2
COLI_CUDA_TC_W4A16=1
-CUDA_EXPERT_GB=176 # NOT "auto" β€” see issue on prefill scratch
+COLI_CUDA_ATTN_SHARD=1 # +9 % with PIPE_SHARD; measured separately in Β§10
+COLI_CUDA_PIPE_SHARD=1
+CUDA_EXPERT_GB=188 # NOT "auto"; tier saturates at ~183 GB anyway (Β§13)
+OMP_NUM_THREADS=24 # PHYSICAL cores. +15 %; never set on Linux (#805)
+CACHE_ROUTE=1 # +33 % at 99.1 % routing agreement (#811)
+ROUTE_M=16
+ROUTE_J=1
PIN=auto
-PIN_GB=all
-RAM_GB=235 # +25 % over 205 under a controlled profile (Β§6)
+PIN_GB=150 # NOT "all" -- see below
+RAM_GB=235
+COLI_USAGE_DECAY=0.9 # bounds the learned history (#780) -- see below
DIRECT=1
-PIPE=1 # no URING, no PILOT* β€” +26 % on this host
+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.
+
+### `PIN_GB=all` is not a safe steady state
+
+The report originally recommended it. After two days of ordinary use the engine **refused
+to start**:
+
+```
+[USAGE] expert history: 26,437,320 selections
+[PIN] placement: 4661 VRAM + 5497 RAM expert (207.7 GB warm)
+[RAM] refusing to start: projected peak 315.0 GB exceeds the 258.2 GB available
+```
+
+Nothing was reconfigured. `PIN=auto` seeds from `.coli_usage`, which grows monotonically β€”
+here 18.2 M -> 26.4 M selections β€” so with `PIN_GB=all` the pinned set grows with it:
+184.8 GB, then 207.7 GB. A working configuration stops working by itself.
+
+Two things fix it, and both belong in a recommended config: **bound `PIN_GB`**, and set
+**`COLI_USAGE_DECAY`**, which exists for exactly this and which nothing points a user
+toward when they hit the wall.
+
+Worth noting that the refusal itself is the correct behaviour and is new: before #793 the
+projection under-counted the slot width, so the same configuration would have started and
+been OOM-killed mid-generation (#305, #766).
+
`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.