- Python 62.2%
- Shell 25%
- PowerShell 9%
- Jinja 3.3%
- Batchfile 0.5%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| bench | ||
| docs | ||
| engine@f11c756186 | ||
| engine-notes | ||
| layer | ||
| receipts/mirai-port | ||
| suite | ||
| templates | ||
| tooling | ||
| .gitattributes | ||
| .gitignore | ||
| .gitmodules | ||
| LICENSE | ||
| README.md | ||
| RELEASE-NOTES.md | ||
| start-server.ps1 | ||
Mirai S 27B on a 12 GB card: the full 262k window, drafting at every depth, and the layer
Mirai S (Qwen3.8-27B-S, trellis codes, ~2.4 bits of
information per weight, 11.17 GB) served on an RTX 4070 12 GB with the full 262,144-token trained window at q8_0
KV cache, MTP speculative decoding from the GGUF's own draft block at every depth, harness-proofing for the apps
that send effort: "high" or tiny output caps, and an optional server-side layer (exact API cards, an API check, a
sandboxed Python tool). Same weights as published; every kernel checked greedy token-for-token against the model's
own llama.cpp fork before anything else was measured. This is a serving layer on top of alesha-pro's work, not a
replacement for it: the codec, the model and the reference fork are theirs; the cache, drafting, server flags and
measurements here are what a 12 GB card adds around them.
| RTX 4070 12 GB, served, one slot | alesha-pro's reference fork (llama.cpp-mirai-s, the starting point) |
this serve |
|---|---|---|
| context window with q8_0 KV | 64k (11.0 GB) | 262,144 (tiered: 44k positions in VRAM, the rest in pinned RAM) |
| decode, tok/s, at 0 / 16k / 60k / 120k / 180k | 40.0 / 38.1 / 33.5 (60k) / - / - | 75.8 / 71.4 / 40.3 / 16.6 / 10.3 |
| prefill, 16.8k-token prompt | ~1,000 | 1,090 (2048 micro-batch mode: 1,148) |
| speculative decoding | none | MTP draft at every depth, outputs identical to drafting off |
| HumanEval 164, greedy, tests executed in a sandbox | 158 at medium or at effort "low"; 154 thinking off | |
| long exact-work suite, 37 tasks, raw / behind the layer | 13 / 30 (on the reference fork) | 18 / 28 (12 rescues, 2 losses); coding family over two seed sets 7 / 12 of 24, at effort "low" 6 / 8 of 12 |
apps that send effort: "high" |
template error on every request | answered (normalized to medium) |
Receipts for every row are in receipts/mirai-port/ and bench/; how each number was obtained, and what did not
work, is in docs/REPORT.md and docs/PREFILL.md. Numbers are from 2026-10-05/06, GDDR6X at stock clocks, display on
the CPU's integrated GPU (see "Getting more positions into VRAM").
Quick start (Windows, NVIDIA)
-
Download
mirai-s-bundle-win-x64.zipfrom Releases and unzip into this repo (it fillsbin\), or build it (below). The binaries carry sm_89 machine code (RTX 40) and need only the NVIDIA driver. -
Put
Qwen3.8-27B-S-mirai.gguffrom alesha-pro on Hugging Face inmodels\. The MTP draft block ships inside that file; nothing is grafted. -
Optional, once:
layer\fetch_runtime.ps1downloads the sandbox runtime (CPython 3.12 on WASI, checksummed) and runs its isolation canaries. Without it the plain server starts. -
Serve:
.\start-server.ps1OpenAI-compatible API on
http://<host>:8080/v1, bearer key inartifacts\api_key.txt(created on first run). The launcher reads free VRAM, keeps a safety margin below the point where Windows demotes a background process's memory, and puts as many positions of the 262k cache in VRAM as fit (about 44k headless on this card). It prints the line it chose.
Recommended settings
- Chat, coding answers, anything behind the layer: the defaults (medium reasoning, 20k thinking budget, layer on).
- Coding agents that run their own tools (Cline, Kilo, OpenHands-style loops against
127.0.0.1:18080, or the layer with"api_cards": false): sendreasoning_effort: "low", and launch withMIRAI_EFFORT_ALLOWED=low,mediumso the server lets it through. Measured on the suite's coding family, raw: 4 -> 6 of 12 at the same seeds, the MIME task 0 -> 4 of 4, HumanEval unchanged at 158/164; the cost is longer tool loops (+31% completion tokens). - Sessions that stay under ~28k tokens and want the fastest decode:
MIRAI_SPEC_TYPE=dflashwith the Q4_0 DFlash drafter fromggml-org/Qwen3.8-27B-GGUFinmodels\. Measured (E22, three runs): 86 / 78 tok/s at 0 / 16k against 76 / 72 with the MTP block, greedy outputs identical, acceptance 70% at draft 3; drafts of 4 or more lose. It costs ~17k of the 45k positions in VRAM, which is why the default keeps the MTP block for long agent sessions. - Tool-heavy agents that want speed over depth:
chat_template_kwargs: {"enable_thinking": false}per request (HumanEval 154/164 at 0.19x the tokens).
Knobs (environment variables)
| Variable | Default | |
|---|---|---|
MIRAI_CTX |
262144 | context window |
MIRAI_CTK |
q8_0 | K/V cache type |
MIRAI_TIER |
1 | 0 = all-VRAM cache (then a 64k window) |
MIRAI_KV_VRAM_CELLS |
auto | pin the VRAM line |
MIRAI_VRAM_MARGIN |
800 headless / 1300 with the display on this card | MiB kept free below the demotion point |
MIRAI_SPEC / MIRAI_SPEC_DEEP |
2 / 2 (3 with dflash) | draft size, and past the VRAM line |
MIRAI_SPEC_TYPE / MIRAI_DRAFTER |
mtp / models\dflash-Qwen3.8-27B-Q4_0.gguf |
dflash drafts with ggml-org's DFlash drafter instead of the GGUF's MTP block: +13% decode at depth 0, +8.5% at 16k, outputs identical, ~590 MiB more VRAM (~17k fewer positions in VRAM). Download the drafter from ggml-org/Qwen3.8-27B-GGUF into models\ |
MIRAI_DRAFT_WINDOW |
16384 | rows the draft block keeps |
MIRAI_EFFORT / MIRAI_EFFORT_ALLOWED |
medium / medium | server default effort; effort words the template sees (others become medium) |
MIRAI_THINK / MIRAI_THINK_BUDGET |
1 / 20480 | thinking on; tokens before a forced close |
MIRAI_HARNESS_PROOF |
1 | 0 = pass effort words and output caps through unchanged |
MIRAI_PREFILL_PLANES |
ffn | prompt-token numerics: ffn (one int8 plane for the FFN matmuls, +18% prefill, KL 0.00028), 2 exact, 1 one plane everywhere |
MIRAI_KQ_MASK_PACKED / MIRAI_UBATCH |
1 / 1024 | 1-bit attention mask; micro-batch (2048 = +5.6% prefill for ~570 MiB of VRAM) |
MIRAI_LEVELS_MIB |
128 | level-decode chunk footprint for long prompts |
MIRAI_LAYER |
1 | 0 = no layer |
MIRAI_PORT, MIRAI_MODEL, MIRAI_LOG_FILE |
8080, auto, none |
Getting more positions into VRAM
Every GB of VRAM the desktop does not use is ~30k more q8_0 positions at full speed. Run the display from the CPU's integrated graphics and set GPU-accelerated apps to it in Windows Settings > System > Display > Graphics; the launcher's margin drops from 1300 to 800 MiB headless.
Why the VRAM line is ~44k and not more
Mirai keeps 8,220 MiB of weights resident; drafting keeps one 150 MiB snapshot of the recurrent state per unit of
rollback depth (two at the default draft 2) plus ~660 MiB for the draft context. Past the line every step reads the
host tail over PCIe; drafting there is worth 2.2x over no drafting. MIRAI_SPEC=0 moves the line to ~70k positions
at the cost of the 1.85x below it (docs/REPORT.md).
Known limits and issues
- 12 GB is the floor. 8.2 GB of weights stay resident; this model does not fit an 8 GB card, and the launcher does not try.
- Past the VRAM line decode is PCIe-bound (45k positions on a 12 GB card with the display on the iGPU; see the decode table). A 16 GB card moves the line to ~175k by the launcher's arithmetic; not measured here.
- Host RAM: the full 262k cache keeps ~7 GB of K/V in pinned system RAM; the box needs that much free.
- One slot (
-np 1), as the reference fork also requires for this model. - Windows launcher. The Linux command line above is the same recipe, untested here.
- Effort words outside the allow-list are normalized to medium by design (harness-proofing). Agents that want
"low" need
MIRAI_EFFORT_ALLOWED=low,mediumat launch; a request's effort is never silently honored or rejected, it is mapped, and the server log says so. - Prompt numerics are one-plane for the FFN matmuls by default (KL 0.00028 against exact, top-token agreement
99.2%, no suite pair moved).
MIRAI_PREFILL_PLANES=2gives the exact path at -18% prefill. - Library-heavy coding tasks remain hard for the model (the suite's MIME task passes only raw at effort "low"); the layer's API check reduces invented names, it does not remove the model's limits.
- Sampled runs are deterministic for an identical request and seed, with rare late divergence under cache
reuse (one in twelve 70k-character traces); treat small paired deltas as noise (
docs/REPORT.md, determinism probe). - Report issues with the launcher's printed configuration block and
logs\product.log.
What is here
| path | what |
|---|---|
engine/ |
submodule: professorpalmer/llama.cpp-ada-mirai. PrismML's llama.cpp fork with the serving patches (tiered KV cache, draft window and tail, reasoning flags, batch-invariant kernels, op timing) and Mirai's codec ported on top (ggml types 90-93, CPU and CUDA kernels, rotation and scale tensors, split attention gate, graph hook), plus the prefill work done here (one-plane FFN prompt numerics, packed 1-bit KQ mask, level-decode chunking). |
start-server.ps1 |
the launcher: sizes the VRAM line from measured fixed costs, starts the layer in front of llama-server. |
tooling/ |
build_engine.bat (Ninja + pip CUDA 13, sm_89), install_bin.ps1, serve.ps1 / stop.ps1 (hidden test server, log and PID files). |
layer/, suite/ |
the layer and the long exact-work suite, from bonsai-ada-surgery with the changes made here (layer/ORIGIN.md). |
bench/ |
the measurement scripts and every run's scoreboard and results (ML1..ML2f, E18..E21, HumanEval arms). |
receipts/ |
small text receipts cited by the docs: profiles, greedy dumps from the model's fork, probe logs. |
templates/bonsai-template.jinja |
the chat template used for every measurement (reasoning_effort, thinking on/off). |
docs/REPORT.md, docs/PREFILL.md, docs/ROADMAP.md |
what was found, the prefill investigation, what is left. |
Build from source
Windows without the CUDA toolkit (VS 2022 Build Tools C++ workload + NVIDIA's pip wheels):
python -m pip install cmake ninja nvidia-cuda-nvcc nvidia-cuda-runtime nvidia-cublas nvidia-cuda-nvrtc
git clone --recurse-submodules https://github.com/professorpalmer/mirai-s-ada
cd mirai-s-ada
tooling\build_engine.bat llama-server # ~30 min first time
tooling\install_bin.ps1 # copies the result into bin\ next to the CUDA runtime DLLs
Linux: the engine builds like any llama.cpp (cmake -S engine -B build -DGGML_CUDA=ON); the flags behind the
numbers are one llama-server command line:
llama-server -m Qwen3.8-27B-S-mirai.gguf -ngl 99 -fa on -c 262144 -np 1 -ctk q8_0 -ctv q8_0 --kv-vram-cells 44000 \
-b 2048 -ub 1024 --kq-mask-packed \
--spec-type draft-mtp --spec-draft-n-max 2 --spec-draft-n-max-tail 2 --spec-draft-window 16384 -ctkd q8_0 -ctvd q8_0 \
--reasoning-effort-allow medium --reasoning-max-tokens-floor 24576 --reasoning-budget 20480 --backend-sampling \
--chat-template-file templates/bonsai-template.jinja --chat-template-kwargs '{"reasoning_effort":"medium"}' --jinja
with GGML_MIRAI_PREFILL_PLANES=ffn in the environment. Untested on Linux here.
Measure it yourself
python bench\compare_servers.py --base http://127.0.0.1:18080 --against receipts\mirai-port\stock-greedy-nothink.json # greedy identity vs the model's fork
bash bench\product_smoke.sh # identity, layer round trip, decode by depth
bash bench\prefill_probe.sh # prefill by prompt length
python suite\run_suite.py --base http://127.0.0.1:18080 --base-b http://127.0.0.1:8080 --out suite-out # the paired suite
python bench\humaneval_wasi.py --arm medium # HumanEval 164, sandbox-scored
python bench\determinism_probe.py # same request and seed, seven conditions
Licenses and attribution
- This repository (launcher, tooling, layer, suite, docs, receipts): MIT, Cary Palmer.
- The engine (
engine/): llama.cpp is MIT (the ggml authors); PrismML's fork and alesha-pro's fork are MIT; their notices are preserved in the engine tree. The Mirai codec kernels are alesha-pro's work, ported with attribution in the commit history andengine/README.md. - The model weights are not redistributed here.
Qwen3.8-27B-S-mirai-GGUFis published by alesha-pro under the license on its Hugging Face card (Qwen3.8 itself is Apache 2.0); download it from there and keep its notices. - Nothing here is affiliated with, endorsed by or sponsored by alesha-pro, PrismML or Alibaba's Qwen team.
Credits
alesha-pro for the model, its codec and the llama.cpp fork it ships with. PrismML for the llama.cpp fork the engine is built on. sudoingX for the planar activation layout and batch-invariant mode in that fork. MIT for everything here; the weights are their authors'. Not affiliated with alesha-pro or PrismML.


