okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
e2de691c7
main
1# Strata - the details 2 3The technical side of Strata: every measured number, the API, images, all settings and how the engine works. 4New here? Start with the [README](../README.md); installing step by step is in [INSTALL.md](INSTALL.md), the models in 5[MODELS.md](MODELS.md), common problems in [TROUBLESHOOTING.md](TROUBLESHOOTING.md). 6 7> **On this page:** [Speed](#speed-measured) · [Other GPUs](#other-gpus-estimated) · [Which model?](#which-model) · 8> [Requirements](#before-you-start) · [Windows](#windows) · [Linux](#linux) · [API](#using-it) · 9> [MCP tools](#tools-from-mcp-servers) · [MCP server](#manage-strata-from-your-ai-assistant-mcp-server) · 10> [Images](#images-vision) · 11> [Troubleshooting](#troubleshooting) · [How it works](#how-it-works) 12 13--- 14 15## Speed (measured) 16 17RTX 5070 **12 GB**, Ryzen 5 7600 (6 cores), 64 GB DDR5-5200, Windows, engine 0.1.26 with the settings setup writes 18(`--prefill auto`, 8-bit KV above 4K, KV streaming from 64K). One code-agent prompt per length, 256 generated tokens, 19MTP speculative decoding on. "262K" is the model's full context window (a 259,943-token prompt). The IQ2_XS row was 20measured with Swift 1.5's IQ2_XS, which runs at the original's speed. 21 22**Engine 0.1.36 (#136), the same PC:** Q2_0's prompt experts run on fused int8 tensor-core kernels (RTX 30 and newer): 234K 1,294 -> 1,570, 32K 2,170 -> 2,653, 128K 2,123 -> 2,468 tokens/s (+16-22%), as close to an FP16 reference as the 24previous kernels (closer at 32K: teacher-forced KL 0.009 vs 0.012). The decode path's block selection and greedy 25argmax run on thread-block clusters (RTX 50, sm_90+; other cards keep the previous kernels; the same tokens): Q2_0 output at 4K 89 -> 93.5, at 128K 2664.5 -> 76.4 tokens/s. `STRATA_PF_FUSED=0` keeps the previous prompt kernels (byte-identical answers to 0.1.35); 27`STRATA_PF_FUSED=1` also runs the native IQ packs' fused kernels (opt-in: IQ2_XS prompts +12% at 4K, +3% at 32K, the 28IQ3 packs about even); `STRATA_QSA_CLUSTER=0` / `STRATA_ARGMAX_MULTI=0` turn the decode kernels off. The tables 29below are 0.1.26's. 30 31### Prompt processing (tokens/s) 32 33| Model | 1K | 4K | 32K | 64K | 128K | 262K | 34| --- | ---: | ---: | ---: | ---: | ---: | ---: | 35| **Q2_0** | 536 | 1,299 | 2,171 | 2,126 | 2,107 | 1,304† | 36| **IQ2_XS** | 534 | 1,256 | 2,092 | 1,754 | 1,752 | 1,181*† | 37| **IQ3_XXS** | 482 | 1,007 | 1,745 | 1,609 | 1,602 | - | 38| **IQ3_S** | 427 | 913 | 1,624 | 1,640 | 1,443 | - | 39| **Coder** | 656 | 1,583 | 2,177 | 2,236 | 2,208 | 1,034** | 40 41Engine 0.1.26; `bench/results/2026-09-29-speed-0126`. At 32K-128K that is 8-28% faster than 0.1.22. † not measured 42again: 0.1.22. \* measured with images on (the image encoder's VRAM reserve leaves fewer experts cached). \*\* not 43measured again: 0.1.14. 44 45### Output (tokens/s) 46 47| Model | 1K | 4K | 32K | 64K | 128K | 262K | 48| --- | ---: | ---: | ---: | ---: | ---: | ---: | 49| **Q2_0** | 87.3 | 93.0 | 81.8 | 76.2 | 73.7 | 60.3† | 50| **IQ2_XS** | 79.6 | 78.6 | 76.3 | 63.7 | 62.7 | 52.8† | 51| **IQ3_XXS** | 61.9 | 61.6 | 58.5 | 57.2 | 49.0 | - | 52| **IQ3_S** | 52.4 | 53.3 | 48.3 | 46.3 | 45.5 | - | 53| **Coder** | 58.9 | 55.1 | 54.9 | 53.2 | 43.0 | 42.8† | 54 55Engine 0.1.26, the same runs. † not measured again: 0.1.14. 56 57Output speed depends on the text as well: speculative decoding runs faster when more of the drafted tokens are 58accepted, so a different answer to the same prompt moves it by several percent. Run back to back on the 4K prompt, 590.1.14 writes 88.5 tokens/s and 0.1.12 85.7. The numbers before 0.1.13 (prompts about half as fast): 60[`bench/results/2026-09-24-final`](../bench/results/2026-09-24-final/matrix.md); these: 61[`bench/results/2026-09-28-speed-0114`](../bench/results/2026-09-28-speed-0114/README.md). 62 63IQ3_XXS and IQ3_S at 262K are not measured: with their 43 / 50 GB of experts, a 260K-token context brings a 64 GB PC 64to its memory limit by setup's estimate (the experts + the context's KV cache + 24 GB), so setup recommends up to 128K 65with them on 64 GB. A longer context you choose (`--context 262144`, or a pick in its list) is kept, with a note: users 66ran IQ3_S at 256K on 64 GB with RAM to spare (#406). In the low-RAM mode the KV cache stays in VRAM and the context 67does not count against RAM. IQ3_S (engine 0.1.4 or newer) is only published for the original model, not for Swift 1.5. 68 69**KV streaming (engine 0.1.5):** at 64K and more, setup keeps the context's KV cache in RAM and only the part the 70attention reads in VRAM (`--kv-resident 32768`), so more experts fit on the GPU. Q2_0 at 262K: 50.9 -> 62.6 tokens/s 71(1,589 -> 3,872 experts in VRAM); at 128K about +6%. The attention reads exactly the same values (only where the KV lives changes); it 72costs ~13.7 KB of RAM per context token (1.7 GB at 128K). Existing installs: run `START-HERE.bat --setup` once to turn 73it on. Setup turns it on when the RAM has room for it; `--kv-streaming on|off` overrides that (on past the RAM test with a 74note; never under WSL, which cannot stream). 75 76**4-bit KV cache (engine 0.1.8, optional):** `START-HERE.bat --setup` asks above 8K context (or pass `--kv q4_0`). It 77halves the KV cache's memory with a Hadamard rotation before 4-bit rounding (PR #21), about 4% faster at 128K, but it 78is measurably less precise on long documents (perplexity +8-12%; needle tests still pass). 8-bit stays the default. 79Details: [`bench/results/2026-09-27-kv-q4`](../bench/results/2026-09-27-kv-q4/README.md). 80 81**Hybrid K8V4 KV cache (engine 0.1.25, optional, PR #120):** `--kv k8v4` (`START-HERE.bat --setup --kv k8v4`) keeps 82the keys at 8 bits and stores the values as rotated 4-bit: 23% less KV memory than 8-bit, so more experts fit in 83VRAM. RTX 3090, the Coder at 198K context: 99 instead of 85 tokens/s output, the same needle results, prompts 2-5% 84slower. It streams its KV cache like the other formats (`--kv-resident N`): on an RTX 2060 SUPER 8 GB at 128K with 8520,480 resident cells, +780 expert slots over resident K8V4, and it scores better than 4-bit KV on long documents. 86 87**Reproducible greedy output (0.1.30, opt-in, `STRATA_IQ_MT_MIN=1`):** with the IQ models, the CPU computes an 88expert for one token with ggml's dot product and for several tokens with Strata's multi-token kernels, which round 89slightly differently. How many tokens share an expert depends on the drafts in a verify window, so the same prompt 90at temperature 0 can end in a different (equally good) answer when the drafting, the cache state or a resumed 91conversation differ (issue #152). `STRATA_IQ_MT_MIN=1` (in the config's `env`) uses the multi-token kernels for 92every group: the answer then no longer depends on the drafting. Measured on a Ryzen 7600 (AVX-512): IQ3_S decode 93-1..-3%, the other models the same; the default stays the fastest rule. On an Intel CPU of Alder Lake or later 94without AVX-512, where the AVX-2 kernel gathers the IQ3_S grid, `STRATA_IQ3S_MT1=1` (opt-in) gives IQ3_S the multi-token 95kernel for one token, which is the faster one there; it changes a lone token's rounding, so it is off by default. Through the server, two more things carry 96over from one request to the next (#410): the adaptive tier moves experts between RAM and VRAM (the GPU and the CPU 97round an expert differently), and the prompt cache resumes a repeated prompt and reads only its tail through the 98decode path. For byte-identical repeats add `--prompt-cache 0 --adapt-swaps 0 --pcie-frac 0` to the engine's args 99as well (#410): the PCIe share of the missed experts (computed on the GPU instead of the CPU) still made the first 100answer after a start differ from the next ones. Measured here (IQ3_XXS, a 3.6K-token prompt, 4 repeats): with all 101three switches 1 answer of 4, without `--pcie-frac 0` 2 of 4 (the first one differs), with the defaults 2 of 4. 102`--pcie-frac 0` costs decode speed (the missed experts all run on the CPU), so keep it for A/B runs. 103 104**The draft layer's tokens (0.1.27, `--draft-vocab`):** the MTP draft layer can only propose tokens from a subset 105of the vocabulary (`mtp/rt/draft_vocab.bin`). Since 0.1.27 the subset includes every Chinese, Japanese and Korean 106token (106,299 ids), so answers in those languages are 15-38% faster (Q2_0, RTX 5070). Its head takes ~180 MiB of 107VRAM, which the expert cache leaves free for it (0.1.28). `START-HERE.bat --setup --draft-vocab en` keeps the 108English/code subset from before (40,525 ids, ~110 MiB less VRAM, English answers 1-2% faster; CJK answers get 109almost no drafts). `--draft-vocab cyrillic` takes the English/code subset plus the whole Cyrillic script (58,963 110ids): the shipped subsets hold 142 of the vocabulary's 18,580 Cyrillic tokens, so Ukrainian or Russian answers got 1111.4 tokens a round; with it 2.1, and 83 -> 109 tokens/s (RTX 5090, the NVFP4 fork), English unchanged. 112`--draft-vocab fr` (0.1.39, #597) takes the English/code subset plus the 5,686 tokens that cover 99% of a French 113Wikipedia corpus (46,211 ids, `tools/draft_vocab.py --corpus`): 23.6% of French text's tokens were outside the 114English/code subset, 0.7% are outside this one. Drafts accepted in French answers 0.51 -> 0.60 (IQ3_XXS, RTX 5070, 1158 prompts x 2 passes; English 0.61 -> 0.63 and code 0.77 -> 0.78, no loss), and 141 -> 158 tok/s in French on an 116RTX 5090 (IQ3_S, the reporter's measurement). 117`tools/draft_vocab.py` builds and inspects subsets. When the start stops with "the draft head does not fit" (a 11812 GB card with a long context, #474), the engine says how much the head needs, how much VRAM is free and which 119smaller subset fits, and the server's start error repeats it; setup suggests `--draft-vocab en` on cards under 12014 GB (only a suggestion: nothing changes unless you pass it). 121 122**Serving without the draft layer (`--mtp` is optional):** `serve` runs without `--mtp`. Drafts then come from the 123suffix/prompt-lookup drafter only (or one token per round), every token is still verified against the model, and the 124draft layer's VRAM (~0.7-1 GiB with its head) goes to the expert cache: 1,000 -> 1,678 slots in one A/B on an 8 GB 125card. The conversation cache (`--conversation-cache-mib`) stays on: a parked conversation then carries no draft K/V. 126 127**Low-RAM mode (engine 0.1.26, chosen by setup):** normally all of a model's experts are copied into RAM (23-50 GB, 128pinned) and the GPU holds a copy of the most-used ones. On a PC whose RAM cannot hold them beside the system (the 129experts plus ~10 GB), setup instead maps them from one file in the model's folder (`--mmap-experts`, the pack's 130`experts.bin`, +23-50 GB of disk). The OS file cache holds what the GPU does not, and it can give that memory back. 131On the Coder the engine's committed memory drops from 36 to ~13 GB, with the same answers. With a big GPU (an RTX 1325090 holds all of the Coder's experts, most of Q2_0's) it runs at nearly the usual speed. With a small one, most 133experts come from the SSD and it is much slower (setup says so). `START-HERE.bat --setup --low-ram on|off` overrides 134the choice. 135 136**Low-RAM mode, resident (engine 0.1.30):** when the experts the GPU does not hold fit the RAM (with the same ~10 GB 137beside them), setup picks the resident variant instead (`--resident-experts`): at start the engine copies exactly those 138experts from `experts.bin` into RAM (page-locked when the driver allows, else locked in RAM), so while it answers 139nothing is read from the SSD, however little RAM the OS leaves for its file cache. Examples with setup's context: a 14032 GB PC with a 24 GB GPU runs Q2_0, IQ2_XS and the Coder this way (~16-18 GB of experts in RAM, the GPU holds the 141other ~18 GB), a 32 GB PC with a 12-16 GB GPU the Coder; IQ3_XXS on a 32 GB PC stays mapped. The details: 142- The prompt path borrows room in the GPU's expert cache for its buffers and puts those experts back after the prompt; 143 as far as the RAM allows, their experts are kept in RAM too (so a prompt reads nothing from the SSD either). 144- The cache still follows the conversation (`--adapt-every`): a swap copies the evicted expert back from VRAM into the 145 RAM place of the one that replaces it, so the RAM copy keeps holding exactly what the GPU does not. 146- `--adapt-async 1` (opt-in, `--serve`): the swaps of a round advance between decode windows on a helper thread 147 (copy back, copy in, move into RAM) instead of one window waiting for the whole round. Not with `--batch` or 148 `--peer-device` (the blocking tier runs there). It is not bit-exact from run to run: which window first computes a 149 swapped-in expert on the GPU (which rounds differently from the CPU) depends on when its copy lands. 150 It stays on the blocking tier (said in the log) when the exchange buffers are not page-locked, and with 151 `--pipeline-windows`; the stats line reports ms per round. 152- `STRATA_EXCHANGE_ROTATE=1` (opt-in): an adaptive swap hands buffer ownership over instead of copying the evicted 153 blob into the RAM copy (equal-size blobs, fully page-locked copy). Same tokens, fewer host copies; it works with 154 `--adapt-async 1` too. Details and the measurement: [EXCHANGE_ROTATION.md](EXCHANGE_ROTATION.md). 155- The answers are the plain mapped mode's for the same expert placement: the bytes are the file's. With a page-locked 156 copy the GPU also takes its usual share of the misses over PCIe (`--pcie-frac`), as with enough RAM; `--pcie-frac 0` 157 (or `STRATA_RESIDENT_PIN=0`) gives the mapped mode's exact tokens. 158- The engine leaves 4 GB of the RAM it finds free (`STRATA_RESIDENT_HEADROOM_GIB`); when even the experts the GPU does 159 not hold do not fit, it says so and runs the plain mapped mode. The server log shows, per request, how many expert 160 reads went to the file (`resident RAM: ... blob reads from the file`: 0 in steady use). 161- `--low-ram resident|mmap` forces one variant (also on a PC with enough RAM, e.g. to try it). 162- Several GPUs (#364, #384): setup recommends one GPU in the low-RAM mode (the resident variant has no layer split 163 yet), and asks; `--gpus 0,1` (or answering 2) shares the model across them with the mapped variant 164 (`--mmap-experts`): the cards together hold more of the experts, and two users measured it 1.3-1.6x faster than 165 one card, but the OS file cache can fill the RAM to 0 free during long prompts. `--yes` keeps one GPU. A config 166 with `--resident-experts` started with `--gpus` switches to `--mmap-experts` with a note, and the engine runs that 167 pair as `--mmap-experts` with a warning instead of refusing it. **Since 0.1.40 (#642, #848)** setup requires an 168 engine that runs the resident variant on a split, so it keeps both cards, resident, as for any config: 169 [MULTI_GPU.md](MULTI_GPU.md#using-it). 170 171**A mapped arena for small RAM (Linux, opt-in, 0.1.39, PR #640):** `STRATA_ARENA_MMAP=1` maps a native pack's expert 172arena read-only from the pack's `experts.bin` instead of reading it into locked RAM, for a PC whose GPUs hold most 173experts but whose RAM is small (2x 16 GB GPUs with 32 GB of RAM: ~1 GB -> 25 GB available while serving). The first 174start writes `experts.bin` (when the drive has room for it), later starts map it; the pages of the experts a GPU holds 175are handed back to the OS. Run it with `--pcie-frac 0` (the GPUs get no mapped alias). Without the variable nothing 176changes. 177 178**Releasing mapped expert pages on Windows (opt-in):** `STRATA_FILE_RELEASE=1` lets `FileExpertSource` trim the 179full file-backed pages of experts after their GPU uploads complete, including the slots lent to prefill and then 180refilled. It works with `experts.bin` and the direct GGUF views; shared boundary pages and private/pinned buffers 181are left alone. Unset or `0` keeps the previous behavior. On one 32 GB Windows 11 laptop with an RTX 4080 Laptop 182and a Thunderbolt RTX 3090, IQ2_XS with `--mmap-experts --layer-split 12 --trim-stage-weights` raised median available 183RAM from 0.51 to 12.19 GiB across 1K/4K/16K prompt trials, with 3.7-4.4% lower prefill throughput. It did not reduce 184committed memory or physical SSD reads. This is a working-set hint, not an unmap or a guarantee that the OS drops 185its file cache. See the [configuration, measurements and limits](../bench/results/2026-10-04-windows-mapped-release/README.md). 186 187**Low-RAM mode without `experts.bin` (engine 0.1.31):** for the native packs (IQ2_XS, IQ3_XXS, IQ3_S, the Coder, Swift, 188Q2_0 packed by `tools/iq_pack.py`; not the canonical Q2_0 pack setup makes for AVX-512 CPUs) the mapped mode no longer 189needs the pack's `experts.bin`: when the pack has none, the engine 190maps the model's GGUF files themselves and reads each expert's gate, up and down rows from where `native_experts.txt` 191says they are (the files are checked against it first: every tensor's name, type, shape, offset and bounds). That 192saves the 23-50 GB copy on the disk. The answers are the same: on the Coder, 64 greedy tokens from `experts.bin` and 193from the GGUF gave identical tokens and logits. An expert read from the GGUF is three reads instead of one, so the 194engine fetches a layer's missing experts on 8 threads (`STRATA_FETCH_THREADS`) with one batched page request 195(Windows `PrefetchVirtualMemory`). With an `experts.bin` in the pack, nothing changes. Setup does not use this yet. 196 197**A RAM budget (engine 0.1.31, `--resident-budget-gib N`):** the resident variant for a model whose experts do not all 198fit: the N GiB of experts the GPU cache does not hold that the expert profile ranks hottest are copied into RAM at 199start (locked; page-locked when the driver allows the whole budget), and the rest are read from the files. 200It implies `--mmap-experts` and leaves 4 GiB of headroom. On Windows, available commit capacity also 201limits the budget; a larger N is clamped to the smaller limit less 4 GiB and a 256 MiB margin, with a message. 202A clamped budget no longer fails the safety check that follows (#403). A budget that cannot be kept at all is a 203warning, with every expert read from the files. Setup sets N with `--resident-budget-gib N`. With 204the GGUF read in place it also warms the next layer's likely experts: while the CPU works on a layer, a thread applies 205the next layer's router to this layer's input and asks the OS for the pages of the predicted experts that neither the 206GPU nor the RAM budget holds (only pages - the experts computed are the same; `STRATA_LOOKAHEAD=0` turns it off). This 207is what runs [Unsloth's UD-Q4_K_XL](UNSLOTH_Q4.md) (72 GiB of experts) on a 64 GB PC: 7-8.5 tokens/s at N = 40 on an 208RTX 5070, against ~3 tokens/s before these changes. 209 210**Switches added in 0.1.40 (all off unless noted; none changes the default output):** 211- `--kv-grow` (or `STRATA_KV_GROW=1`; `--no-kv-grow` turns it off): the K/V takes VRAM only for the cells the requests 212 reach, and the expert cache holds the rest, giving slots back as the context grows. It needs one GPU, an expert 213 profile, the whole K/V in VRAM (no KV streaming) and every expert in RAM (not the resident low-RAM mode); otherwise, 214 and with `--batch`, `--vram-elastic` or `--peer-device`, the engine says so and stays off. 215- `--host-core last` (or `STRATA_HOST_CORE=last`, Windows): the host thread runs on the last physical core and the 216 workers take the first. Windows sends a GPU's interrupts to the first core, where a host spinning on the GPU's flags 217 waits for them (`--host-core first` is the default; the startup log names the cores). 218- `STRATA_ADAPT_LAG=2` (#764): a window takes the adaptive tier's swaps once they are two windows old (default 1, 219 as 0.1.39). `STRATA_PREFILL_EQUAL=1` (#693): a prompt segment is read in chunks of equal size, not full chunks and a 220 short last one (changes the rounding). `STRATA_OWNED_PRICE=exact` (#796): the cache sizing prices the prompt path's 221 own buffers by their real allocation instead of 0.1.39's rule. 222- `STRATA_Q2_BITPLANE=1`: a bit-plane row kernel for Q2_0 on CPUs with AVX2 and no AVX-512 (changes the last bits). 223 `STRATA_NO_AVXVNNI=1` turns the AVX-VNNI forms of the i-quant, IQ4_NL and Q2_0 rows off on CPUs that have them 224 (Alder Lake, Sapphire Rapids and later); they give the same bits as the AVX2 forms, 4-25% faster rows. 225- Draft layer: `--lookup-chain-min M` (the shortest context match `--lookup-chain` extends, default 3), 226 `--mtp-hnorm stream` (one norm per stream, as llama.cpp's MTP graph) and `--mtp-draft-vocab FILE` (a token subset 227 of your own instead of `<mtp>/draft_vocab.bin`). 228- Elsewhere: HIP `STRATA_DENSE_MMQ=1` and `STRATA_HIP_ADAPT_KERNEL_COPY=1` in [AMD_HIP.md](AMD_HIP.md#model-and-serving-configuration); 229 `STRATA_KEEP_EMPTY_TURNS=1` and `STRATA_TOPK_STREAM=0` in [TROUBLESHOOTING.md](TROUBLESHOOTING.md). 230 231 232**Read-ahead at start (Linux):** the weights, the native dense matrices, the GPU cache's fill from the profile, the 233resident RAM copy and the MTP draft files are asked for ahead of their reads (madvise / posix_fadvise WILLNEED in 234128 KiB steps), so the drive sees a deep queue instead of one page fault at a time. Measured on a Gen3 NVMe (RTX 5090, 23532 GB, Q2_0 resident at 262K): ready in 70 s instead of ~920 s; the fill went from 39 MB/s to 3.2 GB/s. 236`STRATA_READ_AHEAD=0` turns it off; `STRATA_FILL_AHEAD=N` sets how many fill pairs are asked for ahead (default 256). 237 238**How much came from where:** with `--stats` the engine prints the tiers of the decode (`expert tiers`: blobs from the 239RAM copy, blobs and MB from the files, the time spent reading them; `routing prefetch`: how many of the file reads had 240been warmed). The server log has the same per request (`expert tiers: GPU ... hits ...; RAM ... blobs, files ... 241blobs ... MB read`), and `GET /metrics` lists `ram_blobs`, `file_blobs` and `file_mb` for each recent request (with 242engine 0.1.31 or newer). It also lists each request's speculative drafts, `drafts_offered` and `drafts_accepted` 243(`null` when the engine did not report them), and their sums since the server started in `totals` (#457). 244Its `hit_rate` is the VRAM share of the experts looked up while answering: experts the GPU reads over PCIe 245(`--pcie-frac`) are not in it, so a higher `--pcie-frac` raises it even when decoding gets slower. `pcie_share` 246(engine 0.1.39 or newer, #588) is their share of all routed experts, and the server log and the Monitor tab show it 247beside the hit rate. 248 249**Where a decode window's time goes (profiling, #610):** start the server with `STRATA_DECODE_TIMING=1` (and 250`STRATA_VERIFY_PROFILE=1` for the GPU's side) in the environment. After each request the engine log then has one 251`strata decode timing:` line - windows, tokens per window, and per window the verify time split into the wait for the 252GPU, the CPU expert pool (plan, activation quantization, jobs) and the stage, plus commit and draft - and one 253`strata decode GPU stages (ms/window):` line with the GPU time of each stage (GDN and QSA layers, the VRAM expert 254hits, the router, the head, ...). The GPU profile times every stage with events, so it slows the decode a little: 255use it to compare, not to measure speed. This works with every pack; `--gpu-stages` (a one-token replay of 256per-layer graphs) refuses a native (IQ) pack, which has no such graphs. 257 258Time to first token is prompt length / prompt speed: with Q2_0 about 4 s at 4K, 25 s at 32K, under 2 minutes at 128K 259and 4.5 minutes at 262K (engine 0.1.13 made long prompts about twice as fast, below). 260 261**Faster prompts (engine 0.1.13):** the prompt is read in chunks of up to 8,192 tokens instead of 2,048 (`--prefill 262auto`: the largest chunk whose buffers fit in the expert-cache slots it borrows, and a request borrows only what its 263prompt needs); the experts are multiplied by llama.cpp's quantized MMQ kernels instead of being expanded to FP16 264first; the next layer's experts stream over PCIe while the current layer's attention runs; the PLE block runs for the 265whole chunk at once; unpinned experts are copied by helper threads. Measured on the RTX 5070 12 GB, 64 GB RAM, 26632K-token prompt: Q2_0 572 -> 1,290 tokens/s, IQ3_S 383 -> 1,208. Through the server (Q2_0, 128K context): 999 tokens 267353 -> 438 tokens/s, 6,927 tokens 529 -> 1,077, 28,584 tokens 584 -> 1,249. Output speed is unchanged. Needles 5/5 268(1K-262K). Details and the quality check: 269[`bench/results/2026-09-28-prefill-speed`](../bench/results/2026-09-28-prefill-speed/README.md). Existing installs 270switch to `--prefill auto` the next time START-HERE / setup.sh starts them. The raw numbers: 271[`bench/results/`](../bench/results/). The [paper](paper/Strata-Paper.pdf) explains every number. 272 273## Other GPUs (estimated) 274 275Not measured - estimated from the runs above (same CPU and 64 GB RAM): the GPU part scaled by memory bandwidth, the CPU 276part by how many more experts the card's VRAM holds. Treat as **±20%**. Numbers are *prompt / output* tokens/s. 277The prompt figures predate engine 0.1.13, which about doubled prompt speed on the measured card; how much of that a 278card gains depends on its PCIe link (the experts stream over it), so they are still the older estimates. 279 280| GPU | Model | 1K | 4K | 32K | 64K | 128K | 262K | 281| --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | 282| RTX 5060 Ti 16GB | Q2_0 | ~341 / ~80 | ~472 / ~87 | ~501 / ~81 | ~492 / ~72 | ~476 / ~62 | ~435 / ~53 | 283| | IQ2_XS | ~291 / ~80 | ~406 / ~77 | ~434 / ~63 | ~426 / ~62 | ~413 / ~51 | ~383 / ~47 | 284| | IQ3_XXS | ~249 / ~66 | ~359 / ~65 | ~381 / ~56 | ~374 / ~54 | ~363 / ~45 | - | 285| RTX 3090 24GB | Q2_0 | ~355 / ~128 | ~491 / ~140 | ~521 / ~130 | ~512 / ~115 | ~495 / ~100 | ~453 / ~85 | 286| | IQ2_XS | ~303 / ~131 | ~422 / ~128 | ~451 / ~103 | ~444 / ~102 | ~430 / ~85 | ~398 / ~78 | 287| | IQ3_XXS | ~260 / ~106 | ~374 / ~103 | ~396 / ~89 | ~390 / ~85 | ~378 / ~71 | - | 288 289More VRAM matters more than a faster GPU: every extra GB holds ~700 more experts, and every expert on the GPU is one the 290CPU does not have to compute. A 3090's 24 GB takes most of the CPU work away. (Since 0.1.14 the expert profile ranks 291all 24,576 experts; before, the cache stopped at 8,000, about 10-14 GB. `tools/make_profile.py` builds a profile from 292your own prompts: run the engine once with `--dump-routing trace.bin`, see the tool's help. The shipped profile already 293ranks every pair, so a trace only changes the order with `--reorder` (0.1.39, #587): your trace's pairs first, then the 294base's, then the rest.) 295 296## Which model? 297 298All three are [ISTA-DASLab's GSQ-RCO quantizations](https://huggingface.co/ISTA-DASLab/Qwen3.8-Flash-Next-GSQ-RCO-GGUF) 299of [Qwen3.8-Flash-Next](https://huggingface.co/Qwen/Qwen3.8-Flash-Next). 300 301| Model | Download | RAM it uses | Speed | Quality | 302| --- | ---: | ---: | --- | --- | 303| **Q2_0** | 66 GB | ~34 GB experts + ~6 GB | fastest | good | 304| **IQ2_XS** | 68 GB | ~36 GB experts + ~6 GB | close to Q2_0 | a bit better | 305| **IQ3_XXS** | 76 GB | ~43 GB experts + ~6 GB | slower (more CPU work) | best | 306 307With 64 GB of RAM all three fit (close the browser for IQ3_XXS, and keep its context at 128K or less). With 48 GB only Q2_0 / IQ2_XS may fit. With 32 GB: the Coder (below). 308 309### Or: the Coder (half the experts, for code) 310 311**[Qwen3.8-Flash-Next GSQ-RCO Coder](https://huggingface.co/ISTA-DASLab/Qwen3.8-Flash-Next-GSQ-RCO-Coder-GGUF)** is 312ISTA-DASLab's expert-pruned release: 256 of each layer's 512 experts are kept (still 10 active per token), chosen with 313RCO on code, agentic and vision calibration data; its authors report 91.3% of the full model's SWE-bench Verified and 31498.7% of LiveCodeBench v6. One size, named IQ1_M for its 1.89 bits per *original* parameter; the kept experts are 315stored like IQ3_S (IQ2_S-IQ4_XS gate/up, IQ4_NL/Q2_0 down). Shard 1 is 29.6 GB (experts: 23 GB of RAM), so it runs 316on **32 GB of RAM**, and at 262K on 64 GB. Its shard 2 and its vision encoder are the original's files: with the 317original installed, setup downloads only shard 1. Strata ships its expert profile (`data/expert-profile-coder.bin`, 318the shipped ranking mapped onto the kept experts through the release's `rco-allocation.txt`: 72% of the expert 319reads hit the GPU on a 12 GB card). Images work; the experimental speed projection loads and runs on it (it was made 320for the full model). 321 322``` 323START-HERE.bat --setup --family coder 324``` 325 326### Or: Swift 1.5 (a fine-tune that thinks shorter) 327 328The setup's first question also offers **[Swift 1.5](https://huggingface.co/ukisai/Swift-1.5-Qwen3.8-Flash-Next-GSQ-RCO-GGUF)**, 329UkisAI's fine-tune of Qwen3.8-Flash-Next, trained to reach the answer with much less thinking (its authors: 63% fewer 330thinking tokens, 1.8x sooner answers, under 1% accuracy loss). Same architecture, the same three sizes, its own 331vision encoder; Strata runs it at the same speed (4K, IQ2_XS: 465 prompt / 78.7 output tokens/s, vs 467 / 78.3 for 332the original). Its authors recommend **IQ2_XS** (their Q2_0 is marked experimental). Its license is the Swift Open 333License 1.0 - read it on the model page. 334 335Our small check (8 reasoning questions, default thinking, IQ2_XS): both models got **8/8**; Swift used **1,234** 336output tokens in 28 s, the original **2,682** in 46 s - most of the difference from one question the original 337thought about for 1,524 tokens. Not a benchmark, but consistent with the claim. 338 339``` 340START-HERE.bat --setup --family swift --model IQ2_XS 341``` 342 343### Experimental: Unsloth's UD-Q4_K_XL 344 345A 4-bit quantization of the same model (111 GB, 72 GiB of experts). Setup offers it from engine 0.1.32 346(`--family unsloth --model UD-Q4_K_XL`: a RAM budget of your RAM less 24 GB, the rest read from the SSD); what it 347does and the manual workflow are in **[docs/UNSLOTH_Q4.md](UNSLOTH_Q4.md)**. On a 64 GB PC with a 12 GB RTX 5070 it writes 7-8.5 348tokens/s, most experts read from the SSD; it picks the same tokens as llama.cpp on the same file at 97.5-99% of 349the positions of short greedy answers, 90-91% after a 16K prompt, differing mostly at near-ties 350([measured](UNSLOTH_Q4.md#quality-against-llamacpp-on-the-same-file)). 351 352## Before you start 353 354You need **only a graphics driver**: NVIDIA 580 or newer (update it with the NVIDIA App or from 355[nvidia.com/drivers](https://www.nvidia.com/drivers)), or for AMD the one in [INSTALL.md](INSTALL.md#what-you-need). 356Everything else is installed for you the first time. 357 358| | | 359| --- | --- | 360| GPU | NVIDIA **RTX 20, 30, 40 or 50 series**, **12 GB VRAM or more** (8 GB runs, slowly). Measured on an RTX 5070 and an RTX 3090; RTX 20 (Turing, since 0.1.27) was tested by a contributor on an RTX 2070. Or AMD **Radeon RX 7900 XT / XTX, RX 7800 XT / 7700 XT, RX 9060 XT, RX 9070 / 9070 XT, Radeon AI PRO R9700, RX 6800 / 6900 series**: [AMD_HIP.md](AMD_HIP.md). | 361| RAM | **64 GB** recommended (see the table above). | 362| CPU | x86-64 with AVX2 (any Intel/AMD desktop CPU from the last ~8 years). AVX-512 (Ryzen 7000/9000) is a bit faster. Older CPUs without AVX2 are experimental and slow: [Older CPUs](INSTALL.md#older-cpus-experimental). | 363| Disk | ~70-80 GB free for the model, ~6 GB for the MTP layer (+1 GB with images). **Q2_0 on an AVX-512 CPU** also writes a one-time ~40 GB pack for the fast CPU kernel (34 GB of experts in its layout, plus the dense weights). An NVMe SSD is strongly recommended. | 364| OS | Windows 10/11, or Linux (Ubuntu 22.04/24.04 get everything installed automatically). | 365 366What the first start installs: in this folder `.venv/`, `engine/` and `third_party/`; the model files (`models/`, 367`packs/`, `mtp/`, 70-120 GB) in **`Strata-data` next to this folder**, so a new copy of Strata (an update unzipped 368elsewhere) finds them and sets itself up the same way. The place is remembered per user (`%APPDATA%\Strata\settings.json`, 369`~/.config/strata/settings.json`); `--data-dir` chooses another. Installs from before 0.1.16 are moved there by the next 370start (a rename on the same drive; files on another drive are used where they are). 371Python 3.12 if you have none (for your user account, no admin), a private Python environment, NVIDIA's CUDA libraries 372(from pip, ~0.4 GB), the ready-made Strata engine for RTX 20/30/40/50, the model and the MTP draft layer. If no 373ready-made engine fits your PC, it offers to install the build tools (Visual Studio Build Tools + CUDA Toolkit on 374Windows, `build-essential` + CUDA on Ubuntu) and compiles the engine for your GPU (asks first; 20-40 minutes once). 375 376--- 377 378## Windows 379 380### Double-click `START-HERE.bat` 381 382**The first time** it asks four questions and does the rest: 383 3841. **Which model?** Qwen3.8-Flash-Next (the original) or Swift 1.5 (the fine-tune that thinks shorter). 3852. **Which size?** Q2_0, IQ2_XS or IQ3_XXS (it recommends one for your RAM). 3863. **How much context?** 8K to 256K tokens (it recommends one for your VRAM). 3874. **Images?** yes / no (see [Images](#images-vision)). 388 389Then it downloads and prepares everything (the model is 66-76 GB, so the first start takes a while; an interrupted 390download continues where it stopped) and **starts the model**: your browser opens `http://127.0.0.1:8080`, the Strata 391app. It has three tabs: 392- **Chat:** streaming answers, the model's thinking (folded away once it answers), code with a copy button, pictures when 393 images are on, and sampling and thinking-level settings. Chats stay in your browser. 394- **Monitor:** what the model is doing (reading the prompt, with progress, or writing, at how many tokens/s); GPU load, 395 VRAM, temperature, power and PCIe traffic; CPU, RAM and disk; the context in use; the last requests. 396- **About:** the model and engine settings, and the addresses to connect other apps. 397 398`http://127.0.0.1:8080/?q=your question` opens it with a new chat already asking. The API is at 399`http://127.0.0.1:8080/v1` for your apps. 400 401**Every time after that**, `START-HERE.bat` just starts the model (30-90 s to load 34-43 GB into RAM). Nothing is 402downloaded again. Closing the window stops the model. 403 404``` 405START-HERE.bat --setup install another model, or change context / images 406SETUP.bat the same (double-click it) 407START-HERE.bat --model IQ2_XS --context 32768 --vision yes --yes no questions 408START-HERE.bat --gguf-dir D:\models\IQ2_XS use GGUF files you already have 409START-HERE.bat --data-dir E:\Strata-data keep the model files somewhere else 410START-HERE.bat --port 8081 another port 411START-HERE.bat --gpu 1 another GPU (numbered as nvidia-smi; setup picks the one with the most VRAM) 412START-HERE.bat --calibrate tune the engine for this PC (about 5-10 minutes), then start 413``` 414 415With more than one model installed, it asks which one to start. `run-<model>.bat` starts a model directly. 416 417**Tuning for your PC (`--calibrate`, engine 0.1.19).** Three engine settings depend on the PC more than on the model: 418- the share of the experts missing from VRAM that are copied to the GPU instead of computed by the CPU 419 (`--pcie-frac`: a fast PCIe link and a slower CPU want more, a laptop's narrower link less); 420- how sure the draft layer must be to add another guess to a check (`--spec-min-p`); 421- how many CPU threads compute experts (`--pool-workers`: on CPUs with efficiency cores, fewer can be faster). 422 423The defaults were measured on a Ryzen 5 7600 with an RTX 5070. Setup offers to measure them on your PC after an 424install; `START-HERE.bat --calibrate` (Linux: `./setup.sh --calibrate`) does it any time. It measures the output 425speed with each setting and keeps one only when it is more than 3% faster. The result is remembered per PC and model 426(in the settings file next to the data folder's record), so updates keep it. 427 428### Running it at startup (Task Scheduler) 429 430To have the model up at logon, people start the serve from **Task Scheduler** (or a service). Beware: Windows 431throttles such contexts, and the model's ~40 GB expert load then crawls at **~0.05 GiB/s (13-14 minutes)** 432instead of **~1.4-1.5 GiB/s (~35 seconds)** - a 24x slower start. Measured on an RTX 5070 Ti + Ryzen 7 9800X3D 433+ NVMe, same binary, same args, same cache state: 434 435| How the serve starts | Expert load | 436| --- | ---: | 437| Double-click / terminal / SSH | 1.42-1.52 GiB/s (~35 s) | 438| Task Scheduler with its defaults | 0.05 GiB/s (821-841 s) | 439| Task Scheduler with the two settings below | 1.42 GiB/s (35 s) | 440 441In the task's properties set both of these (the defaults are the opposite): 442 443- **Priority level: Normal** (Options tab; the default is Below normal), and 444- **Run with highest privileges** (General tab; without it the task runs with a limited user token - which 445 also strips `SeLockMemoryPrivilege`, the privilege Windows large pages need). 446 447(Both were changed at once, so the isolated effect of each is not measured.) If the model still starts 448slowly, the engine prints a hint under its `loaded ... GiB at ...` line naming this cause. 449 450### Chat in the terminal (optional) 451 452``` 453.venv\Scripts\python chat.py 454``` 455 456--- 457 458## Linux 459 460```bash 461./setup.sh 462``` 463 464The same questions, the same automatic install (it uses `sudo apt` for Python and, only if it has to compile, 465for the build tools), and the same start: `http://127.0.0.1:8080`. Later runs of `./setup.sh` (or `./run-<model>.sh`) 466start the model directly. Options as on Windows (`./setup.sh --setup`, `--model Q2_0 --yes`, `--gguf-dir /data/Q2_0`). 467Terminal chat: `.venv/bin/python chat.py`. 468 469- **Updating:** `git pull`, then `./setup.sh`: it compiles the engine again when its source changed (a minute or 470 two for the changed files). If that compile fails, it says so and starts the engine you had. 471- **Other distributions** (Arch, Fedora, ...): install the C++ compiler and the CUDA Toolkit 13 with your package 472 manager first (Arch: `sudo pacman -S base-devel cuda`); setup finds `nvcc` on PATH, in `/usr/local/cuda*` and in 473 `/opt/cuda*`, and does the rest. 474- **WSL** works (Ubuntu 24.04 tested), with one limit: the NVIDIA driver pins only about 1 GB of RAM there, so KV 475 streaming (`--kv-resident`) is off and the KV cache stays in VRAM, and the experts are copied to the GPU from 476 unpinned RAM (slower prompts than native Linux). 477 478--- 479 480## Sharing the GPU with other programs (optional) 481 482By default the model stays loaded until you close Strata. On a PC that also games, renders or runs another model 483server, three server options (all off by default; also as keys in `strata-<model>.json`) give the VRAM back: 484 485| Option | Config key | What it does | 486| --- | --- | --- | 487| `--idle-unload 600` | `"idle_unload_s": 600` | unload the model after 600 s without requests; the next request loads it again | 488| `--min-free-vram-mib 11000` | `"min_free_vram_mib": 11000` | load an unloaded model only when that much VRAM is free (it waits up to 15 s for memory being given back), else answer **503** "the GPU is in use by another program" instead of starting into what a game left (with several GPUs it checks the first one) | 489| `--before-load "cmd"` | `"before_load": "cmd"` or `["cmd", "arg"]` | a command run before the model is loaded again, e.g. one that unloads another server's model | 490 491`POST /unload` unloads it now (`409` while a request is running) and `POST /load` loads it ahead of a request (both 492with `Content-Type: application/json`, e.g. `curl -X POST -H "Content-Type: application/json" localhost:8080/unload`); 493`/health` says `"loaded"`, `/v1/models` lists it as `unloaded` (like llama.cpp's router), `/props` sets 494`is_sleeping` and the Monitor shows the state. Unloading ends the engine process - and the image encoder, when images 495are on; it is started again first, as at a start - so their VRAM and RAM go straight back. The model files stay in 496the OS file cache, so loading again takes seconds while that RAM is not needed elsewhere. Measured on an RTX 5060 Ti 49716 GB with Q2_0 in the low-RAM mode: unloading takes ~0.3 s, and a request to an unloaded model answered after 4984.6 s (text) or 14.7 s (a picture, image encoder on the CPU). 499 500**Giving part of the VRAM back while it keeps serving (#533, opt-in, one NVIDIA GPU).** With `"vram_elastic": true` 501in the config (the engine flag `--vram-elastic`), the expert cache is allocated in 512 MiB segments 502(`"vram_segment_mib"`), and `POST /v1/vram` with `{"reserve_mib": 8000}` shrinks it between requests until that much 503VRAM is free for another program; `{"reserve_mib": null}` grows it back towards its full size, keeping the reserve 504the engine started with (`--vram-reserve-mib`), and `{"reserve_mib": 0}` takes all of it back. A request that is 505running finishes first. The experts of the segments given back are computed on the CPU, like any expert outside the 506cache, so answers keep coming, slower; growing back puts the same experts in the same slots. Nothing resizes on its 507own. Not with a layer split, the helper caches, `--peer-device` or the resident low-RAM mode. Measured on an RTX 5070 50812 GB with Q2_0 (4.8 GiB cache): `{"reserve_mib": 6000}` took 78 ms and freed 4.3 GiB (the cache keeps 0.5 GiB for 509the prompt path), decode 44 -> 33 tok/s; growing back took 92 ms and the answers were token for token the ones before 510the shrink. Without the flag nothing changes (the same answers as without it). 511 512**Keep what the expert cache learned across restarts (opt-in, engine 0.1.36, #477):** a start fills the GPU's expert 513cache from the shipped profile, and the adaptive tier (`--adapt-every`) then moves in the experts your requests use. 514With `"expert_profile_save": "expert-profile-learned.bin"` in `strata-<model>.json` the engine saves that as a 515profile - the experts in VRAM first, then the routing it counted since the start, then the shipped order - on a 516clean exit and every 10 minutes between requests (`"expert_profile_save_every": 5` for another interval, `0` for 517exit only), written to a temporary file and renamed, so a crash never leaves half a file. The next start begins from 518it instead of the config's `--expert-profile` when it is a profile of the same model (else from the config's, as 519before). A relative path is in the Strata folder; one file per model, and a profile per project works the same way 520(point the key at another file). The file is a fingerprint of what you used the model for: it stays on your PC. 521Without the key nothing is counted or written. Setup rewrites the config when run again: add the key again then. 522 523--- 524 525## Using it 526 527The server listens on `http://127.0.0.1:8080` (change with `--port` in setup, or edit the run script). 528 529| API | Endpoint | 530| --- | --- | 531| OpenAI Chat Completions (stream and non-stream, tools) | `POST /v1/chat/completions` | 532| Anthropic Messages (stream and non-stream, tools) | `POST /v1/messages` | 533| OpenAI Responses (stream and non-stream, tools; stateless, [below](#the-responses-api-and-codex-cli)) | `POST /v1/responses` | 534| Model list / health | `GET /v1/models`, `GET /models`, `GET /health` | 535| Model properties | `GET /props` (also accepts `?model=<loaded-model-id>`) | 536| What the model is doing right now | `GET /status`, `GET /slots` (single slot, busy or idle) | 537| Save / restore the conversation to a file (session files, below) | `POST /slots/0?action=save\|restore` | 538| Everything the Monitor tab shows (engine, live state, last requests, hardware) | `GET /metrics` | 539| The MCP servers, their state and tools ([below](#tools-from-mcp-servers)) | `GET /mcp` | 540 541`/models` and `/v1/models` list only the loaded model, with its context limit and input modalities. `/props` exposes the original chat template, context limit, configured generation defaults (shared settings take precedence), model path and engine version when available. Context means the full engine context, not the resident KV window. `n_predict: -1` means no fixed output cap. Unconfigured sampling fields are omitted. `autoload` has no effect; an unknown `model` returns 404. These metadata endpoints and `/slots` require the API key when one is configured. They do not load, unload or restart models. 542 543```bash 544curl http://127.0.0.1:8080/v1/chat/completions -H "Content-Type: application/json" -d '{ 545 "model": "strata", "messages": [{"role": "user", "content": "Write a haiku about GPUs."}], "max_tokens": 512 }' 546``` 547 548```python 549from openai import OpenAI 550client = OpenAI(base_url="http://127.0.0.1:8080/v1", api_key="none") 551r = client.chat.completions.create(model="strata", messages=[{"role": "user", "content": "Hello!"}]) 552print(r.choices[0].message.content) 553``` 554 555- **Thinking levels: none, low, medium, high.** The model thinks before it answers (streamed as 556 `reasoning_content`, Anthropic: `thinking` blocks). Choose how much per request - in the chat page (the "Thinking" 557 menu), in `chat.py` (`/think low`), or over the API: 558 559 | API | how | 560 | --- | --- | 561 | OpenAI | `"reasoning_effort": "none" \| "low" \| "medium" \| "high"` (also `"reasoning": {"effort": ...}`, or `"chat_template_kwargs": {"enable_thinking": false}`) | 562 | Anthropic | `"output_config": {"effort": "low" \| "medium" \| "high"}`, `"thinking": {"type": "disabled"}`, or `"thinking": {"type": "enabled", "budget_tokens": N}` (under 2K = low, under 8K = medium, more = high) | 563 564 Without a setting the model uses its own default, **high**. `none` answers at once (fastest); `low` keeps the thinking 565 short. The levels are instructions the model was trained with, not a hard token limit: on easy questions all three 566 think briefly, on hard ones `high` thinks longest and is most accurate. 567- **A hard thinking budget (opt-in).** `"reasoning_budget_tokens": N` in a request (OpenAI or Anthropic) caps the 568 thinking at N tokens: when it gets there the server ends it with a short wrap-up line and `</think>`, and the model 569 answers from there (the engine continues from what it already holds, so nothing is read again). The wrap-up is 570 part of the thinking the client sees and counts as output tokens. `"reasoning_budget_tokens": N` in 571 `strata-<model>.json` sets it for every request; a request's own value wins, and `0` means no budget. Off by default; 572 Anthropic's `"thinking": {"budget_tokens": N}` still only chooses the level, as above. 573- **A reply stuck on one token is ended (0.1.39, #606).** When a reply repeats the same token 256 times in a row, the 574 server ends it there with `finish_reason` `"length"` and says so in its window: a model in a loop, or a broken 575 state that answers one token forever (#606 saw 36,689 tokens of `!`). `"repeat_stop_tokens": N` in 576 `strata-<model>.json` sets the run length; `0` turns it off (for a request that really wants one token many times). 577- **Repeated reasoning (opt-in, #728).** The single-token guard above does not see a model that repeats whole 578 passages. `"reasoning_loop_recovery"` in `strata-<model>.json` is `false` (the default), `"stop"` or `"recover"` 579 (`true` means `"recover"`). Every 512 output tokens, at a complete character and parser boundary, the reasoning is 580 measured over its last 2,000 words and punctuation marks (counting passages over the last 30,000 words). If at 581 least 25% belong to 12-word passages seen three times, `"stop"` ends the reply there as `"length"` and says so in 582 the server window. `"recover"` stops and drains that generation, then goes on once from all its generated token 583 ids with the template's low-effort sentence in place of the xhigh one in the first system message (a splice of 584 token ids: the rest of the prompt is not decoded or re-encoded). The task stays the same; no answer or `</think>` 585 is inserted, and both passes share the original output limit. On recovery only, temperature is raised to at least 586 1.0 and presence penalty to at least 1.5; a client's top-p, top-k and seed are never changed. `/metrics` records 587 `reasoning_recoveries` and the coverage. This is a policy, not a numerical engine fix or a guarantee of an answer. 588 `"recover"` needs the exact xhigh sentence in the first system message and skips requests with images; re-reading 589 the changed prefix costs prompt time. Either mode can mistake repeated useful code or checks for a loop, so keep 590 the recorded answer quality alongside the completion rate when testing it. 591- **Changing the effort without re-reading the prompt (opt-in, 0.1.39, #458).** The effort's instruction is the 592 first thing in the prompt, so a request that only changes the effort (an agent's "think harder" switch, `none` for 593 a quick tool step) reads the whole conversation again. `"effort_position": "end"` in `strata-<model>.json` renders 594 every request's prompt start as the default effort's and puts a `low` / `medium` effort in a short system turn 595 right before the answer (no thinking: the empty thinking block, as always); the engine (0.1.39+, which the server 596 checks) keeps its checkpoint in front of that turn, so the next request reuses the conversation whatever its 597 effort. The default (`"start"`) prompt is unchanged. The model sees a level that is not the default in another 598 place than it was trained with; how well it follows it there is not measured yet. 599- **Anthropic requests that don't ask for thinking (opt-in, 0.1.32, #278).** By default a `/v1/messages` request 600 with no `"thinking"`, effort or budget thinks as the model's template does. `"anthropic_thinking": "on_request"` in 601 `strata-<model>.json` renders such a request without thinking - Anthropic's own rule, and what Claude Code's short 602 helper calls (a session title in a few dozen tokens) need; its real turns ask for thinking when it is on there. 603- **Streaming.** With `"stream": true` everything arrives as it is made: the thinking, the answer, and tool calls 604 (the tool's name first, then its arguments piece by piece, like OpenAI and Anthropic do). While the model reads a 605 long prompt the stream sends keep-alives, so agents do not time out; the server window prints progress every 606 15 s, and `GET /status` says what it is doing (`reading the prompt`, `answering`, tokens so far). Closing the 607 connection or pressing stop in your app really stops the model, so the next request starts at once. 608- **Prefill progress in the stream (opt-in).** `"return_progress": true` puts that progress on the stream instead of 609 sending only the keep-alive, as one extra field on a chunk with an empty delta: `prompt_progress` with `total`, 610 `cache`, `processed` and `time_ms`. Those are llama.cpp's four fields and mean the same there (`time_ms` is the time 611 since the prompt started reading, and the work still to do is `(total-cache) - (processed-cache)`), so a client that 612 draws a prefill bar for llama.cpp draws one here too. It is off unless the request asks, as it is in llama.cpp. 613 The engine says one line per `--prefill` chunk, so that chunk is the step: measured on two RTX 3090s with 614 `--prefill auto` (8192 tokens), a 42,131 token prompt read in 15 s sent six of them. A prompt shorter than one chunk 615 sends nothing, and that is on purpose: its only line arrives once the prompt is read, because the last tokens go 616 through the verify windows rather than the batched path, so it stops up to `--short-read` tokens short of the end. 617- **Chat apps.** Any app with an "OpenAI-compatible" provider works: base URL `http://127.0.0.1:8080/v1`, any API key. 618- **OpenCode** (#543). A starting point for `opencode.jsonc` (in your project, or `~/.config/opencode/`); the field 619 names are OpenCode's, so check its config docs if your version differs: 620 621 ```jsonc 622 { 623 "$schema": "https://opencode.ai/config.json", 624 "provider": { 625 "strata": { 626 "npm": "@ai-sdk/openai-compatible", 627 "name": "Strata (local)", 628 "options": { "baseURL": "http://127.0.0.1:8080/v1", "apiKey": "none" }, // or your api_key 629 "models": { 630 "strata": { 631 "name": "Qwen3.8-Flash-Next (Strata)", 632 // context: what you chose in setup; output: what one reply may use (prompt + output must fit) 633 "limit": { "context": 262144, "output": 32768 }, 634 "options": { "reasoningEffort": "high" }, // sent as reasoning_effort 635 "variants": { // switch between them in OpenCode 636 "low": { "reasoningEffort": "low" }, 637 "medium": { "reasoningEffort": "medium" }, 638 "none": { "reasoningEffort": "none" } 639 } 640 } 641 } 642 } 643 }, 644 "model": "strata/strata" 645 } 646 ``` 647 648 Set `limit.context` to the context you chose in setup: OpenCode compacts the conversation before it gets there. 649 Keep `limit.output` well under it: a request whose prompt plus `max_tokens` runs past the context is refused (see 650 **Context** below), or add `"fit_max_tokens": true` to `strata-<model>.json`. For a hard cap on the thinking, add 651 `"reasoning_budget_tokens": N` to `strata-<model>.json` (see above). 652- **Claude Code** (Strata 0.1.17 or newer): set `ANTHROPIC_BASE_URL=http://127.0.0.1:8080` and 653 `ANTHROPIC_MODEL` to a Claude model name it knows (it refuses names it doesn't; Strata ignores the name), plus any 654 `ANTHROPIC_AUTH_TOKEN` (or your `api_key`, if you set one). 655- **Codex CLI** (0.1.39): see [the Responses API](#the-responses-api-and-codex-cli) below. 656- **Context.** Chosen in setup (8K-262K). Requests longer than that are refused, never silently cut. A request whose 657 `max_tokens` would run past the context is refused too (400); agents that always ask for their full output cap 658 can instead get it shortened to the room left: add `"fit_max_tokens": true` to `strata-<model>.json` (or pass 659 `--fit-max-tokens` to `serve/server.py`). A prompt that leaves no room at all is still refused. 660- **Model aliases** (0.1.32). `"aliases": ["qwen", "local-model"]` in `strata-<model>.json` lists the model under 661 those names too in `/v1/models` (each with its own `id`, and in the model's `aliases`), like llama-server's 662 `--alias`; a request naming one is answered under that name. Any other name is still served, as before. 663- **Model settings in the web page (0.1.39, #564).** The About tab's Model settings card shows and changes a few of 664 the keys above in `strata-<model>.json`: the `sampling` defaults (temperature, top_p, top_k, min_p), 665 `reasoning_budget_tokens`, `fit_max_tokens`, `anthropic_thinking`, `effort_position`, `aliases`, `idle_unload_s`, 666 `lazy_load`, `engine_silence_s`, `api_monitor`, `open_browser` and `--vram-reserve-mib`. An empty field removes the 667 key (its default). Every other key of the file stays as it is, the earlier file is kept as 668 `strata-<model>.json.bak`, and the model uses the change from its next start. Only Strata's own page can save 669 (JSON, the API key when one is set, as for the Chat settings); the network, key, MCP and program keys are not 670 editable there. 671- **From other devices on your network.** The server listens on your PC only (`127.0.0.1`) unless you say otherwise: 672 run setup with `START-HERE.bat --setup --host 0.0.0.0 --api-key some-long-secret` (or add `"host": "0.0.0.0"` and 673 `"api_key": "..."` to `strata-<model>.json`). The server window then prints this PC's addresses 674 (`from other devices: http://192.168.x.x:8080/`); open that on the other device, or use `.../v1` as an API base URL. 675 On Windows the firewall blocks it until you allow it: accept its prompt for Python (private networks), or run 676 `New-NetFirewallRule -DisplayName "Strata 8080" -Direction Inbound -Protocol TCP -LocalPort 8080 -Action Allow -Profile Private` 677 in an admin PowerShell, and make sure the network is set to Private. 678- **From the internet.** Put a tunnel in front of it, for example [cloudflared](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/do-more-with-tunnels/trycloudflare/): 679 `cloudflared tunnel --url http://127.0.0.1:8080`. **Set a key first**, or anyone with the link can use your PC: 680 add `"api_key": "some-long-secret"` to `strata-<model>.json` (or set the `STRATA_API_KEY` environment variable); 681 clients then send it as their API key. Streamed answers carry `X-Accel-Buffering: no`, so nginx-style proxies pass 682 each token on at once. The web app's settings and MCP tools only answer Strata's own page: when you open it through 683 a proxy or tunnel whose address differs, add that address, e.g. `"trusted_origins": ["https://strata.example.com"]`. 684 With the key set, any `Host` name reaches the server (see Host names below). 685- **From web apps in a browser (CORS).** Off by default. `"cors_origins": ["https://chat.example.com"]` lets pages of 686 those origins call `/v1/*` from the browser (Open WebUI's direct connections, browser extensions); `["*"]` lets any 687 page do it - only sensible with an API key. It never opens `/settings`, `/unload` or the MCP tools. 688- **Host names (DNS rebinding).** A web page of another site can point its own name at `127.0.0.1` and then reach 689 this server as if it were its own, so without an API key the server answers only requests whose `Host` is a name 690 it knows (with a key the check is off: such a page cannot send the key, and tunnels and proxies that pass their 691 own name on keep working): 692 `localhost` (and `*.localhost`), any IP address (`127.0.0.1`, `[::1]`, `192.168.x.x`, ...), the address it 693 listens on and, when it listens beyond this PC (`0.0.0.0` or a LAN address), this PC's name (`mypc`, `mypc.local`) 694 and `host.docker.internal`; any port. Others get **403** naming the setting, and the server window prints one line 695 for each. Reach it under another name (a reverse proxy that keeps the name, a tunnel, a DNS name on your network, 696 another container's name for it)? Add the name: `"allowed_hosts": ["strata.example.com"]` in 697 `strata-<model>.json` or `STRATA_ALLOWED_HOSTS=strata.example.com` (comma-separated); `".example.com"` allows that 698 name and every name below it, and `["*"]` turns the check off (so does setting `api_key`). The hosts of 699 `trusted_origins` count as allowed. Requests without a `Host` header (HTTP/1.0 clients) pass. 700- **Web pages without an API key.** Without `api_key`, a `POST` to `/v1/*` that carries an `Origin` header (a 701 browser page sent it) is answered only for Strata's own page, pages on `localhost` or an allowed host name (any 702 port), the origins in `trusted_origins` or `cors_origins`, and browser extensions and desktop apps 703 (`chrome-extension://`, `moz-extension://`, `app://`: no web site can send those), and only with a JSON body; any 704 other page, and `Origin: null`, gets **403**. Clients that send no `Origin` (curl, the OpenAI and Anthropic SDKs, 705 other servers) are not affected. With 706 an API key, the key decides. `POST /unload` and `POST /load` take `Content-Type: application/json` from Strata's 707 own page (or no `Origin`), like `/settings`. `POST /slots/0?action=save|restore` keeps the Host and API-key checks 708 and also takes only JSON from no `Origin`, Strata's own page or a trusted origin - also when an API key is set. 709 710**Conversation cache.** A request that continues a chat reads only the part after what the engine already holds: the 711live session, or one of the checkpoints it keeps in RAM (up to 6, ~118 MB each, taken at the start of each new 712assistant turn and every 16K prompt tokens). A checkpoint is used only when the prompt starts with exactly its tokens 713and pictures. The oldest checkpoint - in practice the end of the system prompt, which every chat of the same client 714shares - is kept for good while the rest rotates by least recent use, so a NEW chat that shares that prefix starts 715reading after it instead of from token 0. A prompt read from the start is also checkpointed at the end of its system 716prompt when that is 2,048 tokens or more (engine 0.1.20; PR #62 + #65), so that root exists for agent clients with long 717system prompts and tool lists. Claude Code stamps its system prompt with a billing header that changes on every 718request (`cch=...`) and every session (the 4th part of `cc_version=`); the server pins both stamps (to `f`s, as 719llama.cpp does), so the system prompt and the tool list in front of it are the same prompt on every turn. Engine options: `--prompt-cache N` (0 = off), `--prompt-cache-every N`, 720`--prompt-cache-root N` (0 = no system-prompt checkpoint), `--turn-token ID`. 721A one-shot request that no later request continues (a classification call, a probe) can send 722`"strata_checkpoint": false` in its body: it saves no checkpoint at its last turn nor every 16K tokens, so what 723follows the reused prefix (or the root) is read in one run, and its session is not kept or parked for a next request. 724It still starts from a checkpoint it matches, and still saves the system-prompt root when that reaches 725`--prompt-cache-root`. Without the field (or with `true`) nothing changes. 726 727**Multiple conversations (opt-in).** Add `--conversation-cache-mib 8192 728--conversation-cache-slots 4` to the engine arguments to park up to four conversations 729in a bounded 8 GiB host-RAM cache. This preserves controller/worker histories when 730their requests alternate; it does not execute requests concurrently. No client session 731ID is required: only exact token/image prefixes with matching steering mode are reused. 732The default budget is 0 (disabled); `--prompt-cache 0` also disables parking. 733With `--layer-split`, a parked conversation holds one image per stage (each later stage's 734session and its share of the conversation checkpoints), every image is validated before 735anything is overwritten, and each is restored on its own GPU. Verified on a 4-GPU split: 736a 9,276-token conversation restored in 51 ms, and its follow-up decodes exactly the tokens 737it decodes when the conversation never left (`tools/parking_test.py`). FP16, 738INT8, Q4_0 and identity-layout K8V4 snapshots are supported; the K8V4 draft ring 739remains INT8, as in upstream. Windows/HIP and multi-GPU runtime coverage must be 740reported separately from Linux/CUDA evidence. 741 742The web page's Monitor tab has a **Conversation cache** card (0.1.39, #596): the parked conversations against the 743slots and the RAM budget, how many were parked, restored and evicted, and the last switch (read from the engine's 744log), and for every setup how many prompt tokens the cache gave back - in the last request and since the start. 745`/metrics` has the same under `"conversation_cache"`. 746 747Snapshots contain running state, checkpoints, used K/V pages, and draft-layer K/V. 748They add host RAM, not another model or VRAM allocation. The byte budget also counts 749an incoming snapshot during a switch. After a restore, unchanged K/V pages can be 750retained for the next parking operation; growth appends storage without copying 751the existing pages. Rewinds refresh the affected pages, and running state and 752checkpoints are captured again. Retained active K/V counts against the same byte 753budget and is discarded before evicting parked entries under memory pressure. 754If reserving space for growth would evict another conversation, parking uses a 755full capture instead. 756Oldest parked entries are evicted first. 757Oversized snapshots or host allocation failures fall back to ordinary prompt processing. 758`--conversation-cache-min-free-mib N` (default 2560) additionally requires that 759physical-RAM headroom remain available: the engine checks before allocation and 760again after capture. Unknown telemetry or insufficient RAM skips parking. Windows 761uses `GlobalMemoryStatusEx`, Linux uses `MemAvailable`; these are host-level samples, 762not a reservation or enforcement of container/job memory limits. An 8 GiB budget 763is a cap, not a recommendation for every machine. 764 765The shared snapshot core validates all layers and checkpoints before applying any 766state. Invalid entries are discarded; transfer/synchronization failure is fatal 767rather than permission to continue with partial state. Indexer spare keys and the 768moving spare row are preserved, including checkpoint rewinds. 769The engine log reports parking, restoration, bytes, evictions, individual snapshot 770sizes and K/V bytes reused during capture. `STRATA_SNAPSHOT_FULL_CAPTURE=1` disables 771retention for diagnostic comparisons. Parked snapshots are not 772persisted across restarts; the session files below are. 773 774**Session files (disk).** The conversation the engine holds can be saved to a file and restored later, also after a 775restart of the same engine version, so a long prompt is not read again. The server exposes the save and restore 776requests of llama-server's slot API, for its single slot 0, when started with `--slot-save-path DIR` (also 777`"slot_save_path"` in the config); NAME must be a plain file name inside DIR. There is no erase action and the file 778format is Strata's own, not llama.cpp's: 779 780```bash 781curl -X POST "http://127.0.0.1:8080/slots/0?action=save" -H "Content-Type: application/json" -d '{"filename": "chat1.bin"}' 782# {"id_slot": 0, "filename": "chat1.bin", "n_saved": 63025, "n_written": 1198691396, "timings": {"save_ms": 709.5}} 783curl -X POST "http://127.0.0.1:8080/slots/0?action=restore" -H "Content-Type: application/json" -d '{"filename": "chat1.bin"}' 784# {"id_slot": 0, "filename": "chat1.bin", "n_restored": 63025, "n_read": 1198691396, "timings": {"restore_ms": 898.2}} 785``` 786 787DIR becomes one absolute path at start (`--slot-save-path` relative to the server's working directory, the config's 788`slot_save_path` relative to the config's `"cwd"`), created with mode 0700 when missing. It should be private to the 789user that runs Strata: the files hold the conversation's token IDs and state, are created with mode 0600 on Linux 790(on Windows they inherit the folder's permissions), and nothing deletes them - about 1.2 GB per 63K-token 791conversation. Before it writes, a save checks that the disk has room for the whole new file plus 792`--session-min-free-mib` (an engine argument, in the config's `args`; default 4096, 0 = no check) - also when it 793replaces a file, whose space comes back only after the rename. This is a preflight, not a quota or a reservation. 794NAME may 795not contain a path, a drive, a stream (`:`), a Windows device name (`NUL`, `CON.bin`, `COM1`...), a control character, 796a leading dot or a trailing dot or space. 797 798The request must be `Content-Type: application/json` (else `415`) and come from no browser page, Strata's own or a 799trusted origin (another site's `Origin` gets `403`, also with an API key); the Host and API-key checks apply as 800everywhere. Errors: `501` without `--slot-save-path` or with parallel requests; `400` for a slot other than 0, an unknown action, a refused 801file name, or a file the engine refuses as invalid (not a session file, corrupt, another model or configuration, over 802this session's limits; the session is as it was); `404` for a restore of a missing file; `503` while the model is not 803loaded, when the RAM to read the file is not there or an allocation failed; `507` when the disk has no room (the 804free-space reserve, or the OS reports no space or quota); `500` for any other I/O failure (permissions, read, write, 805flush, rename) and when the engine ended (a restore transfer failure, below, an engine that said nothing for 806`engine_silence_s`, or one that answered out of protocol) - the next request starts it again. The status follows the 807engine's category (`error.kind`: `invalid`, `memory`, `storage`, `io`), never the words of the message. A save that 808failed after its new file had replaced the old one says so with `error.published: true` (below). A save or restore waits for the running request 809(the same queue), shows in `/status` and counts as activity for the idle unload. A later request whose messages 810continue the restored conversation reuses the restored state or its checkpoint; a short tail may be read again (35 811tokens in the measurement below). Only the deepest checkpoint is saved, so an edit further back reads more again. 812Clients still send their messages (and images): the file holds engine state and token/image identity, not a chat 813export. Underneath, `strata --serve` takes `SAVE <path>` and `RESTORE <path>` on stdin between requests and answers 814`SAVED <tokens> <bytes> <ms>`, `RESTORED <tokens> <bytes> <ms>`, `SERR <kind> <published 0|1> <reason>` (failed, 815the engine and the session as they were) or `FATAL <reason>` (then exits). On the way, `SESSION <done> <total>` follows 816every block of the file that moved (at most 16 MiB, the last partial block and a small file included), and 817`SWAIT <phase> <seconds>` comes before a step that blocks in one call (`fingerprint`, `capture`, `flush`, `publish`, 818`validate`, `transfer`): that step is allowed those seconds - 60 plus one per 4 MiB it concerns, at most 3600 - by the 819engine's watchdog and by the server, then it counts as stuck. The next line clears the allowance. The server checks 820every line: a malformed or unknown one, counts that are negative or go back, an allowance outside 1..3600 or a time 821that is not a finite number end the engine as out of step. 822 823One file holds the running state, the deepest checkpoint, every QSA layer's K/V up to the conversation's length and 824the draft layer's K/V. Format v1, little-endian, fixed-width integers, IEEE-754 floats (a big-endian build does not 825compile): a 64-byte header (magic `STRSESS\x01`, version u32, header size u32, model fingerprint u64, config 826fingerprint u64, payload length u64, two reserved u64 that must be 0, a hash of the first 56 bytes), the payload 827(geometry, layer range, cvec flag, the live state, the checkpoints, the K/V layers; every array preceded by its u64 828count), the payload hash and the end marker `STRSEND\x01`. The hash is a 64-bit function with xxHash64-style rounds, 829not the standard XXH64 stream; it detects accidental corruption and does not authenticate a file: restore only files 830this engine wrote. An unknown version is refused; a new format gets a new version number. 831 832A file is bound to the model inputs and to the settings that change what the saved bytes mean. The model fingerprint 833samples (size, first and last MiB) every file the engine loads, by its role: the GGUF shards (also 834`--native-dense-gguf`, the head shards and `--embd-gguf`), the PLE shard, the pack's index/dense/embedding files and 835`native_experts.txt`, every file the expert source resolved - the pack's `experts.bin`, or for a pack read in place each 836layer's gate/up/down GGUF as `native_experts.txt` names it, also one outside the CLI shards - and the MTP's files; not 837other files in those folders, and not the path, so a moved model folder still matches. A 838change in the middle of a file that keeps its size is not seen: do not change model files while their sessions are 839kept. The config fingerprint covers the engine version string (another version is refused; two builds of the same version 840are not told apart - there is no build hash), CUDA or HIP, 841`--kv`, `STRATA_KV_ROT`, `--kv-resident`, `--max-context`, `--mtp-window`, the resolved rope configuration (type, 842base, factor, freq scale, original context, the YaRN knobs - the cached K is post-RoPE), the loaded control vector (a 843digest of the tables uploaded: every file's content times its exact scale, the mode, the layer range and the 844direction) and the arithmetic switches (`--native-*`, `--no-ple`, the A/B arms). Sampling, seeds, draft tuning and 845the expert tier are not in it: they change what comes next, not what the saved cells hold. 846 847A save writes a temporary file with a new hidden name beside `path` (created exclusively, never an existing file or 848link), flushes it to the disk, renames it over `path` (`MoveFileExW` with write-through on Windows, which promises no transaction 849on every filesystem) and, on POSIX, flushes the folder (Windows has no folder flush; the file flush and the 850write-through rename are all it does). A save that fails before the rename keeps the old file at `path` and removes 851only its own temporary file. Once the rename is done the old file is gone: if the folder flush then fails, the save 852fails with `published` set - the new file's bytes are complete and flushed, but its name may not survive a power loss. 853A filesystem that cannot flush a folder (`EINVAL`) is not a failure; the engine logs it. A restore opens `path` without following a symbolic link (or a Windows reparse point) and refuses 854anything but a regular file with one name; it checks the size, the header, both fingerprints (before the payload is 855parsed; the first 16 MiB block, header included, is already read), that the parse's peak (the image, the read buffer, the per-segment overhead) fits in RAM above the parking 856floor (`--conversation-cache-min-free-mib`), the file's size against the largest this session can restore, the 857geometry and layer range before any state array, and every count against the bytes left and this session's exact 858limits (context and cells, checkpoints, layers, each running-state array, each K/V part) before allocating it, the payload hash 859and then the usual snapshot validation - all before any device write, and a refusal leaves the current session as it 860was. A transfer failure after the device writes began ends the engine (`FATAL`) rather than decode from a partial 861state; the server reports `500` and starts it again. A restore does not park the outgoing session. Not supported with 862`--layer-split`, `--peer-device`, `--batch` (the config's `"parallel"`, #465; the server answers `501`) or 863`--prompt-cache 0` (the RAM conversation cache need not be on). On Linux the file 864moves with `O_DIRECT` in 16 MiB blocks when the filesystem takes it (buffered I/O otherwise, or with 865`STRATA_SESSION_BUFFERED=1`); on Windows with buffered I/O. The engine has been run on Linux/CUDA only. An earlier 866revision's CPU file-I/O test passed as a 32-bit Windows executable under Wine; the current code has not been built 867for Windows, and the Windows engine, HIP and AMD cards have not been run. 868 869A session file saves conversation state, not all of the process's execution history. Exact future token replay 870across restarts is not guaranteed: expert residency and CPU/GPU rounding can change later output. In a 63K test the 871first 32-token continuation after a restore matched the process that kept running; on the next continuation three 872restored processes agreed with one another but differed from that process from the 28th token on. A refused, 873corrupted restore in between did not change the restored processes' continuation. The cause of this divergence has 874not been isolated. 875 876Measured on an RTX 4070 Ti (12 GB), Ryzen 9 5900X, 64 GB RAM, NVMe ext4, IQ3_XXS, a 63,025-token conversation 877(engine 0.1.38 with this change, binary sha256 `3bbe4fc3...`): file 1.20 GB, save 0.65 s including the flushes to 878disk (10 more saves of the 1.20 GB state after a further turn: 0.59-0.61 s replacing one file, 0.80-1.18 s to new 879names), restore 1.05 s in a new engine process, then the next 32-token turn in 1.14 s with the same 32 output tokens as 880the same turn without a restart (1.00 s); the cold first turn takes 25.5 s. The save reported 73 `SESSION` lines, never 881more than 16 MiB apart. A symbolic link, a second hard link and a file with one flipped payload byte were refused 882(the last also while a restored conversation was live, which then went on to answer); a fresh engine with another 883`--rope-freq-base` refused the file and then answered; a save with a RAM floor above the machine's RAM was refused as 884`memory` before any copy, the file it would have replaced untouched. The times are single runs. 885 886**Current limits (v1):** one request at a time unless `"parallel": N` is set (opt-in batch slots, up to N requests 887decoded together: [BATCHING.md](BATCHING.md)), and one conversation cached at a time (switching between two chats 888re-reads the other one unless the opt-in cache above is enabled, or each conversation keeps its own batch slot); images only when set up with them (below); no video. **Temperature / top_p / top_k / min_p / 889seed** are honored per request (OpenAI and Anthropic fields), and so are stop strings (OpenAI `stop`, a string or up 890to 4; Anthropic `stop_sequences`): the answer ends before the first one, which is not sent, and the engine stops 891there (`finish_reason` "stop"; `stop_reason` "stop_sequence" with `stop_sequence` set to the one found); with the default adaptive expert tier a sampled result 892is not reproducible run to run - for seed-reproducible output add `--adapt-every 100000` (static residency) to the 893engine arguments. The run config's optional `sampling` block sets the defaults for requests that leave the fields out 894(`"sampling": {"temperature": 1.0, "top_p": 0.95, "top_k": 20}`); a request's own fields always win, and with no 895block at all a request without sampling keys decodes greedy. The penalties (`presence_penalty`, `frequency_penalty`, 896`repetition_penalty`, with `penalty_last_n` capping how many recent tokens they count over, default 64 when any 897penalty is set) ride the same path; they count the tokens the request has consumed, so a repetition penalty 898suppresses what the model itself just said, not the prompt alone. Since engine 0.1.19 they apply to every token 899the speculative decoding checks at once, exactly as if it decoded one token at a time (before, only the first of 900each batch got them). That makes requests with penalties 1-11% slower than in 0.1.18: the draft layer guesses 901without penalties, so more of its guesses are now rejected. Requests without penalties are unchanged. `top_k` keeps at most 64 candidates: `0` ("off") or anything above 64 uses all 64. 902 903--- 904 905### The Responses API and Codex CLI 906 907`POST /v1/responses` (0.1.39, #451) speaks OpenAI's newer Responses API, which Codex CLI uses (it no longer 908speaks Chat Completions). It runs on the same path as `/v1/chat/completions`, so the thinking levels, the thinking 909budget, the conversation cache and the same API key, Host and Origin checks apply. 910 911It is **stateless**: nothing is stored, so the client sends the whole conversation in `input` every time (Codex does, 912with `store: false`). `previous_response_id`, `conversation`, `background` and the retrieve/delete/cancel endpoints 913are refused with an error that says so. 914 915| Request | What Strata does | 916| --- | --- | 917| `input` as a string, or as items | `message` items (`user`, `assistant`, `system`, `developer`; text and images), `reasoning`, `function_call`, `function_call_output`, `custom_tool_call(_output)` | 918| `instructions` | The system message (with leading `developer` messages; later ones become user messages, as on the chat path) | 919| `tools` | `function` tools, `namespace` tools (the model sees `namespace.name`; calls come back with `namespace` and `name`), `custom` tools (one free-form `input` string). Hosted tools (`web_search`, `file_search`, ...) are left out: the model cannot run them | 920| `tool_choice` | `"none"` hides the tools; anything else lets the model choose (it cannot be forced) | 921| `reasoning.effort` | `none`/`minimal`, `low`, `medium`, `high`/`xhigh`; without it the model's default (high) | 922| `max_output_tokens` | The output cap (thinking included). Running out ends the response `incomplete` (`max_output_tokens`) | 923| `text.format` | `json_schema` and `json_object` use the [JSON response formats](#json-response-formats) (checked, not constrained) | 924| `temperature`, `top_p`, `reasoning_budget_tokens`, ... | As on the chat path | 925 926The model's thinking comes back as a `reasoning` output item with `reasoning_text` content (streamed as 927`response.reasoning_text.delta`). This model writes no separate summaries, so `summary` is empty. With 928`"include": ["reasoning.encrypted_content"]` the item also carries `encrypted_content`: an opaque string (base64, not 929encrypted; the client already holds the text). Send the reasoning items back with the rest of the conversation, as 930Codex does: their thinking goes back into the prompt, so it matches what the model wrote and the conversation cache 931is reused. 932 933With `"stream": true` the events are the official ones, in order: `response.created`, `response.in_progress`, then 934for each output item `response.output_item.added`, its deltas (`response.reasoning_text.delta`, 935`response.output_text.delta`, `response.function_call_arguments.delta`), its `...done` events and 936`response.output_item.done`, and at the end `response.completed`, `response.incomplete` or `response.failed`. 937While a long prompt is read, a `response.in_progress` event goes out every 15 s, which Codex counts as activity. 938Errors before the answer starts have the Responses form (`{"error": {"message", "type", "param", "code"}}`); after 939it started they arrive as `response.failed`. 940 941**Codex CLI.** In `~/.codex/config.toml` (Windows: `%USERPROFILE%\.codex\config.toml`): 942 943```toml 944model = "strata" # any name; Strata answers with its model 945model_provider = "strata" 946model_context_window = 32768 # the context you chose in setup: Codex compacts before it gets there 947show_raw_agent_reasoning = true # show the model's thinking (it writes no summaries) 948# model_reasoning_effort = "medium" # none, low, medium or high; default: the model's (high) 949 950[model_providers.strata] 951name = "Strata (local)" 952base_url = "http://127.0.0.1:8080/v1" 953wire_api = "responses" 954stream_idle_timeout_ms = 600000 # a first, long prompt can take minutes to read 955# env_key = "STRATA_API_KEY" # only if the server has an api_key: the variable holding it 956``` 957 958Then run `codex` (or `codex exec "..."`) as usual. Codex warns `Model metadata for ... not found` for a local model 959name; that is expected. Measured with Codex CLI 0.160.0 and Q2_0 on an RTX 5070: its first prompt (instructions and 960tool descriptions) was 9,443 tokens, read in 10 s; in a tool loop, each later turn reused about 96% of the prompt from 961the cache and read only the new part in 1-2 s. On Windows, Codex's sandbox rejected every shell command in that test 962until it was started with `-c 'windows.sandbox="unelevated"'` (a Codex setting, not Strata's). 963 964## Tools from MCP servers 965 966The chat page can give the model tools from [MCP](https://modelcontextprotocol.io) servers, as LM Studio and Claude 967Desktop do: reading your files, fetching web pages, searching, anything an MCP server offers. List the servers in 968`strata-<model>.json` under `"mcp_servers"` - the same shape as Claude Desktop's `mcpServers` block, which you can 969also paste as it is (key `"mcpServers"`): 970 971```json 972"mcp_servers": { 973 "files": {"command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "C:\\Users\\me\\Documents\\notes"]}, 974 "search": {"url": "http://127.0.0.1:3000/mcp", "headers": {"Authorization": "Bearer ..."}} 975}, 976"mcp": {"timeout_s": 60, "max_result_chars": 20000, "max_rounds": 8} 977``` 978 979Or keep them in their own file and start the server with `--mcp-config path\to\claude_desktop_config.json` (a file 980with an `mcpServers` block; add it to the `serve/server.py` line of your run script). Restart Strata after a change. 981 982- **A program** (`command`, `args`, optional `env` and `cwd`) is started by Strata and spoken to over its 983 stdin/stdout; `npx`, `uvx`, `python` and friends are found on `PATH` as usual (Node.js is needed for `npx` 984 servers). **An address** (`url`, optional `headers`) uses MCP's Streamable HTTP transport (the older SSE-only 985 transport is not supported). `"disabled": true` leaves an entry out. 986- The servers start with Strata, in the background; the server window says what each one offers 987 (`MCP server 'files': 14 tools (...)`), or why it did not start - its tools are then left out and the chat works 988 without them. The Monitor tab lists them, and the Sampling drawer has **Use tools from MCP servers** (on by 989 default). A server that stops later is started again at its next call. 990- In the chat each call shows as a small block (tool, arguments, result); the model reads the result and goes on, 991 up to `max_rounds` calls in a row per answer. A tool that fails or takes longer than `timeout_s` (default 60 s) 992 gives the model an `error: ...` result instead of ending the chat. Results longer than `max_result_chars` 993 (default 20,000 characters) are cut, with a note, before the model reads them. Stop stops a running tool too. 994- Only the chat page uses them. API clients (omp, Claude Code, OpenAI and Anthropic SDKs) see the API exactly as 995 before and keep their own tools; a request to `/v1/chat/completions` opts in with `"strata_mcp": true` (it then 996 gets `strata_mcp` tool events in the stream). 997 998**Security.** MCP tools run on your PC with your user's rights, and **the model decides when to call them** - also 999because of what it reads (a web page or a file can contain instructions). Give a filesystem server only the folders 1000it needs, prefer read-only tools, and don't add servers you don't trust. The tools can only be used from the chat 1001page itself (a request with another site's Origin or without a JSON content type is refused); if Strata is reachable 1002from other devices, set an API key. 1003 1004**Context extension past 262K (rope scaling, EXPERIMENTAL, off unless you pick it).** The model was trained on 1005262,144 positions (rotary base 1e7). Rope scaling rescales the rotation angles so that longer contexts stay usable, 1006with llama.cpp's types and flag names. `linear` is Position Interpolation: every angle is shrunk by the factor. 1007`yarn` keeps the high-frequency angles, interpolates the low-frequency ones, and adds the magnitude correction 1008that keeps the attention temperature where training put it. **Without the flags nothing changes:** an unscaled 1009run computes exactly what it did before the feature existed, bit for bit. Scaled contexts need proportionally 1010more VRAM/RAM for the KV cache and the rope tables (~13 KB and ~0.26 KB per token). 1011 1012What was measured (contributors' runs, RTX 5080 + IQ3_S, native path, in PR #84): per-position perplexity on the 1013same tokens, with only the scaling flag changed. At 293K tokens (1.12x the trained length), `yarn` with factor 2 1014lowered the NLL by 0.18 nats against both `none` and `linear` 2 (2.04 vs 2.22 / 2.22). That is 3-4x the path noise 1015measured at the same length. `linear` 2 was indistinguishable from `none`. At 2.7K and 32K no arm separated from the 1016noise. Needle tests do not tell the arms apart: the unscaled model also finds a needle at 413K. Long real-document 1017Q&A worked with `yarn` 2 at 421K and `yarn` 4 at 714K (8/8 each), and a 1M-token `yarn` 4 run read end to end. 1018Taken together, use **yarn**. It is still experimental: the numbers come from one machine and one quant. 1019 1020- setup: `START-HERE.bat --setup --context 393216` asks nothing extra - it picks the method (yarn; one 1021 question when run interactively) and derives the factor from the final context for you (final context / 1022 262,144, at least 1: 1.5 at 393K, 2 at 512K, 1 inside the trained range; `--rope-scaling`/`--rope-scale` 1023 override; an explicit `--rope-scale` is kept as given even when it is too small for the context actually 1024 served, so check it if you set one). An explicit `--rope-scaling none` for a context past 1025 262,144 is refused: the setup will not configure a run with the stock angles past the trained range. If 1026 the RAM check reduces a chosen 384K/512K back inside the trained range, an omitted method adds no 1027 scaling, and an explicitly chosen one stays at factor 1 - the trained angles, no expansion (not a 1028 switch for rope as a whole: explicitly supplied rope settings keep their behavior). 1029- engine: `--rope-scaling none|linear|yarn`, `--rope-scale F`, and the raw ggml knobs `--rope-freq-base`, 1030 `--rope-freq-scale`, `--yarn-orig-ctx` (default 262,144), `--yarn-ext-factor`, `--yarn-attn-factor`, 1031 `--yarn-beta-fast` (32), `--yarn-beta-slow` (1). The model file's `rope.scaling.*` keys, when a 1032 fine-tune ships them, are the defaults the flags override. 1033 1034The scaling is fixed for the whole run - the engine stores keys in its cache after rotating them, so one 1035cache must never mix two scalings, and there is no per-request form. Within the trained 262,144 a scaled 1036run is a slightly different model: the rescaled angles, and `yarn`'s magnitude correction, apply at every 1037position, not only past the trained end. That is why the setup turns scaling on only for a context past 1038262,144. Pictures read the same scaled table (their (t, h, w) positions feed it). That should work, but it is 1039unmeasured: all the runs above are text. 1040 1041--- 1042 1043## Manage Strata from your AI assistant (MCP server) 1044 1045`tools/strata_mcp.py` is an MCP server for Claude Code, Claude Desktop, Cursor, VS Code, Codex and other assistants. 1046Once it is added, you can ask your assistant "install Strata for this PC", "start Strata" or "is Strata running?". 1047In Claude Code, add it with: 1048 1049```bash 1050claude mcp add strata -- python C:\Users\you\Strata\tools\strata_mcp.py 1051``` 1052 1053It has eight tools: status (the running model, what is installed, the hardware, a recommended size), the model 1054list, install, start, stop, logs, a speed test, and connection settings for other apps. 1055 1056Install runs `setup.py` with `--yes` in the background. Before it downloads anything, it shows the plan and waits 1057for your OK. Start and stop work like the run scripts and the server's own unload. The MCP server only ends 1058processes it started itself. It uses only Python's standard library, so it works before `.venv` exists. 1059 1060The config snippets for every client, the tool arguments and the safety rules are in 1061[docs/MCP_SERVER.md](MCP_SERVER.md). This is the opposite direction from 1062[Tools from MCP servers](#tools-from-mcp-servers) above, where the Strata model calls *your* MCP tools. 1063 1064--- 1065 1066## Images (vision) 1067 1068The model has a vision encoder: [`mmproj-Qwen3.8-Flash-Next-BF16.gguf`](https://huggingface.co/ISTA-DASLab/Qwen3.8-Flash-Next-GSQ-RCO-GGUF) 1069(0.9 GB, a 27-layer ViT plus the projector into the language model). It is **optional**: say yes when the setup asks 1070"Images?", or run it again with `--vision gpu` (or `--vision cpu`). The setup downloads the encoder, builds a small 1071helper (`strata-vision`, from llama.cpp's `mtmd` library) and adds it to your start script. Nothing else changes. 1072 1073| Encoder on | Time per picture | Cost | 1074| --- | --- | --- | 1075| **GPU** (recommended) | **0.1-0.5 s** (up to 1,024 image tokens) | ~1.4 GB of VRAM is kept free for it, so the expert cache is smaller: text output is a few % slower (table below) | 1076| CPU | about 3 s at 300 image tokens on 8 cores (6-13 s on 4 threads); more tokens take longer, in proportion (#767, #625) | nothing on the GPU | 1077 1078A picture becomes up to 1,024 tokens of the context (a 640x480 photo: 300). The same picture sent again, as chat apps 1079do on every turn, is encoded only once. 1080 1081**More image tokens (0.1.39, #625):** `--vision-tokens N` at setup (`START-HERE.bat --setup --vision cpu 1082--vision-tokens 768`) sets the most tokens a picture becomes - `"max_tokens"` in the `"vision"` section of 1083`strata-<model>.json`, which you can also edit by hand. More tokens keep more detail (small text, charts, screenshots) 1084and take longer to encode, on the CPU most of all; a setup run again keeps the value. 1085 1086**A minimum number of image tokens (0.1.40, #767):** `"min_tokens": N` in the `"vision"` section of 1087`strata-<model>.json` (edit it by hand; a setup run again keeps it) is passed to the encoder as `--min-tokens N` 1088(mtmd's `image_min_tokens`): a small picture is scaled up to at least N tokens. llama.cpp's mtmd prints that Qwen-VL 1089models want at least 1,024 for grounding tasks (pointing, counting small items); the CPU default stays at 300 at most 1090and no minimum, because a larger minimum changes the image answers and costs encode time (about 3 s at 300 tokens on 10918 cores, in proportion to the tokens). 1092 1093**A Q8_0 encoder (#625):** `"mmproj"` in the `"vision"` section can point to another mmproj file of this model, for 1094example a Q8_0 one (llama.cpp's `convert_hf_to_gguf.py --mmproj --outtype q8_0` makes one): the encoder's library 1095reads quantized weights, the file is smaller (590 MiB against 865 MiB for the BF16 one, from `llama-quantize 1096mmproj-Qwen3.8-Flash-Next-BF16.gguf mmproj-Qwen3.8-Flash-Next-Q8_0.gguf Q8_0`), and on the CPU it uses less RAM 1097(about 280 MiB less in the encoder) and can encode faster than BF16 at the default 300 tokens. Setup downloads the 1098BF16 file, and a setup run again keeps a file of your own that still exists. **Recommended for `--vision cpu`.** 1099Accuracy against BF16, per image token: the cosine of the embeddings is 0.997-0.999 on average (#625's report, with 1100a community Q8_0 file, at 300, 768 and 1,024 tokens), and 0.9988 and 0.9987 on two pictures with the file made by 1101the command above (300 tokens; the worst single token 0.94-0.96). Encode time above 768 tokens is the same as BF16's 1102within about 3%. Numbers on more pictures (charts, small text) are welcome in #625. 1103 1104**A spare GPU for the encoder (0.1.33, #408):** with a card the engine doesn't use, add `"cuda_device": 2` (numbered 1105like `nvidia-smi`) to the `"vision"` section of `strata-<model>.json`: the encoder then runs on that card alone. Lower 1106`--vram-reserve-mib` in `"args"` to 700 as well, so the engine's cards keep that VRAM for the expert cache. The 1107encoder's card needs code in the ready-made encoder (RTX 20/30/40/50). 1108 1109### Sending a picture 1110 1111**Terminal chat:** type `/image <path to a picture>`, press Enter, then type your question. 1112 1113``` 1114you> /image C:\Users\me\Pictures\receipt.jpg 1115(picture attached: receipt.jpg - now type your question) 1116you> What is the total on this receipt? 1117``` 1118 1119**OpenAI API** (an `image_url` part: a `data:` URL, an `http(s)://` URL or a local file path): 1120 1121```python 1122import base64 1123from openai import OpenAI 1124client = OpenAI(base_url="http://127.0.0.1:8080/v1", api_key="none") 1125img = base64.b64encode(open("photo.jpg", "rb").read()).decode() 1126r = client.chat.completions.create(model="strata", messages=[{"role": "user", "content": [ 1127 {"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{img}"}}, 1128 {"type": "text", "text": "What is in this picture?"}]}]) 1129print(r.choices[0].message.content) 1130``` 1131 1132**Anthropic API:** an `image` block with a `base64` (or `url`) source, as usual. 1133 1134JPEG, PNG, BMP, GIF, WebP, TIFF and AVIF work (the last ones are converted to PNG first; agents such as omp send 1135WebP). Chat apps with image upload work the same way. 1136 1137### Speed with images on (4K context, measured) 1138 1139| Model | Prompt tok/s, images off | Prompt tok/s, images on | Output tok/s, images off | Output tok/s, images on | 1140| --- | ---: | ---: | ---: | ---: | 1141| **Q2_0** | 541 | 531 | 90.7 | 86.9 | 1142| **IQ2_XS** | 468 | 458 | 77.1 | 74.0 | 1143| **IQ3_XXS** | 411 | 401 | 64.7 | 59.5 | 1144 1145"Off" is the published setup; "on" runs with the encoder loaded on the GPU and its VRAM kept free, so ~1,000 fewer 1146experts fit in VRAM and the CPU computes a few more per token: 2-8% slower. For text, turning images on changes 1147nothing else (the output is bit-identical when the VRAM is the same). 1148 1149A question about a picture (a 640x480 newspaper page = 300 image tokens, a 328-token prompt; the whole request, encoder 1150on the GPU, measured through the API): 1151 1152| Model | Answer ("MEN WALK ON MOON") | Picture encoded | Prompt | Output | 1153| --- | ---: | ---: | ---: | ---: | 1154| **Q2_0** | 1.9 s | ~0.1 s | 207 tok/s | 65-73 tok/s | 1155| **IQ2_XS** | 2.3 s | ~0.1 s | 173 tok/s | 50-60 tok/s | 1156| **IQ3_XXS** | 2.7 s | ~0.1 s | 144 tok/s | 41-50 tok/s | 1157 1158(Short prompts run below the 4K prompt speed: a 2,048-token chunk is where the prompt path is efficient. Short answers 1159run below the long-output speed: the first rounds have no draft yet.) 1160 1161**How it works inside:** the encoder turns the picture into rows of the same width as the model's word embeddings; 1162Strata puts them where the prompt has `<|image_pad|>` tokens and gives each one its 2-D position (row and column in the 1163picture; the model uses interleaved M-RoPE). Answers match llama.cpp's multimodal implementation token for token on our 1164test images. 1165 1166--- 1167 1168## Experimental speed projection (EXPERIMENTAL, off by default) 1169 1170**This is an experiment, not a finished feature.** It ships with Strata but stays off unless you turn it on. 1171 1172A 480 KB control vector for Qwen3.8-Flash-Next (`data/experimental-speed-projection/`, see its README). After each 1173of layers 4-44 the engine removes one direction from every hyper-connection stream of the residual: `h -= (h . v) v`, 1174one unit vector `v` per layer, exactly as llama.cpp does with the package's `--cvec-mode project` patches. 1175 1176**What it changes.** The vector's own package describes it as a **refusal-direction projection**: with it the model 1177declines far fewer requests (it reports 1 of 50 vs 50 of 50 on its test set), and removing refusals removes a safety 1178behaviour - you are responsible for what the model writes with it on. It also shifts ordinary answers a little 1179(measured below). It is not an optimization in the engine: on the same text it costs 0.2-0.4% per token. What a 1180chat's tokens/s does with it on depends on the text the model writes (length, repetition, how well the drafts land), 1181so measure it on your own prompts; the Monitor marks every request ESP or stock. 1182 1183**Turning it on (at setup).** `START-HERE.bat --setup` asks "Turn on the experimental speed projection?" (default: 1184no), or pass `--experimental-speed-projection on` (`off`, or a path to another vector GGUF). Only for the original 1185Qwen3.8-Flash-Next, not Swift 1.5. It writes these engine flags (llama.cpp's) into `strata-<model>.json`: 1186 1187``` 1188--control-vector-scaled <Strata>\data\experimental-speed-projection\Qwen3.8-Flash-Next-experimental-speed-projection.gguf:1.0 1189--control-vector-layer-range 4 44 --cvec-mode project --cvec-dir per-layer 1190``` 1191 1192The engine log then says `control vector mode = project, dir = per-layer, layers 4..44 (41 steered)`, and the web 1193app's About tab lists it. (`--cvec-mode add` is llama.cpp's stock additive mode, for additive vectors.) 1194 1195**Per request.** A loaded vector is on for every request unless it says otherwise: the web app's Sampling drawer has 1196a switch, and the API takes `"experimental_speed_projection": false` in the request body (OpenAI and Anthropic; a 1197config default goes in `"sampling": {"experimental_speed_projection": false}`). Switching drops the conversation 1198cache once, since the model state was computed the other way. Switched off, the output is token-for-token the stock 1199model's. 1200 1201**Measured here** (Q2_0, fixed experts, 2,557 teacher-forced tokens of code, a document and a chat): the top-1 token 1202changes at 10% of positions, mean KL from the stock model 0.063 nats (max 4.1), perplexity +15% on code, +2.3% on 1203the document, +0.4% on the chat. Details: `bench/results/2026-09-27-esp/`. 1204 1205--- 1206 1207## Troubleshooting 1208 1209| Symptom | What to do | 1210| --- | --- | 1211| `the NVIDIA driver is too old` | Update the driver (NVIDIA App or nvidia.com/drivers), restart, run `START-HERE.bat` again. | 1212| Python or the build tools could not be installed | Install what it names (links are printed), then run it again. Everything already done is kept. | 1213| `port 8080 is already in use` | Strata is already running (look for its window), or another program uses the port: `START-HERE.bat --port 8081`. | 1214| `cudaHostRegister ... out of memory` in the log | Normal on Windows: the engine pins the experts in per-layer slices instead. Only a problem if the load then fails. | 1215| `ExpertCache: cudaMalloc(...) failed: out of memory` although VRAM is free | Windows' page file is off or tiny: every allocation on the graphics card is also charged to Windows' commit (RAM + page file). Set the page file to "System managed" (System > About > Advanced system settings > Performance > Advanced > Virtual memory) and restart. Since 0.1.19 the engine retries with a smaller cache instead of stopping, and setup warns about a page file under 4 GB (issue #60). | 1216| The first start takes minutes | It is reading 34-55 GB into RAM; the second start is faster while the files are in the OS cache. | 1217| The PC freezes for a few minutes at the start | Normal, most of all the first time (the server window says when it happens): the engine loads the experts into RAM, pins part of it for the GPU and sizes the expert cache. Wait; don't close the window. Still frozen after 10 minutes: restart the PC, close other programs, try again, or pick a smaller size. | 1218| `the engine stopped unexpectedly (exit code ...)` | The engine process ended mid-answer - usually out of RAM (Linux ends the biggest program: `sudo dmesg \| grep -i -E 'killed process\|out of memory'`). The next request starts it again by itself. If it repeats: close other programs or pick a smaller size. The server also warns at start when the model's experts leave less than ~6 GB of RAM for everything else. | 1219| Slow output, disk light busy | Not enough free RAM: close other programs, or choose Q2_0 / IQ2_XS. | 1220| `prompt ... exceeds the context` | The request is longer than the context you chose: run setup again with a bigger `--context`. | 1221| `the setup refuses --rope-scaling none for a past-trained context` | A context past the trained 262,144 needs the rotary angles rescaled (experimental rope scaling), and the setup will not configure one with the stock angles there. Let it pick (`START-HERE.bat --setup --context 393216` adds yarn and a covering factor), or pass `--rope-scaling linear` or `yarn` yourself. | 1222| Slower than the tables | The monitor plugged into the GPU and other GPU programs take VRAM from the expert cache; RAM running below its rated speed (enable EXPO/XMP in the BIOS) slows the CPU half. | 1223| `this server was started without the vision encoder` | The model was set up for text only: run setup again with `--vision gpu`. | 1224| A picture is refused or `cannot read the image` | The file is not a picture Pillow can open (JPEG, PNG, WebP, GIF, BMP, TIFF, AVIF work). | 1225| Pictures are slow (3-30 s) | The encoder runs on the CPU: run setup again with `--vision gpu` (needs ~1.4 GB of VRAM). | 1226| A request never finishes: "reading the prompt", GPU "100%" at low power | The GPU ran out of VRAM (engines before 0.1.9 could end with ~30 MiB free at large contexts). Run `START-HERE.bat` once to get engine 0.1.9 or newer; the log then says `... MiB of VRAM free with everything loaded` (a few hundred) and names the `--vram-reserve-mib` to add if it is low. | 1227| Generation stops mid-answer, GPU "100%", one CPU core busy | Fixed in engine 0.1.12 (issue #29, a race in the CPU expert pool on big-VRAM cards). Since then a request that stops moving ends with an error instead of hanging (after 2 minutes; 1 minute from 0.1.13): the log says `no progress for ... s ... (issue #29)` with where it stopped, and the next request starts the engine again. If you see that line, please open an issue with it. Engine 0.1.13 adds a stall report under it (what every expert-pool thread and the GPU handshake were doing, memory and page faults) and, on Windows, a `strata-stall-<pid>.dmp` file with every thread's stack: attach both. (`STRATA_WATCHDOG_S` sets the time in seconds; 0 turns it off.) Engine 0.1.14 fixes the stall those reports found (issue #31: with the IQ packs the host could wait forever inside the NVIDIA driver while copying experts in a verify window; the experts are now copied by a GPU kernel, `--pcie-mode dma` restores the old way). | 1228| `no progress for 60 s ... reading the prompt` on Linux, and the stall report says `threads waiting on the disk (state D): 16 ...` | The engine waits for the drive, not a deadlock: the n-gram table is read at random (`--ple-io direct`), which a rotational disk cannot keep up with (#605). The engine warns at start when the table is on one; `--ple-io ram` (Linux, needs RAM for the table) or the model on an SSD fixes it. Setup adds `--ple-io ram` itself on a rotational disk when the RAM holds the table (0.1.39). | 1229| `the engine said nothing for ... s during the request` or `... did not finish the request after it was stopped (STOP)` | Issue #481: the engine and the server lost step (the engine waits for its next command, the server for the request's end; GPU at 0 %, nothing in the log). The server ends the engine after 300 s without a line from it during a request (while a prompt is read: each chunk may take three times the previous one's time, the first one up to its tokens at 50 tok/s more), the request ends with an error and the next request starts the engine again. `"engine_silence_s": 600` in `strata-<model>.json` sets the time (0 = wait forever, as before). If you see it, please add the end of the engine log to #481. | 1230| `out of memory: cudaFuncSetAttribute` in the log (IQ3_XXS, long prompt) | Fixed in engine 0.1.15: CUDA loaded a kernel's code when it was first needed, and mid-prompt there was no VRAM left for it. Run `START-HERE.bat` (Windows) or `./setup.sh` (Linux) once to update. | 1231| Anything else | The engine log is `strata-<model>.log` in this folder. | 1232 1233--- 1234 1235## How it works 1236 1237<p align="center"><img src="paper/tiers.svg" width="760" alt="memory tiers"></p> 1238 1239- **GPU (VRAM):** attention and DeltaNet mixers, the gated-residual weights, routers, shared experts, output head, the MTP 1240 draft layer, the KV cache (from 64K: only its most-read part, the rest streams from RAM), and an **expert cache** that fills the rest of VRAM with the most-used experts (it adapts to 1241 the conversation while you chat). 1242- **RAM:** all 24,576 experts, pinned. The CPU computes the experts that are not on the GPU **in place**, at the same time 1243 as the GPU works on the cached ones (AVX-512 / AVX2 kernels, ggml's for the i-quants). 1244- **SSD:** the 28.8 GB n-gram table, a few rows per token, read unbuffered past the OS cache (`--ple-io direct`, the 1245 default, made for SSDs; on a rotational disk `--ple-io ram` keeps the table in RAM, #605). The engine reads the table 1246 in the format the GGUF has it: IQ4_NL (the default table), Q4_0, Q5_0, Q5_1, Q8_0, FP8 (E4M3 with a scale) or BF16. 1247 Measured on 4,000 random rows against the checkpoint's own BF16 table, the mean per-row error is Q8_0 0.53%, FP8 2.64%, 1248 Q5_1 3.78%, Q5_0 4.25%, IQ4_NL 7.60%, Q4_1 7.80%, Q4_0 8.55% (a Q8_0 table is 54 GB, an IQ4_NL one 28.8 GB). On the Q2_0 model, 700 teacher-forced tokens, the mean KL against the BF16 table is 0.0117 (Q5_0), 0.0121 (Q5_1), 0.0125 1249 (Q8_0), 0.0128 (FP8), 0.0140 (Q4_0) and 0.0146 (IQ4_NL), with the perplexity within 1% of BF16's either way: any change to the 1250 table moves the 2-bit model by about 0.012, so the formats are hard to tell apart. Setup does not offer another table; 1251 it only changes which GGUF the engine is given. 1252- **Speculation:** the model's own MTP layer drafts up to 3 tokens; one pass over all 48 layers checks them. 2.4-3.2 1253 tokens per pass on average. When the reply repeats the context (code edits, quoted text), **prompt lookup** (engine 1254 0.1.7) drafts up to 5 tokens from the earlier copy, but only where its measured acceptance and cost say it pays: 1255 code edits 6-11% faster, other text unchanged. The drafts are checked like the MTP's, so the output is the same. 1256- **Prompts** are processed in chunks of up to 8,192 tokens (`--prefill auto`; 32,768 opt-in) with the experts 1257 streamed to the GPU over PCIe. Since engine 0.1.39b (#583) the streamed ring is sized in bytes for the pack (a 1258 native pack with bigger blobs gets fewer ring slots and keeps more cache slots) and `--prefill auto` picks the 1259 largest chunk that keeps that ring full. It only gives up ring slots where 0.1.39's rule held the chunk at 4,096 1260 tokens or less; from 6,144 on it keeps 0.1.39's ring and only looks for a bigger chunk beside it (shrinking the 1261 ring there measured slower: the Coder -12%), and a prompt that fits 0.1.39's chunk keeps 0.1.39's ring (one 1262 chunk: a smaller ring only slowed it). RTX 5070, 32K prompts against `STRATA_RING_BYTES=0`, 2-3 interleaved 1263 rounds: IQ3_XXS +18.5% at a 1,500-slot cache and +9% in another memory state, the Coder +3%, IQ3_S unchanged; 4K 1264 prompts unchanged (-0.7% to +1.1%, bit-identical). Q2_0 (a fixed `--prefill 2048`) is not affected. It changes 1265 the bits of a long prompt against 0.1.39 (the experts go through a different 1266 mix of cached and streamed groups). Measured quality, teacher-forced over the next 2,001 tokens of a long document 1267 against the FP16 prompt path (IQ3_XXS, `--prefill auto`): 8K prompt KL 0.042 (0.1.39: 0.054), top-1 agreement 1268 93.5% (92.2%); 32K prompt KL 0.020 (0.019), top-1 95.3% (95.0%) - the same band as before. `STRATA_RING_BYTES=0` 1269 restores 0.1.39's ring, loan and chunk choice. 1270 1271The full story, with measurements, bottlenecks and what comes next: **[docs/paper/Strata-Paper.pdf](paper/Strata-Paper.pdf)**. 1272 1273--- 1274 1275## Credits and licenses 1276 1277Strata itself: [MIT](../LICENSE). The model files are not part of it; their licenses apply to them (below). 1278 1279- Model: [Qwen/Qwen3.8-Flash-Next](https://huggingface.co/Qwen/Qwen3.8-Flash-Next) by the Qwen team; quantizations: 1280 [ISTA-DASLab/Qwen3.8-Flash-Next-GSQ-RCO-GGUF](https://huggingface.co/ISTA-DASLab/Qwen3.8-Flash-Next-GSQ-RCO-GGUF). 1281 The Coder: [ISTA-DASLab/Qwen3.8-Flash-Next-GSQ-RCO-Coder-GGUF](https://huggingface.co/ISTA-DASLab/Qwen3.8-Flash-Next-GSQ-RCO-Coder-GGUF) 1282 (Apache-2.0 per its card); its support in Strata came from @pjgmobile's PR #54. 1283 Swift 1.5: [uk