okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge branch 'f-140' into f-140-j2e0f28e7d

main
9.7 KiB143 linesraw

Windows mapped expert-page release

Measured October 4, 2026, against upstream 6f32ec070f23ced9f50e704d854d775da52591ab (0.1.39). The same patched executable was run with STRATA_FILE_RELEASE=0 and STRATA_FILE_RELEASE=1. Releasing file-backed expert pages after GPU copies substantially increased available physical RAM on this machine. Prefill was slightly slower. This is a memory-pressure improvement, not a general speed claim.

What changes

Windows FileExpertSource::release() uses VirtualUnlock on complete interior pages of its read-only file views. Windows documents that unlocked pages are removed from the process working set even when the call returns FALSE with ERROR_NOT_LOCKED. Other errors are reported. The mapping stays valid and later reads fault in the original bytes. Shared boundary pages are retained. The code resolves file spans directly, so it does not trim resident complements, CUDA-pinned buffers or the temporary buffers used to assemble GGUF experts.

Existing cache-upload release calls use this implementation. Two additional calls release pages after prefill's lent cache slots have finished refilling, in serving and one-shot generation. Other platforms are unchanged. STRATA_FILE_RELEASE=1 enables it; unset, 0, or any other value leaves it disabled. The switch is read once per engine process, so restart the engine when changing it.

This builds on the existing working-set handling in #467 and the mapped-arena work in #640. Multi-GPU placement already exists upstream; this patch does not implement it. See Microsoft's VirtualUnlock documentation.

Configuration

ComponentMeasured configuration
SystemWindows 11 Pro build 26200, Core i9-14900HX, 31.77 GiB usable RAM, 2 x 16 GB DDR5-5600
GPU 0RTX 4080 Laptop, 12,282 MiB VRAM; also drives the desktop
GPU 1RTX 3090, 24,576 MiB VRAM, Thunderbolt eGPU
LinksEngine H2D probes approximately 12.3-12.9 GB/s and 2.4 GB/s respectively; no CUDA peer read/write
DriverNVIDIA 616.56
StorageModel and pack on an internal WD PC SN560 NVMe
BuildMSVC 19.29.30157, CUDA 13.1.80, Release, AVX2 portable, SM 86/89, native experts enabled
ModelISTA-DASLab/Qwen3.8-Flash-Next-GSQ-RCO-GGUF, IQ2_XS, with MTP
PlacementGPUs 0,1, layer split 12, stage-weight trim, mapped experts
RuntimeContext 32768, int8 KV, 15 pool workers, auto expert cache and prefill, spec 4, minimum draft probability 0.5

GPU 0 held 6,144 expert pairs (about 8.00 GiB), GPU 1 held 13,381 (about 18.15 GiB); 19,525 of 24,576 pairs in total. Prefill selected 8192 and borrowed approximately 3.77 GiB of expert cache on each GPU. The native pack used experts.bin (35,454,976,000 bytes), dense.bin (1,538,035,200 bytes), and the GGUF PLE table on disk. Power was AC; the existing power plan, drivers and system-managed pagefile were not changed.

Model revision: ed59f92082b1e93c0e96d60a8b11aab089b52f09. MTP checkpoint revision: de4b8e4d43b917e7706784d8bb445c9af86a3540. llama.cpp revision: 3cf03257f219afbe7334045ff7c6a06ac68c627d. The two downloaded GGUF shards were fully SHA-256 verified:

ShardBytesSHA-256
139,225,954,59292cee27ae5bbadcd732416a0f7a7f0acc092399dbbe8f5a5efa707c2ec0a49d7
228,800,138,432316b46f3a2dbd68c900f43136ab9449f9dcc3725dfd8c794847c204bc161e113

The measured prototype executable had SHA-256 9118b02dcc0ad4bd8398ba033c641feb93800e0eeecea59ee42be141e4a186fc. It predates the submitted patch's decision to default the switch to OFF. Explicit 0 and 1 have the same behavior in both versions; the numbers below are from the prototype, not a benchmark of the final rebuild.

Measurements

