mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1498] [CLOSED] KV streaming under WSL: pin the K/V host copy with cudaHostRegister #3492
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#3492
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/1498
Author: @yjamil8
Created: 10/8/2026
Status: ❌ Closed
Base:
main← Head:wsl-kv-stream-host-register📝 Commits (1)
79b43beKV streaming under WSL: pin the K/V host copy with cudaHostRegister📊 Changes
1 file changed (+55 additions, -4 deletions)
View changed files
📝
src/core/layer.cpp(+55 -4)📄 Description
Under WSL2 the NVIDIA driver caps what
cudaHostAlloc(Mapped)can pin at about 1 GiB in all. KV streaming allocates each QSA layer's K/V host copy that way (src/core/layer.cpp), so it cannot work under WSL, and setup turns it off there: the whole KV cache has to sit in VRAM beside the expert cache, which limits long contexts on WSL.cudaHostRegisterof ordinary memory is not capped the same way. Strata already relies on that: the expert arena is registeredPortable|Mappedinpinned.cu, and on my WSL machine the start log showsexpert arena: cudaHostRegister PORTABLE okfor 46.84 GiB.This change adds
kv_host_alloc()for the K/V host copy:/dev/dxgexists (WSL2, the same check asunder_wddm()ingenerate.cpp) it maps anonymous memory and registers itPortable|Mappedbefore any page is touched. This also leaves WSL's smallcudaHostAllocbudget to the staging buffers that are still allocated that way;cudaHostAllocstays first;STRATA_KV_HOST_REGISTER=1/=0forces the order;The buffer lives as long as the process, like the
cudaHostAlloccopy it replaces. By inspection, native Linux and Windows behave as before unlesscudaHostAllocis refused; I have not run it there.Tested with this commit on one RTX 5090 (32 GB), Ryzen 9 9950X3D, WSL2 with 157 GiB, Windows driver 591.86, CUDA 13.1, IQ3_S,
--max-context 1048576 --rope-scaling yarn --rope-scale 4 --kv int8 --kv-resident 32768:the host copy is pinnedKV streaming: 32768 of 1048576 cells per QSA layer in VRAM, the K/V in 12.38 GiB of pinned RAM`, with no environment variable settools/needle_bench.py: 4/4 found, 128K and 1M (1,015,070 prompt tokens) at depths 10 and 90Not tested: a layer split or remote experts under WSL (where t3253 applies to the expert arena, not to this copy), Docker Desktop, native Linux, Windows.
Not in this PR:
setup.pystill never writes--kv-residenton WSL (kv_streaming_wam configs there (upgrade_config), so until that changes WSL users have to add--kv-residentby hand, andsetup.py --updateremoves it again. The docs also still say WSL cannot stream. I can add this PR, gated onMIN_ENGINE`, or send it as a follow-up, whichever you prefer.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.