Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

docs: the expert cache size is a budget, and an over-sized one pages on Windows

1314521gjyf2158a5cf5ba
diff --git a/docs/DETAILS.md b/docs/DETAILS.md
index 580cd037d..580937d9f 100644
--- a/docs/DETAILS.md
+++ b/docs/DETAILS.md
@@ -520,6 +520,50 @@ before). A relative path is in the Strata folder; one file per model, and a prof
(point the key at another file). The file is a fingerprint of what you used the model for: it stays on your PC.
Without the key nothing is counted or written. Setup rewrites the config when run again: add the key again then.
+**The expert cache size is a budget, and on Windows an over-sized one pages instead of failing.** `--expert-cache N`
+(`"expert_cache": N`) is `N` times the largest expert blob, and the engine compares it only with the free VRAM it
+reads **before** the slots are written. `--expert-cache auto` (the default) sizes from that same figure but **checks
+again once the slots are actually written** and shrinks if they do not fit; that second check is auto-only (the loop
+breaks on `!auto_cache`). Under WDDM an allocation is not resident until it is touched, and the free figure read
+before it can be about a gigabyte too high, and the driver's default sysmem fallback puts an over-committed
+allocation in system memory instead of failing - so the start looks normal, the banner still reports the slot count,
+and only the speed collapses. The startup line is the tell: `... MiB of VRAM free with everything loaded`, and below
+about 256 MiB it adds `LOW: requests may stall; add --vram-reserve-mib N` with the value that would have left room.
+
+Measured on an RTX 4080 SUPER 32 GB, IQ3_S, engine 0.1.39, `--max-context 1048576` (yarn factor 4), fresh
+43,969 / 45,670 / 47,956-token prompts with 200 generated each, one engine start per row (the rest of the
+configuration is the one in `bench/results/2026-10-04-community-rtx-4080s-iq3s`):
+
+| expert cache | slots | VRAM free at start | decode tok/s |
+| --- | ---: | --- | --- |
+| `--expert-cache 8900` (11,631 slots, 22.07 GiB) | 11,631 | 0 MiB (`LOW`, suggests `--vram-reserve-mib 1212`) | 13.7 / 14.7 |
+| `auto` | 11,178 | 217 MiB (`LOW`) | 102.1 / 122.3 |
+| `auto` with `--vram-reserve-mib 1500` | 10,766 | 1,075 MiB | 88.9 / 96.5 / 101.4 |
+| `--expert-cache 7000` | 9,148 | 4,130 MiB | 94.1 / 97.3 |
+| the same 11,631-slot cache at `--max-context 524288` | 11,631 | 299 MiB | 113.2 / 107.9 |
+
+453 slots (0.86 GiB) separate 13.7 from 102 tok/s, and the slower run had the **higher** cache hit rate (91.4 / 94.7%
+against 90.4 / 93.9%), so this is not misses: being at 0 MiB free is what costs 7x. Two ways to stay out of it: leave
+the cache on `auto`, or keep an explicit size and raise `--vram-reserve-mib`, which the engine deducts **before** it
+sizes the cache (700 -> 1000 -> 1500 took the free figure from 217 to 575 to 1,075 MiB and cost about 400 slots).
+
+**Checking it on Windows.** `\GPU Process Memory(<pid>)\Shared Usage` and `Dedicated Usage` (Performance Monitor, or
+`Get-Counter`) look like the right instrument, but on this machine they did **not** separate a 13.7 tok/s run from a
+102 tok/s one: `Shared` read about 55.5 GB at 262/524K and 62.4 GB at 1M in every run, because it counts the
+deliberately pinned memory (the expert arena, 50.3 GB here, plus the pinned K/V, 6.19 -> 12.38 GiB at 1M). The free
+line in the log is the reliable tell, and on NVIDIA hardware `CUDA - Sysmem Fallback Policy` set to
+`Prefer No Sysmem Fallback` for the engine's executable is the other way to make an over-sized cache fail instead of
+paging (not measured here). Reported with the measurements in
+[issue #781](https://github.com/Niko1221/Strata/issues/781).
+
+The same shape appears on a second, smaller card. On a 16 GB RTX 5080 at 786,432, UD-IQ4_XS, INT8 KV, with
+`Prefer No Sysmem Fallback` set and an explicit `--expert-cache 4000`, taking `--vram-reserve-mib` down from 770 to 0
+grew the cache from 2,782 to 3,115 slots (768 MiB) while the card's used memory moved 129 MiB, the hit rate stayed
+flat (59.9% to 63.0%) and decode fell from 40.9 to 16.6 tok/s. Every step there reached READY with 0 MiB free, so
+with the fallback off it still starts and degrades instead of failing - the slack left for the rest of the card is
+worth more than the extra slots, which is the same ordering measured above (enkynakamura, #781; one 256-token sample
+per step, so the upper rows are noisy).
+
---
## Using it
@@ -1253,6 +1297,7 @@ the document, +0.4% on the chat. Details: `bench/results/2026-09-27-esp/`.
| 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). |
| Pictures are slow (3-30 s) | The encoder runs on the CPU: run setup again with `--vision gpu` (needs ~1.4 GB of VRAM). |
| 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. |
+| Output much slower than the tables above, only with a large `--context`, and the start says a small `... MiB of VRAM free with everything loaded` | The expert cache does not fit the card at that context. With `--expert-cache auto` the engine shrinks it to fit; with a fixed number it does not check again after the slots are written, and on Windows the extra is put in system memory instead of failing, so only the speed shows it. Use `auto`, a smaller number, or raise `--vram-reserve-mib` (it is deducted before the cache is sized). See "The expert cache size is a budget" under Sharing the GPU. |
| 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). |
| `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). |
| `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. |