Each arm had one excluded short warmup followed by three fresh prompts at each length, with 256 output tokens, temperature zero and thinking disabled. Prompts ask for explanations of synthetic integer-processing code. The harness checks that all prompt tokens were processed, no prefix tokens were reused, the response completed, and exactly one request was recorded by the idle dedicated server. Actual prompt lengths were 1023, 4096 and 16384.

Medians of three requests per cell:

PromptPrefill OFF / ON, tok/sDecode OFF / ON, tok/sClient TTFT OFF / ON, s
1K263.68 / 253.8377.35 / 77.653.93 / 4.07
4K583.51 / 558.2481.99 / 94.177.06 / 7.38
16K1045.85 / 1000.1680.88 / 84.9315.73 / 16.45

An independent Windows monitor sampled host RAM, process working sets, commit, pagefile use and physical-disk counters approximately once per second. The following window includes warmup and gaps between requests, from the first request's start to the last request's finish. GiB means bytes divided by 2^30.

MetricRelease OFFRelease ON
Available RAM, median0.512 GiB12.187 GiB
Available RAM, minimum0.277 GiB6.110 GiB
Engine working set, median23.379 GiB11.946 GiB
Engine nonprivate working set, median20.460 GiB8.689 GiB
System commit, median51.880 GiB51.973 GiB
Engine private commit, median36.807 GiB36.804 GiB
Pagefile use, median1.233 GiB1.218 GiB
Internal physical-disk reads, total16.750 GiB16.809 GiB

The benefit was available physical RAM. Commit was effectively unchanged; this does not solve a commit-limit failure or eliminate the need for pagefile capacity. Physical reads were also effectively unchanged. Nonprivate working-set bytes include file mappings and shared images, not only model pages. Physical-disk counters are system-wide and omit about 1.1-1.3 seconds at the sampled interval edges. The external disk was idle.

These were sequential OFF-then-ON runs on one machine, with warm engines and retained OS file-cache history. The adaptive expert cache remained enabled. The OS cache was not flushed; this is not a cold-SSD experiment. Three repetitions provide observed ranges, not confidence intervals. Code-explanation outputs differed between the two arms despite identical measured requests; speculative decode rates are workload-dependent. Prefill throughput dropped 3.7-4.4%, and median whole-request time changed by +3.5%, -1.1% and +2.9% at 1K, 4K and 16K. These observations do not establish a decode-speed improvement, output equivalence, or results on other hardware.

Reproduction and checks

benchmark.py and monitor_windows.py are the scripts used for these measurements (the raw per-trial export and the harness self-tests were left out of the repository). The switch was called STRATA_ARENA_RELEASE in the prototype that measured this; it is STRATA_FILE_RELEASE here, because the old name already means the opposite elsewhere (=0 keeps experts a GPU holds). The benchmark needs the repository's normal server/tokenizer dependencies; the Windows monitor also needs psutil.

Start a dedicated server on 127.0.0.1:18080 using a configuration with the runtime settings above, the patched engine, and "env": {"STRATA_FILE_RELEASE": "0"}. Wait until the engine is loaded and idle. In another terminal, run the monitor against the server process ID, and then the benchmark (replace the uppercase placeholders):

python bench/results/2026-10-04-windows-mapped-release/monitor_windows.py --server-pid SERVER_PID --out off-host.jsonl --stop-file off-monitor.stop
python bench/results/2026-10-04-windows-mapped-release/benchmark.py --pack PACK_DIR --config CONFIG_JSON --label release-off --out results-off --targets 1024,4096,16384 --runs 3 --max-tokens 256

Stop the monitor by creating its stop file. Unload and stop the server, change only the release value to 1, restart, and repeat with new ON output paths. Keep available VRAM, background workloads and model files stable. For host summaries, select samples with min(started_epoch_s) <= epoch_s <= max(finished_epoch_s) from the benchmark's results, including warmup. Compute sample medians/minima and physical-disk last-minus-first counters. Sum windows_memory counters for strata.exe processes only; nonprivate working set is total minus private.

