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#4436
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?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/3072
Author: @As7656431
Created: 10/18/2026
Status: 🔄 Open
Base:
main← Head:windows-prompt-direct📝 Commits (3)
2c62621prompt path: STRATA_PROMPT_DIRECT=1 on Windows, also in the low-RAM mode without a RAM budget (#3065)857b57bprompt path: copy blobs already in the working set, read the rest through the file cache (STRATA_PREFILL_DIRECT_RAM, #3065)237d6cbtests: STRATA_PROMPT_DIRECT=1 on a mapped experts.bin - copy_blobs hands out the file's bytes, read unbuffered, copied from the working set or read through the file cache in merged runs (#3065)📊 Changes
5 files changed (+245 additions, -6 deletions)
View changed files
📝
include/strata/core/expert_source.hpp(+11 -1)📝
src/core/expert_source.cpp(+140 -2)📝
src/prefill/prefill.cpp(+9 -3)📝
src/program/generate.cpp(+12 -0)📝
tests/core/file_expert_source_test.cpp(+73 -0)📄 Description
Problem and result
On a Windows PC whose RAM cannot hold the experts, the low-RAM mode (
--mmap-experts, no--resident-budget-gib) reads each prompt chunk's experts by copying them out of the mappedexperts.bin. Those copies are page faults. On this PC (RTX 5070 12 GB, 31.8 GiB RAM, a 35.5 GB IQ2_XSexperts.binon a drive of about 1.5 GB/s) the drive read only 0.2-0.5 GB/s during a long prompt, and the faulted pages push the decode's cached experts out of RAM.STRATA_PROMPT_DIRECT=1already reads the prompt path's blobs unbuffered, but only on Linux and only with a RAM budget.This PR, opt-in and Windows only:
STRATA_PROMPT_DIRECT=1also works on Windows and in the low-RAM mode without a budget: the stager's blobs are read with unbuffered, overlapped reads from a second handle onexperts.bin, while the decode keeps the mapping.STRATA_PREFILL_DIRECT_RAM(on that path only): a blob whose pages are already in the working set is copied from the mapping;=2reads the rest through a cached handle (what the standby list still holds),=3as 2 with neighbouring blobs of a layer merged into one read.With both unset nothing changes. On 0.2.3.1, same PC and settings,
tools/strata_bench.py, medians of 3:7ddc17a3)STRATA_PROMPT_DIRECT=1 STRATA_PREFILL_DIRECT_RAM=3Related discussion
#3065 has the problem, the measurements and the reproduction steps. There is no maintainer reply on scope yet; both switches are opt-in and no default changes. This PR was closed in the 0.2.0-beta reset; it is now rebased on
main(7ddc17a3, v0.2.3.1) and re-tested there. It is independent of #3086; the two merge cleanly together.Approach
open_prompt_directgets a Windows branch: each expert file is opened again withFILE_FLAG_NO_BUFFERING | FILE_FLAG_OVERLAPPED(experts.binonly, and not when the file tier is already unbuffered). WithSTRATA_PREFILL_DIRECT_RAM >= 2it also opens a cached overlapped handle.read_directuses these handles when the tier itself is not unbuffered.copy_blobsalready reads throughpdirect_, as it does on Linux.ExpertSource::prompt_reads()(default false; true on Windows forexperts.binwith those handles open): the stager inprefill.cppthen hands the unpinned blobs tocopy_blobs, 8 at a time.transient()is not touched, so the decode and the prompt path's CPU share behave as before; only where the bytes come from changes.copy_blobswithSTRATA_PREFILL_DIRECT_RAM(Windows,prompt_reads()only) asksQueryWorkingSetExwhich blobs are already in RAM.generate.cppreads the switch in the mmap mode without a budget on Windows only, so Linux keeps its behaviour also with the switch set.test_prompt_direct_mappedintests/core/file_expert_source_test.cpp: a syntheticexperts.bin,open_prompt_direct, thencopy_blobsof 8 blobs, read unbuffered, copied from the working set, and read through the file cache in merged runs, compared byte for byte with the file.Validation
Passed:
-DCMAKE_CUDA_ARCHITECTURES=120 -DSTRATA_PORTABLE=ON:cmake --build build --target strataon857b57b3(this branch before the test commit; that commit touches onlytests/), andcmake --build build --target file_expert_source_testwith-DSTRATA_BUILD_TESTS=ONon237d6cb6(the head). No new kind of compiler warning; a few more C4996 (getenv), as in the code around it.file_expert_source_teston237d6cb6:file_expert_source_test: PASS. The new test printsprompt direct (unbuffered): 7 of 8 blobs read from the file: bytes PASSandprompt direct (file cache, merged): 7 of 8 blobs read from the file: bytes PASS(the eighth blob was copied from the working set). The test also passes on main7ddc17a3, and on this branch merged with #3086.STRATA_DUMP_FIRST_LOGITSafter an 8K document and a 300-token prompt, two runs per build and setting, in one round with main: for each prompt there were two outputs in all, the first choice was the same in every run, and main itself gave both outputs for the 300-token prompt (KL 1.9e-4 between them). This branch gave each output once with the switches unset and once with them set, for both prompts. On the 8K document main's two runs gave the first output; the second differs from it by KL 1.24e-3, which is what the 0.1.45 release showed between two of its own runs of this document.tools/strata_bench.pyof7ddc17a3as the client, againstserve/server.pyof the same commit started separately (--url, andPYTHONUTF8=1for #2792), on the same day with the same settings; only the engine and the two variables differ. The main run is the report in #3063.the prompt path's expert reads go unbuffered (STRATA_PROMPT_DIRECT=1, mmap mode).Failed: none observed.
Not run:
#if defined(_WIN32)) in files that every backend compiles, so the HIP build on Windows compiles it too. I would be glad if someone with a HIP or SYCL setup could build this branch; until then I am leaving it as a draft.STRATA_PROMPT_DIRECT=1on Windows (that combination now opens the handles; before, it was refused as Linux only), the GGUF read in place, other models, contexts above 32K.Limits
read_direct); on this drive they still run near its speed.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.