[GH-ISSUE #147] Windows: CUDA page-locking caps the RAM tier at ~90 GB per process - RAM-resident mode cannot start (32 GB card, 192 GB RAM, 128K ctx) #50

Open
opened 2026-10-29 21:19:46 +07:00 by bsakaguchi · 4 comments
Owner

Originally created by @gmanzienko on GitHub (Oct 12, 2026).
Original GitHub issue: https://github.com/mw00/project-maya/issues/147

Windows: the CUDA page-locking cap (~90 GB/process) starves the RAM tier; RAM-resident mode cannot start on a 32 GB card with 192 GB RAM

v1.1.3, Windows 11, one RTX 5090 32 GB (sm_120, CUDA toolkit 12.8, driver 617.14), Ryzen 9 9950X3D, 192 GB RAM, page file fixed 40 GB (per #20 - thank you, that warning was spot on), Maya-L, 131072 context, DFlash2 drafter.

What happens

The engine pins only 84-91 GB of RAM tier no matter how much is free (155-170 GB), while Maya-L at 128K needs about 125 GB off-VRAM. The rest of the experts are served from the SSD (10-16 disk reads/token):

glm fast: CUDA0 RAM tier 84.23 GB pinned, 7511 slots
glm fast: CUDA0 tiers warm: 8991 experts (107.9 GB) in 13 s (8.05 GB/s)
glm stat: decode 327.08 ms/tok (3.06 tok/s) | ... | disk 12.93 reads/tok in 15.48 waits/tok, 16.32 ms/tok

RAM-resident mode then fails at startup:

glm fast: --glm-ram-resident: the RAM tier cannot hold every non-VRAM expert (class 1: 5681 of 9632 slots pinned; raise STRATA_GLM_RAM_GB, its headroom, or lower --max-context)

This happens with STRATA_GLM_RAM_GB=130, with STRATA_GLM_NUMA=0, with 165 GB free RAM and 201 GB of free commit, and also when the whole process tree is launched outside my shell (via WMI), so it is not an environment or job artifact.

Diagnostics: where the cap actually is

  1. The tier allocation goes through cudaHostAlloc(cudaHostAllocPortable) per class (numa_pinned is Linux-only). Standalone repro on the same PC: allocating and page-locking 110 GB with plain VirtualAlloc + VirtualLock (after SetProcessWorkingSetSize with the minimum raised by the region size - the same thing lock_resident does) succeeds, so the OS is fine with 125+ GB locked per process.
  2. But cudaHostRegister over such a locked 110 GB region fails with cudaErrorMemoryAllocation (out of memory), and in-engine cudaHostAlloc refuses the class blobs past roughly 90 GB - the retry loop walks 9632 slots down to 5681. So BOTH driver paths (cudaHostAlloc and cudaHostRegister) cap out around 90 GB per process under WDDM, well below the physical RAM.
  3. There is also this line, which may matter for the sizing on a single-socket desktop:
glm fast: CUDA0 the RAM tier sits on node 0 of 2 seen

A 9950X3D is a single socket; Windows reports one NUMA node. "2 seen" looks like processor groups being mistaken for NUMA nodes, and if the tier is then sized or placed against node 0 only, that alone would explain the 84-91 GB ceiling even before the driver cap.

An experiment that gets the tier pinned but then trips an IMA

As a working-tree experiment I added a third fallback in the glm_fast_path.cu tier loop: when numa_pinned and cudaHostAlloc both refuse, allocate with plain VirtualAlloc(MEM_RESERVE|MEM_COMMIT) and pin it with strata::platform::lock_resident (opt-out env STRATA_GLM_OS_LOCK=0). Result at startup:

glm fast: CUDA0 class 1: cudaHostAlloc refused 104.6 GB - locked plain memory instead (locked 107156 MiB via working-set minimum + VirtualLock)
glm fast: CUDA0 RAM tier 132.20 GB pinned, 11912 slots
glm fast: CUDA0 RAM-resident mode: every non-VRAM expert gets a slot (+16 slack/layer); disk evictions are OFF
glm fast: CUDA0 tiers warm: 12096 experts (144.1 GB) in 18 s (7.92 GB/s)
glm fast: CUDA0 RAM-resident verified: all 12096 experts are in VRAM or pinned RAM

Generation then stops after 2-3 tokens with:

{"error": {"type": "invalid_request_error", "message": "glm lending copies: an illegal memory access was encountered"}}

which is the cudaStreamSynchronize(F->copy) check in lend_tail (glm_prefill.cu) - the background tier moves and lending copies evidently assume the tier base is driver page-locked (cudaHostAlloc or registered), and plain VirtualLock-ed memory breaks that assumption somewhere. So a real fix likely wants the lending and promotion DMA paths audited for unregistered-but-locked host memory (or an explicit partial-registration scheme), which is beyond a safe local patch - hence this report.

Current workaround

Auto-sized tier (84 GB) + STRATA_GLM_DISK_SKIP_W=0.12 keeps the 128K-context setup usable (decode ~3 tok/s here, cache still warming), and everything else (DFlash2, vision) runs fine.

Happy to test candidate fixes; the standalone VirtualLock and cudaHostRegister repro is a 20-line program I can share.

Originally created by @gmanzienko on GitHub (Oct 12, 2026). Original GitHub issue: https://github.com/mw00/project-maya/issues/147 # Windows: the CUDA page-locking cap (~90 GB/process) starves the RAM tier; RAM-resident mode cannot start on a 32 GB card with 192 GB RAM v1.1.3, Windows 11, one RTX 5090 32 GB (sm_120, CUDA toolkit 12.8, driver 617.14), Ryzen 9 9950X3D, 192 GB RAM, page file fixed 40 GB (per #20 - thank you, that warning was spot on), Maya-L, 131072 context, DFlash2 drafter. ## What happens The engine pins only 84-91 GB of RAM tier no matter how much is free (155-170 GB), while Maya-L at 128K needs about 125 GB off-VRAM. The rest of the experts are served from the SSD (10-16 disk reads/token): ``` glm fast: CUDA0 RAM tier 84.23 GB pinned, 7511 slots glm fast: CUDA0 tiers warm: 8991 experts (107.9 GB) in 13 s (8.05 GB/s) glm stat: decode 327.08 ms/tok (3.06 tok/s) | ... | disk 12.93 reads/tok in 15.48 waits/tok, 16.32 ms/tok ``` RAM-resident mode then fails at startup: ``` glm fast: --glm-ram-resident: the RAM tier cannot hold every non-VRAM expert (class 1: 5681 of 9632 slots pinned; raise STRATA_GLM_RAM_GB, its headroom, or lower --max-context) ``` This happens with STRATA_GLM_RAM_GB=130, with STRATA_GLM_NUMA=0, with 165 GB free RAM and 201 GB of free commit, and also when the whole process tree is launched outside my shell (via WMI), so it is not an environment or job artifact. ## Diagnostics: where the cap actually is 1. The tier allocation goes through cudaHostAlloc(cudaHostAllocPortable) per class (numa_pinned is Linux-only). Standalone repro on the same PC: allocating and page-locking 110 GB with plain VirtualAlloc + VirtualLock (after SetProcessWorkingSetSize with the minimum raised by the region size - the same thing lock_resident does) succeeds, so the OS is fine with 125+ GB locked per process. 2. But cudaHostRegister over such a locked 110 GB region fails with cudaErrorMemoryAllocation (out of memory), and in-engine cudaHostAlloc refuses the class blobs past roughly 90 GB - the retry loop walks 9632 slots down to 5681. So BOTH driver paths (cudaHostAlloc and cudaHostRegister) cap out around 90 GB per process under WDDM, well below the physical RAM. 3. There is also this line, which may matter for the sizing on a single-socket desktop: ``` glm fast: CUDA0 the RAM tier sits on node 0 of 2 seen ``` A 9950X3D is a single socket; Windows reports one NUMA node. "2 seen" looks like processor groups being mistaken for NUMA nodes, and if the tier is then sized or placed against node 0 only, that alone would explain the 84-91 GB ceiling even before the driver cap. ## An experiment that gets the tier pinned but then trips an IMA As a working-tree experiment I added a third fallback in the glm_fast_path.cu tier loop: when numa_pinned and cudaHostAlloc both refuse, allocate with plain VirtualAlloc(MEM_RESERVE|MEM_COMMIT) and pin it with strata::platform::lock_resident (opt-out env STRATA_GLM_OS_LOCK=0). Result at startup: ``` glm fast: CUDA0 class 1: cudaHostAlloc refused 104.6 GB - locked plain memory instead (locked 107156 MiB via working-set minimum + VirtualLock) glm fast: CUDA0 RAM tier 132.20 GB pinned, 11912 slots glm fast: CUDA0 RAM-resident mode: every non-VRAM expert gets a slot (+16 slack/layer); disk evictions are OFF glm fast: CUDA0 tiers warm: 12096 experts (144.1 GB) in 18 s (7.92 GB/s) glm fast: CUDA0 RAM-resident verified: all 12096 experts are in VRAM or pinned RAM ``` Generation then stops after 2-3 tokens with: ``` {"error": {"type": "invalid_request_error", "message": "glm lending copies: an illegal memory access was encountered"}} ``` which is the cudaStreamSynchronize(F->copy) check in lend_tail (glm_prefill.cu) - the background tier moves and lending copies evidently assume the tier base is driver page-locked (cudaHostAlloc or registered), and plain VirtualLock-ed memory breaks that assumption somewhere. So a real fix likely wants the lending and promotion DMA paths audited for unregistered-but-locked host memory (or an explicit partial-registration scheme), which is beyond a safe local patch - hence this report. ## Current workaround Auto-sized tier (84 GB) + STRATA_GLM_DISK_SKIP_W=0.12 keeps the 128K-context setup usable (decode ~3 tok/s here, cache still warming), and everything else (DFlash2, vision) runs fine. Happy to test candidate fixes; the standalone VirtualLock and cudaHostRegister repro is a 20-line program I can share.
Author
Owner

@gmanzienko commented on GitHub (Oct 12, 2026):

Follow-up: with the same VirtualAlloc + lock_resident fallback enabled as an experiment, an AUTO-sized tier (124.74 GB pinned, no RAM-resident flag) also trips the identical "glm lending copies: an illegal memory access" at the first prompt - so the lending/promotion copies on the copy stream require driver page-locked (cudaHostAlloc/registered) tier memory in every mode, not just RAM-resident. The fallback is therefore opt-in (STRATA_GLM_OS_LOCK=1) in my tree and disabled by default; the report above stands. Anything the maintainers want tested on this machine (driver page-locking caps, the node-0-of-2 NUMA detection, candidate copy-path fixes) - happy to run it.

<!-- gh-comment-id:6134843834 --> @gmanzienko commented on GitHub (Oct 12, 2026): Follow-up: with the same VirtualAlloc + lock_resident fallback enabled as an experiment, an AUTO-sized tier (124.74 GB pinned, no RAM-resident flag) also trips the identical "glm lending copies: an illegal memory access" at the first prompt - so the lending/promotion copies on the copy stream require driver page-locked (cudaHostAlloc/registered) tier memory in every mode, not just RAM-resident. The fallback is therefore opt-in (STRATA_GLM_OS_LOCK=1) in my tree and disabled by default; the report above stands. Anything the maintainers want tested on this machine (driver page-locking caps, the node-0-of-2 NUMA detection, candidate copy-path fixes) - happy to run it.
Author
Owner

@uvtzxpm commented on GitHub (Oct 13, 2026):

I think I'm also hitting this. Windows, an NVIDIA 3090 24 GB. I have "only" 64 GB RAM and no matter what I try, ~25 GB RAM is free while running this, with ~"21.4 GB pinned for experts". Testing with github.com/mw00/project-maya@f4d13e1293.

<!-- gh-comment-id:6137461375 --> @uvtzxpm commented on GitHub (Oct 13, 2026): I think I'm also hitting this. Windows, an NVIDIA 3090 24 GB. I have "only" 64 GB RAM and no matter what I try, ~25 GB RAM is free while running this, with ~"21.4 GB pinned for experts". Testing with https://github.com/mw00/project-maya/commit/f4d13e1293a88f6cc0fdf0d0a666aeb5caa9edb6.
Author
Owner

@mw00 commented on GitHub (Oct 13, 2026):

Thank you - an exceptionally clear diagnosis, and the standalone repro settles where the cap is.

What you found matches the engine:

  • The cap is the driver's, for both cudaHostAlloc and cudaHostRegister. STRATA_GLM_RAM_GB and the NUMA settings can't move it.
  • The illegal memory access with VirtualLock-ed memory is expected, unfortunately. Parts of the engine have the GPU read the RAM tier directly, not only through copies, and that works only on memory the driver has page-locked. Memory locked by the OS alone is fine for the CPU, not for the GPU.
  • the RAM tier sits on node 0 of 2 seen doesn't count NUMA nodes: "2 seen" is the number of RAM-tier blocks (one per expert size) whose node could be read, all on node 0. It doesn't size or place anything, so it isn't behind the ~90 GB. We'll reword it.

Where this could go: RAM above the cap can still serve experts without the GPU reading it - through the CPU lane, which computes experts from RAM on the CPU, or copied through a small pinned buffer, the way disk reads land today. That's a real change to the tiers, so it's on our list rather than a quick patch, and we'd like your machine to test it when there's a build. Until then, the auto-sized tier with STRATA_GLM_DISK_SKIP_W is the best setup on that PC, as you found.

@uvtzxpm: with 64 GB of RAM you're more likely hitting a different limit. Windows charges pinned memory to the commit limit (RAM + page file), and the engine sizes the tier from what's left of it. If your engine log has a line starting glm fast: WARNING - Windows' commit limit, enlarging the page file by what it says should let the tier grow (see #20). If not, please post the log's glm fast: lines and we'll look.

<!-- gh-comment-id:6147949322 --> @mw00 commented on GitHub (Oct 13, 2026): Thank you - an exceptionally clear diagnosis, and the standalone repro settles where the cap is. **What you found matches the engine:** - **The cap is the driver's**, for both `cudaHostAlloc` and `cudaHostRegister`. `STRATA_GLM_RAM_GB` and the NUMA settings can't move it. - **The illegal memory access with VirtualLock-ed memory** is expected, unfortunately. Parts of the engine have the GPU read the RAM tier directly, not only through copies, and that works only on memory the driver has page-locked. Memory locked by the OS alone is fine for the CPU, not for the GPU. - **`the RAM tier sits on node 0 of 2 seen`** doesn't count NUMA nodes: "2 seen" is the number of RAM-tier blocks (one per expert size) whose node could be read, all on node 0. It doesn't size or place anything, so it isn't behind the ~90 GB. We'll reword it. **Where this could go:** RAM above the cap can still serve experts without the GPU reading it - through the CPU lane, which computes experts from RAM on the CPU, or copied through a small pinned buffer, the way disk reads land today. That's a real change to the tiers, so it's on our list rather than a quick patch, and we'd like your machine to test it when there's a build. Until then, the auto-sized tier with `STRATA_GLM_DISK_SKIP_W` is the best setup on that PC, as you found. @uvtzxpm: with 64 GB of RAM you're more likely hitting a different limit. Windows charges pinned memory to the commit limit (RAM + page file), and the engine sizes the tier from what's left of it. If your engine log has a line starting `glm fast: WARNING - Windows' commit limit`, enlarging the page file by what it says should let the tier grow (see #20). If not, please post the log's `glm fast:` lines and we'll look.
Author
Owner

@mw00 commented on GitHub (Oct 13, 2026):

A small part of this is in v1.1.7: the "node 0 of 2 seen" line is gone on single-socket PCs, and where Windows refuses a size the tier is now sized to what still pins instead of stepping down. Using the RAM above the ~90 GB cap is still on our list.

<!-- gh-comment-id:6154921984 --> @mw00 commented on GitHub (Oct 13, 2026): A small part of this is in [v1.1.7](https://github.com/mw00/project-maya/releases/tag/v1.1.7): the "node 0 of 2 seen" line is gone on single-socket PCs, and where Windows refuses a size the tier is now sized to what still pins instead of stepping down. Using the RAM above the ~90 GB cap is still on our list.
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mw00/project-maya#50
No description provided.