The C++ tests cover canonical and variable native layouts, full-page alignment, preserved boundary pages, three release/read cycles with byte-for-byte checks, invalid indices, a closed source, and three GGUF roles across two shards. Build with STRATA_BUILD_TESTS=ON and STRATA_NATIVE_EXPERTS=ON, then run ctest --test-dir BUILD_DIR -R "^(file_expert_source_test|expert_layout_test)$" --output-on-failure in fresh processes with the switch unset, 0, and 1.

The final submitted source was rebuilt with the toolchain above. Both C++ tests passed with the switch unset, 0, and 1. That rebuilt engine also completed a warmup and one fresh request each at 1023 and 4096 prompt tokens, generating 256 tokens per measured request on both GPUs with release enabled. This was an inference smoke test, not a replacement for the prototype's OFF/ON performance comparison. Its executable SHA-256 is 9f1e96c36b2ddb530422ee37734606491c0f4c3c9b720095c68d63953e89913b.

Additional prototype checks with release ON completed 30 requests without runtime errors: 21 of 24 objective checks passed, with three JSON-only checks failing because of Markdown fences. All 24 objective responses and statuses matched the official engine with the same GPU placement, including those three failures. Six prose requests were unscored. Needle retrieval passed near 1K/4K/16K tokens at 50% depth. The functional battery was not run on the release-OFF prototype, and these limited checks do not prove general model quality or token parity.

