mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#1230
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @As7656431 on GitHub (Oct 18, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/3065
Update, 2026-10-23: re-tested on 0.2.3.1. The problem is still there. Nothing in 0.2.3.1 changes this path on Windows:
open_prompt_directis still Linux only,STRATA_PROMPT_DIRECTis still read only with a RAM budget, and the io prefetch that 0.2.1 turned on by default forexperts.binpacks is Linux only.Same PC (RTX 5070 12 GB, i5-14600KF, 31.8 GiB DDR4, Windows 10 22H2, Flash-Next IQ2_XS on a drive of about 1.5 GB/s) and settings as below, everything built from main
7ddc17a3(v0.2.3.1, engine 0.1.48.1),tools/strata_bench.pyof that commit, medians of 3, all on the same day:#3086 alone with the bench script and the daily settings of the original report below (a short question, another, a real 20K-token English document, a short question; four interleaved rounds, averages): first request after a start 32.2 to 43.4 tok/s (+35%), decode right after the document 14.7 to 23.9 tok/s (+62%), a short question after it 34.0 to 46.2 tok/s (+36%), warm chat 60.2 to 67.9 tok/s (+13%), each faster in 4 of 4 rounds; reading the document unchanged (186.1 against 184.5 s).
STRATA_PROMPT_DIRECT=1andSTRATA_PREFILL_DIRECT_RAM) and #3086 (change 3,STRATA_MMAP_PREFETCH). Both are rebased on main, independent of each other, off by default, and each has a small regression test intests/core/file_expert_source_test.cpp.STRATA_DUMP_FIRST_LOGITSafter an 8K document and a 300-token prompt, two runs per build and setting: for each prompt the 12 runs gave two outputs, which differ no more than main's own runs differ from each other (300 tokens: main's two runs gave both, KL 1.9e-4; 8K: KL 1.24e-3, as between two runs of the 0.1.45 release). The first choice was the same in every run.PYTHONUTF8=1(#2792) on a Chinese-locale Windows.Original report (2026-10-18, measured on 0.1.44.1 and 0.1.45):
Goal: on a Windows PC whose RAM cannot hold the experts (low-RAM mode,
--mmap-experts), read prompts without millions of page faults, and keep the decode's cached experts in RAM afterwards. I have three opt-in changes for this, measured on one PC, and would like to know whether you would take them as pull requests, or prefer another approach.The PC: RTX 5070 12 GB, i5-14600KF, 31.8 GiB DDR4-3600, Windows 10 22H2, model files on an aigo P2000 NVMe (about 1.4-1.6 GB/s). Original Flash-Next IQ2_XS (35.5 GB of experts),
--mmap-experts, 32K context,--kv int8, MTP. Results-only report for 0.1.45 on this PC: #3063.What happens
tools/strata_bench.py); agent follow-up turns wait 48 s for the first token and then decode at 6.4 tok/s.experts.binare page faults, not drive-bound reads. They also push the decode's cached experts out of RAM, so the answer after a long prompt decodes at 13-19 tok/s, against about 70 tok/s for a warm chat.Why the existing switches do not cover it
STRATA_PROMPT_DIRECT=1is read only in the RAM-budget branch ofgenerate.cpp, andFileExpertSource::open_prompt_directis Linux only ("NTFS serves unbuffered reads of a mapped file one at a time").FileExpertSource::prefetchreturns at once unlessstaged(), so a plain mappedexperts.bingets no batch prefetch in decode; each CPU expert faults in page by page.--resident-budget-gib 8/14, 0.1.44.1) reads a 20K prompt in 80 s instead of about 170 s, but decodes at about 14 tok/s on this PC, so it is not an alternative here.The changes (on 0.1.44.1; every one off by default)
STRATA_PROMPT_DIRECT=1on Windows and without a RAM budget. A Windows branch inopen_prompt_direct(a second handle onexperts.binwithFILE_FLAG_NO_BUFFERING | FILE_FLAG_OVERLAPPED;read_directuses these handles when the tier itself is not unbuffered), the switch honoured in the mmap mode without a budget, and a newExpertSource::prompt_reads()so the stager hands unpinned blobs tocopy_blobs(8 per batch) without touchingtransient(): the decode and the prompt CPU share behave exactly as before.STRATA_PREFILL_DIRECT_RAM=3. In thatcopy_blobspath, a blob whose pages are all in the process working set (QueryWorkingSetEx) is copied from the mapping; the rest are read through the file cache as merged runs of neighbouring blobs (the standby list still holds many of them). On this PC about 70-77% of the prompt's expert bytes came from the working set and none had to be read unbuffered.STRATA_MMAP_PREFETCH=2. For a plain mappedexperts.bin, the layer's CPU experts go toPrefetchVirtualMemoryas one batch on a helper thread (the call costs about 0.2 ms even when every page is resident, so the decode thread does not wait for it).Together with two switches that already exist:
STRATA_PREFILL_STREAM_MIN=8193(stream only the routed experts for chunks up to 8,192 tokens) andSTRATA_WATCHDOG_S=180. About 300 lines inexpert_source.cpp/hpp,prefill.cppandgenerate.cpp. Built and tested only with CUDA on Windows; the new code is Windows file I/O, not GPU code, but I have not built HIP or SYCL.Measurements (same PC, same day, the same settings apart from the switches)
tools/strata_bench.py(the 0.1.45 tool as the client), 0.1.44.1 against 0.1.44.1 with the switches, medians of 3:The tool's prompts are generated word lists, which probably route to fewer experts than real text and so flatter
STRATA_PREFILL_STREAM_MIN. With a real 20K-token English document (four versions in one run, four rounds, a different version first in each round; averages of the four rounds):STRATA_MMAP_PREFETCH=2alone, four interleaved rounds: first request after a start +22% (4 of 4 rounds faster), a short question after the long document +11% (3 of 4), warm chat +7% (4 of 4), prompt reading unchanged.Correctness
The switches change where the bytes come from, not what is computed. Checked with
STRATA_DUMP_FIRST_LOGITS(the logits after the prompt) on an 8K document and a 300-token prompt:STRATA_PREFILL_STREAM_MIN/STRATA_WATCHDOG_Sswitches, and the official binary alone gave three different outputs in seven runs. The extra output is within that spread (KL up to 1.8e-4 against the official outputs, which differ from each other by up to 2.1e-4); the first choice was the same in every run.STRATA_MMAP_PREFETCHonly asks the OS for pages ahead of time, so the bytes the pool reads are the same.So one thing I noticed on the way: the official binary itself is not bit-reproducible between runs on this PC (two runs of the 8K document differ by a KL of 2.4e-3).
Not tested
Linux; other GPUs; a fast NVMe (your note in
read_directmeasured unbuffered reads of a mapped file at 3.4 GB/s on a PCIe 5 drive; on this drive they still beat the page faults, but on a fast drive the official path is already much faster, see #2791); a RAM budget together with the switches; GGUF-in-place packs; HIP and SYCL builds; output quality beyond the logits check (no change is expected, since the computation is the same).If this is welcome, I would send three separate PRs (1, 2, 3 above) on top of current main, each off by default with the default path unchanged.
@As7656431 commented on GitHub (Oct 19, 2026):
How to reproduce #3072 and #3086 (one set of steps for both)
Where it shows. The gain needs all of these: Windows, a pack whose experts do not fit in RAM (here 35.5 GB of IQ2_XS experts and 31.8 GiB of RAM), the low-RAM mode (
--mmap-experts, no--resident-budget-gib), and a drive that is not very fast (here about 1.4-1.6 GB/s). On a PC whose RAM holds the experts, or on Linux, the switches change nothing; on a fast NVMe the default path is already much faster (#2791), so expect less. To try it on a PC with more RAM, a bigger pack (its experts larger than the free RAM) should give the same situation; I have not tried that myself.Build both together (they merge without conflicts):
then build the CUDA engine as usual.
Engine arguments (my config, paths shortened):
with
STRATA_FETCH_THREADS=16in the config'senv. Then add, in the sameenv:STRATA_PROMPT_DIRECT=1STRATA_PROMPT_DIRECT=1,STRATA_PREFILL_DIRECT_RAM=3STRATA_MMAP_PREFETCH=2At start the engine log should say
the prompt path's expert reads go unbuffered (STRATA_PROMPT_DIRECT=1, mmap mode)whenSTRATA_PROMPT_DIRECT=1takes effect.Measure with
tools/strata_bench.py. While #2864 is open, start the server yourself and point the tool at it with--url; while #2792 is open, on a Chinese- or Japanese-locale Windows also setPYTHONUTF8=1:What I got (RTX 5070 12 GB, i5-14600KF, 31.8 GiB DDR4-3600, Windows 10, model on an aigo P2000; every column is current main / 0.1.45 plus the switches named; medians of 3):
STRATA_PROMPT_DIRECT=1+ STRATA_PREFILL_DIRECT_RAM=3+ STRATA_MMAP_PREFETCH=2(all)STRATA_MMAP_PREFETCH=2alone (its own A/B, four interleaved rounds, short question / short question / 20K-token document / short question): first request after a start +33%, a short question after the document +34%, decode right after the document +50%, warm chat +10%, prompt reading unchanged. Adding the existingSTRATA_PREFILL_STREAM_MIN=8193on top reads short and medium prompts faster again (in #3065, on 0.1.44.1: 4K at 978 tok/s, 16K at 1456 tok/s); it is not part of these PRs.Check that the computation is the same: run the CLI engine with the same arguments plus
--tokens-file <ids> --max-new 1andSTRATA_DUMP_FIRST_LOGITS=<out.bin>(float32 logits after the prompt), a few times with and without the switches, and compare the files. The release itself is not bit-reproducible between runs on this PC (two runs of an 8K document differ by KL 1e-3 to 2.4e-3), so compare against several release runs: in my runs every output with the switches was either bit-identical to a release run or as far from the release runs as they are from each other, and the first choice never changed.@Niko1221 commented on GitHub (Oct 19, 2026):
Thanks for taking the time to report this.
We're resetting the tracker for 0.2.0-beta. There are more than 1,300 open issues and pull requests, too many for us to read properly, so we're closing everything that isn't being worked on right now. Closed here does not mean rejected.
To reopen it takes about two minutes:
/reopen. A check runs and either reopens the issue or lists what is still missing.The rules are in CONTRIBUTING.md.
@As7656431 commented on GitHub (Oct 24, 2026):
/reopen
@github-actions[bot] commented on GitHub (Oct 24, 2026):
Reopened, thank you. A maintainer will pick it up from here.
@Niko1221 commented on GitHub (Nov 5, 2026):
Thanks for taking the time to report this.
Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected.
To reopen it takes about two minutes:
/reopen. A check runs and either reopens the issue or lists what is still missing.The rules are in CONTRIBUTING.md.