Experiments, optimizations, and honest findings built on top of the excellent JustVugg/colibri engine β which streams a 744B-parameter GLM-5.2 Mixture-of-Experts model from NVMe, one expert at a time, so it runs on machines with far less RAM than the model's size.
This repo is the pipeline + research half of the project. The matching engine
changes live on a fork branch:
π andy12b/colibri @ branch entmtp-speq
Status: paused / archived. The author has stepped back to let the underlying tech mature. Everything here is public so it can help someone else and so it can be re-created later. Contributions and questions welcome.
The bottleneck for a disk-streamed MoE is not drafting speculative tokens β it is verification: every token the model rejects still costs a full 744B forward pass (hundreds of random expert reads from SSD). So the winning moves reduce wasted verification, not raw draft speed.
| Technique | What it does | Result |
|---|---|---|
| EntMTP β entropy-gated speculation depth | Picks how many draft tokens to verify per round from the MTP head's confidence (top-1 prob). Low confidence β speculate less; high β deeper. Lossless by construction (you choose how much to speculate, not what to accept). | +15β19% throughput vs static depth, quality gate identical |
| MoE-SpeQ β expert prefetch from drafts | Maps each speculative MTP draft token β its likely experts (via a tokenβexperts table built from instrumentation) and prefetches them before verification. |
62.7% miss-coverage (top-8 table); combined engine = 0.151 tok/s, +19% |
Quality was gated on every change with a 20-prompt eval (quality_eval.py) β the
promoted engine passed 19/20 (the one "fail" is an accepted docstring-format
artifact, not a correctness regression).
| Idea | Why it seemed good | What the measurement showed |
|---|---|---|
| GPU draft model over IPC shared memory | A small GLM-family draft model on the RTX 5060, feeding proposals into the engine via Local\ColibriDraftShm (zero HTTP). |
Loses to the engine's native MTP head. First-draft acceptance 45.5% (GPU draft) vs 60% (MTP conditioned on the full 744B hidden state). Every rejected GPU draft is pure verification tax. |
| Chinese-compression pipeline | GLM "reasons" densely in Chinese, a GPU model expands to English β fewer tokens. | On the int4 colibri conversion, the same content cost more tokens in Chinese (~1.5 chars/token vs ~6.3 for English). Net loss. |
EXPERT_BUDGET, naΓ―ve int2, mmap on Windows |
Various "free speedups" from old docs. | All quarantined upstream / measured worse β they wreck quality or RSS. |
β οΈ If you find this repo: the earlier version of this README advertised "~6 tok/s, 60β120Γ speedup" from the GPU-draft/IPC path. That was a hypothesis, not a measured result β and it turned out to be false. The honest number on this hardware is ~0.15 tok/s for the 744B model, with EntMTP+SpeQ giving a +19% lossless improvement over the engine's own strong MTP baseline. Kept here so nobody repeats the dead ends.
A single consumer gaming laptop β the whole point is that 744B runs at all:
- GPU: NVIDIA RTX 5060 Laptop, 8 GB VRAM
- RAM: 32 GB DDR5 (engine auto-sizes to ~12.6 GB working set)
- Storage: NVMe Gen4 SSD β the model lives here (~364 GB, GLM-5.2 int4) and is streamed expert-by-expert during inference
- OS: Windows 11
I/O is everything: the engine does hundreds of random 4β64 KB reads per token. Faster random-read NVMe β faster inference.
βββββββββββββββββββββββββββββββββββββββββββ
Web UI ββββββββΊ β middleware.py (FastAPI, port 8000) β
(React/Vite) β β’ SSE per-token streaming relay β
β β’ temp-0 default, /ipc-stats telemetry β
βββββββββββββββββββββ¬βββββββββββββββββββββββ
β OpenAI-compatible HTTP
βββββββββββββββββββββΌβββββββββββββββββββββββ
β colibri engine (glm.exe, port 8080) β
β β’ GLM-5.2 744B MoE, experts streamed β
β from NVMe β
β β’ MTP head speculative decoding β
β β’ EntMTP (dynamic depth) [ENT_MTP=1] β
β β’ MoE-SpeQ (expert prefetch) [MOE_SPEQ=1] β
ββββββββββββββββββββββββββββββββββββββββββββββ
- Engine (the
glm.cchanges) β fork branchentmtp-speq - Pipeline (this repo) β middleware, web UI wiring, orchestration, benchmarks, research
For future-me or anyone reproducing it. Order matters.
The engine needs a GLM-5.2 int4 snapshot (here it lived at D:\glm52_i4). This is
produced from the original GLM-5.2 weights using colibri's conversion tooling β see the
upstream colibri README for the current, canonical
download + conversion steps. It is not stored in git (way over GitHub's limits).
git clone https://github.com/andy12b/colibri.git cd colibri git checkout entmtp-speq # Build the C engine (Windows: MinGW GCC / WinLibs; see c/Makefile). # Put temp dirs on a drive with space; produces c/glm.exe make -C c
MoE-SpeQ also needs the tokenβexperts table (moe_top8_table.bin, ~195 MB) β it is
regenerated by the instrumentation scripts in this repo (aggregate_moe*.py), not
committed.
git clone https://github.com/andy12b/colibri-hybrid.git cd colibri-hybrid python -m venv .venv && .venv\Scripts\activate pip install fastapi uvicorn httpx llama-cpp-python # see imports in middleware.py
start_engine_eco.cmd # engine on :8080 (ENT_MTP=1 MOE_SPEQ=1, --ram 10) start_middleware.cmd # middleware on :8000 # web UI: cd web && npm install && npm run dev (in the engine repo)
Note:
run.batin this repo is outdated (it wires the rejected GPU-draft path). Use thestart_engine_*.cmd/start_middleware.cmdstarters.
- Temperature 0 is mandatory β any temp > 0 tanks measured acceptance via rejection sampling.
- Metric:
tok/s = completion_tokens / wall_seconds, median of 3 runs + 1 discarded warmup. - A/B comparisons must be interleaved in one engine session (Windows throttles background processes β separate runs measure the throttle, not the algorithm).
middleware.pyβ FastAPI relay (SSE streaming, telemetry, CJK-gated translation fallback)quality_eval.py/quality_eval.jsonlβ the automated quality gate (run on every change)aggregate_moe*.pyβ build the MoE-SpeQtokenβexpertstable from engine instrumentationstart_engine_*.cmd,start_middleware.cmdβ validated launchersAI_HANDOFF.md,TASKS_FOR_GEMINI.md,GEMINI_REPORT.mdβ the running log of a two-AI orchestration (Claude planned/verified, Gemini executed) that produced most of the round-2/round-3 workupgrade_ladder_results.md,research_*.json*β benchmark ladders and research notes
- Engine & the hard part: JustVugg/colibri (Apache 2.0) β running 744B from SSD is their achievement.
- EntMTP / MoE-SpeQ / pipeline / measurements: this project. See discussion #207 upstream for the datapoint report.
License: code here follows upstream (Apache 2.0) where derived; research notes are shared freely.