1# Windows mapped expert-page release
2
3Measured October 4, 2026, against upstream `6f32ec070f23ced9f50e704d854d775da52591ab` (0.1.39).
4The same patched executable was run with `STRATA_FILE_RELEASE=0` and `STRATA_FILE_RELEASE=1`.
5Releasing file-backed expert pages after GPU copies substantially increased available physical RAM on this
6machine. Prefill was slightly slower. This is a memory-pressure improvement, not a general speed claim.
7
8## What changes
9
10Windows `FileExpertSource::release()` uses `VirtualUnlock` on complete interior pages of its read-only file views.
11Windows documents that unlocked pages are removed from the process working set even when the call returns
12`FALSE` with `ERROR_NOT_LOCKED`. Other errors are reported. The mapping stays valid and later reads fault in the
13original bytes. Shared boundary pages are retained. The code resolves file spans directly, so it does not trim
14resident complements, CUDA-pinned buffers or the temporary buffers used to assemble GGUF experts.
15
16Existing cache-upload release calls use this implementation. Two additional calls release pages after prefill's
17lent cache slots have finished refilling, in serving and one-shot generation. Other platforms are unchanged.
18`STRATA_FILE_RELEASE=1` enables it; unset, `0`, or any other value leaves it disabled. The switch is read once
19per engine process, so restart the engine when changing it.
20
21This builds on the existing working-set handling in [#467](https://github.com/Niko1221/Strata/issues/467) and the
22mapped-arena work in [#640](https://github.com/Niko1221/Strata/pull/640). Multi-GPU placement already exists upstream;
23this patch does not implement it. See Microsoft's [VirtualUnlock documentation](https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtualunlock).
24
25## Configuration
26
27| Component | Measured configuration |
28| --- | --- |
29| System | Windows 11 Pro build 26200, Core i9-14900HX, 31.77 GiB usable RAM, 2 x 16 GB DDR5-5600 |
30| GPU 0 | RTX 4080 Laptop, 12,282 MiB VRAM; also drives the desktop |
31| GPU 1 | RTX 3090, 24,576 MiB VRAM, Thunderbolt eGPU |
32| Links | Engine H2D probes approximately 12.3-12.9 GB/s and 2.4 GB/s respectively; no CUDA peer read/write |
33| Driver | NVIDIA 616.56 |
34| Storage | Model and pack on an internal WD PC SN560 NVMe |
35| Build | MSVC 19.29.30157, CUDA 13.1.80, Release, AVX2 portable, SM 86/89, native experts enabled |
36| Model | `ISTA-DASLab/Qwen3.8-Flash-Next-GSQ-RCO-GGUF`, IQ2_XS, with MTP |
37| Placement | GPUs `0,1`, layer split 12, stage-weight trim, mapped experts |
38| Runtime | Context 32768, int8 KV, 15 pool workers, auto expert cache and prefill, spec 4, minimum draft probability 0.5 |
39
40GPU 0 held 6,144 expert pairs (about 8.00 GiB), GPU 1 held 13,381 (about 18.15 GiB); 19,525 of 24,576 pairs in total.
41Prefill selected 8192 and borrowed approximately 3.77 GiB of expert cache on each GPU. The native pack used
42`experts.bin` (35,454,976,000 bytes), `dense.bin` (1,538,035,200 bytes), and the GGUF PLE table on disk.
43Power was AC; the existing power plan, drivers and system-managed pagefile were not changed.
44
45Model revision: `ed59f92082b1e93c0e96d60a8b11aab089b52f09`.
46MTP checkpoint revision: `de4b8e4d43b917e7706784d8bb445c9af86a3540`.
47llama.cpp revision: `3cf03257f219afbe7334045ff7c6a06ac68c627d`.
48The two downloaded GGUF shards were fully SHA-256 verified:
49
50| Shard | Bytes | SHA-256 |
51| --- | ---: | --- |
52| 1 | 39,225,954,592 | `92cee27ae5bbadcd732416a0f7a7f0acc092399dbbe8f5a5efa707c2ec0a49d7` |
53| 2 | 28,800,138,432 | `316b46f3a2dbd68c900f43136ab9449f9dcc3725dfd8c794847c204bc161e113` |
54
55The measured prototype executable had SHA-256
56`9118b02dcc0ad4bd8398ba033c641feb93800e0eeecea59ee42be141e4a186fc`.
57It predates the submitted patch's decision to default the switch to OFF. Explicit `0` and `1` have the same
58behavior in both versions; the numbers below are from the prototype, not a benchmark of the final rebuild.
59
60## Measurements
61
62Each arm had one excluded short warmup followed by three fresh prompts at each length, with 256 output tokens,
63temperature zero and thinking disabled. Prompts ask for explanations of synthetic integer-processing code.
64The harness checks that all prompt tokens were processed, no prefix tokens were reused, the response completed,
65and exactly one request was recorded by the idle dedicated server. Actual prompt lengths were 1023, 4096 and 16384.
66
67Medians of three requests per cell:
68
69| Prompt | Prefill OFF / ON, tok/s | Decode OFF / ON, tok/s | Client TTFT OFF / ON, s |
70| --- | ---: | ---: | ---: |
71| 1K | 263.68 / 253.83 | 77.35 / 77.65 | 3.93 / 4.07 |
72| 4K | 583.51 / 558.24 | 81.99 / 94.17 | 7.06 / 7.38 |
73| 16K | 1045.85 / 1000.16 | 80.88 / 84.93 | 15.73 / 16.45 |
74
75An independent Windows monitor sampled host RAM, process working sets, commit, pagefile use and physical-disk
76counters approximately once per second. The following window includes warmup and gaps between requests, from
77the first request's start to the last request's finish. GiB means bytes divided by 2^30.
78
79| Metric | Release OFF | Release ON |
80| --- | ---: | ---: |
81| Available RAM, median | 0.512 GiB | 12.187 GiB |
82| Available RAM, minimum | 0.277 GiB | 6.110 GiB |
83| Engine working set, median | 23.379 GiB | 11.946 GiB |
84| Engine nonprivate working set, median | 20.460 GiB | 8.689 GiB |
85| System commit, median | 51.880 GiB | 51.973 GiB |
86| Engine private commit, median | 36.807 GiB | 36.804 GiB |
87| Pagefile use, median | 1.233 GiB | 1.218 GiB |
88| Internal physical-disk reads, total | 16.750 GiB | 16.809 GiB |
89
90The benefit was available physical RAM. Commit was effectively unchanged; this does not solve a commit-limit
91failure or eliminate the need for pagefile capacity. Physical reads were also effectively unchanged.
92Nonprivate working-set bytes include file mappings and shared images, not only model pages. Physical-disk
93counters are system-wide and omit about 1.1-1.3 seconds at the sampled interval edges. The external disk was idle.
94
95These were sequential OFF-then-ON runs on one machine, with warm engines and retained OS file-cache history.
96The adaptive expert cache remained enabled. The OS cache was not flushed; this is not a cold-SSD experiment.
97Three repetitions provide observed ranges, not confidence intervals. Code-explanation outputs differed between
98the two arms despite identical measured requests; speculative decode rates are workload-dependent. Prefill
99throughput dropped 3.7-4.4%, and median whole-request time changed by +3.5%, -1.1% and +2.9% at 1K, 4K and 16K.
100These observations do not establish a decode-speed improvement, output equivalence, or results on other hardware.
101
102## Reproduction and checks
103
104`benchmark.py` and `monitor_windows.py` are the scripts used for these measurements (the raw per-trial export and the harness
105self-tests were left out of the repository). The switch was called `STRATA_ARENA_RELEASE` in the prototype that measured this;
106it is `STRATA_FILE_RELEASE` here, because the old name already means the opposite elsewhere (`=0` keeps experts a GPU holds).
107The benchmark needs the repository's normal server/tokenizer dependencies; the Windows monitor also needs psutil.
108
109Start a dedicated server on `127.0.0.1:18080` using a configuration with the runtime settings above, the patched
110engine, and `"env": {"STRATA_FILE_RELEASE": "0"}`. Wait until the engine is loaded and idle. In another terminal,
111run the monitor against the server process ID, and then the benchmark (replace the uppercase placeholders):
112
113```powershell
114python bench/results/2026-10-04-windows-mapped-release/monitor_windows.py --server-pid SERVER_PID --out off-host.jsonl --stop-file off-monitor.stop
115```
116
117```powershell
118python bench/results/2026-10-04-windows-mapped-release/benchmark.py --pack PACK_DIR --config CONFIG_JSON --label release-off --out results-off --targets 1024,4096,16384 --runs 3 --max-tokens 256
119```
120
121Stop the monitor by creating its stop file. Unload and stop the server, change only the release value to `1`,
122restart, and repeat with new ON output paths. Keep available VRAM, background workloads and model files stable.
123For host summaries, select samples with `min(started_epoch_s) <= epoch_s <= max(finished_epoch_s)` from the
124benchmark's results, including warmup. Compute sample medians/minima and physical-disk last-minus-first counters.
125Sum `windows_memory` counters for `strata.exe` processes only; nonprivate working set is total minus private.
126
127The C++ tests cover canonical and variable native layouts, full-page alignment, preserved boundary pages,
128three release/read cycles with byte-for-byte checks, invalid indices, a closed source, and three GGUF roles
129across two shards. Build with `STRATA_BUILD_TESTS=ON` and `STRATA_NATIVE_EXPERTS=ON`, then run
130`ctest --test-dir BUILD_DIR -R "^(file_expert_source_test|expert_layout_test)$" --output-on-failure` in fresh
131processes with the switch unset, `0`, and `1`.
132
133The final submitted source was rebuilt with the toolchain above. Both C++ tests passed with the switch unset,
134`0`, and `1`. That rebuilt engine also completed a warmup and one fresh
135request each at 1023 and 4096 prompt tokens, generating 256 tokens per measured request on both GPUs with release
136enabled. This was an inference smoke test, not a replacement for the prototype's OFF/ON performance comparison.
137Its executable SHA-256 is `9f1e96c36b2ddb530422ee37734606491c0f4c3c9b720095c68d63953e89913b`.
138
139Additional prototype checks with release ON completed 30 requests without runtime errors: 21 of 24 objective
140checks passed, with three JSON-only checks failing because of Markdown fences. All 24 objective responses and
141statuses matched the official engine with the same GPU placement, including those three failures. Six prose
142requests were unscored. Needle retrieval passed near 1K/4K/16K tokens at 50% depth. The functional battery was not
143run on the release-OFF prototype, and these limited checks do not prove general model quality or token parity.