[GH-ISSUE #2535] [Bug]: Windows: a second NVIDIA GPU halves the largest pinned allocation, so the RAM-budget complement silently falls back to pageable memory (CUDA counterpart of #2485) #1027

Closed
opened 2026-11-04 01:47:51 +07:00 by bsakaguchi · 4 comments
Owner

Originally created by @KLOP09 on GitHub (Oct 15, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/2535

What happened

On Windows, adding a second NVIDIA card (a GTX 1650 that drives no display and is hidden from CUDA with CUDA_VISIBLE_DEVICES=<RTX 5070 UUID>) made the low-RAM resident mode stop page-locking its RAM copy. Same config, same engine, before and after:

# GTX 1650 enabled
FileExpertSource: allocating 14.00 GiB page-locked cache complement
FileExpertSource: locked resident cache complement ready: resident 14.00 GiB, pinned 0.00 GiB; page-locking refused (out of memory); locked 14335 MiB via working-set minimum + VirtualLock

# GTX 1650 disabled in Device Manager (nothing else changed)
FileExpertSource: mapped pinned cache complement ready: resident 14.00 GiB, pinned 14.00 GiB; page-locked and mapped

Cause: the largest single pinned allocation is halved, the total is not. Measured with the CUDA driver API (cuMemHostAlloc, PORTABLE | DEVICEMAP, the same flags as the complement), only the RTX 5070 visible, ~26 GB RAM available:

GTX 1650 enabled GTX 1650 disabled
largest single allocation 7.344 GiB (7.375 fails at once) 14.719 GiB
total held in 0.5 GiB pieces 14.0 GiB 14.5 GiB
4 + 4 + 4 GiB held at once the third one fails —

It looks like two ~7.3 GiB regions instead of one ~14.7 GiB region. Logging out does not change it (7.344 / 14.0 GiB again). With both GPUs visible to CUDA, and with the default flags, 6 GiB is granted and 8 GiB refused, as with only the 5070 visible. Windows reports 15,945 MB of shared GPU memory per adapter (half of 31.1 GB). Before the 1650 went in, a 14 GiB complement was pinned on this PC and a 19.8 GiB one was refused.

Why the engine is hit: on Windows, FileExpertSource::pin_cache_complement (v0.1.44.1, the same file on main today — read, not run) still asks for the whole complement with one cudaHostAlloc(Mapped | Portable). The stepped registration of #1250 is only switched on inside #if defined(__linux__), and STRATA_PARTIAL_PIN registers a single prefix. So with the default settings the whole 14 GiB stays pageable, the prompt path streams it through the stager, and the decode's PCIe share is off. STRATA_PIN_BY_NEED is in ArenaExpertSource::open only.

Suggested fix: #2485 does this for the SYCL port (2 GiB chunks, complement_at()), as GgufExpertSource::mirror already does. A CUDA counterpart would fix it here, with two changes for this kind of limit:

  • 2 GiB chunks would reach only about 12 GiB here (three per 7.34 GiB region), so chunks of 1 GiB or less (or one per layer, as the arena does).
  • keep the chunks that were granted, hottest experts first, and lock only the rest, rather than all-or-nothing.

What it costs (0.1.31, Qwen3.8-Flash-Next IQ2_XS, --resident-budget-gib 14, 64K, MTP, the same agentic tasks on two runs, logged in both times)

medians, same task stage complement pageable (1650 on) complement pinned (1650 off)
decode, short-context tasks (replies ≥ 1,000 tokens) 46.5 tok/s 48.0 tok/s
decode, long-context repo tasks 40.2 tok/s 42.2 tok/s
new-session prompt read (8–10K tokens), short-context tasks 229 tok/s 233 tok/s
new-session prompt read (8–10K tokens), repo tasks 230 tok/s 254 tok/s

So pinning is worth 3–5 % in decode and 2–10 % in prompt reading here: modest. The bigger reason is the next part.

Possibly related to #879/#606 (not proven): the all-NaN signature hit twice in the pageable run, 2 of 30 new sessions. Replies were ! only, with the expert-cache hit at 99.1–99.9 % and decode at 74–127 tok/s. In the first event 14 requests in a row each ran to 32,000 tokens, until we stopped the server; the second was cut by a watcher after 61 s. Both times it struck the first request of a new session right after a ~31K-token session ended. That request read its 8.5–9.4K-token prompt from token 0. In the first event a dozen tokens came out normal and then the run collapsed; the fresh prompts that followed (also read from token 0) did the same, so the poisoned state was not only the conversation's K/V. With the complement pinned it was 0 of 233 new sessions before the 1650 went in. A replicate the next morning with the 1650 disabled gave 0 of 28 new sessions, 8 of them right after a ≥ 29K-token session. 2 of 30 against 0 of 28 alone is not significant (one-sided Fisher p ≈ 0.26). Against all pinned runs it is 0 of 261 (p ≈ 0.01, mixed conditions). The second GPU and a Windows update arrived on the same day, but pinned vs. pageable is the one engine-side difference we found.

Workarounds (not yet measured): disable the second card while Strata runs; --resident-budget-gib 7 (fits one region); STRATA_PARTIAL_PIN=1 STRATA_PARTIAL_PIN_GIB=7 (half pinned).

Probe script (Python, ctypes, CUDA driver API)
import ctypes, os
cuda = ctypes.WinDLL('nvcuda.dll'); cuda.cuInit(0)
dev = ctypes.c_int(); cuda.cuDeviceGet(ctypes.byref(dev), 0)
ctx = ctypes.c_void_p(); cuda.cuDevicePrimaryCtxRetain(ctypes.byref(ctx), dev); cuda.cuCtxSetCurrent(ctx)
def alloc(n):
    p = ctypes.c_void_p()
    return p if cuda.cuMemHostAlloc(ctypes.byref(p), ctypes.c_size_t(n), ctypes.c_uint(3)) == 0 else None  # PORTABLE|DEVICEMAP
lo, hi = 1, 16 * 32                      # 1/32 GiB steps
while hi - lo > 1:
    mid = (lo + hi) // 2
    p = alloc(mid * 2 ** 25)
    if p: cuda.cuMemFreeHost(p); lo = mid
    else: hi = mid
held = []
while len(held) < 64:
    p = alloc(2 ** 29)
    if not p: break
    held.append(p)
print(f'largest single allocation {lo/32:.3f} GiB | total in 0.5 GiB pieces {len(held)*0.5:.1f} GiB')
for p in held: cuda.cuMemFreeHost(p)

Strata version, GPU, OS

0.1.31 (the code path above is the same in v0.1.44.1 / main) · RTX 5070 12 GB (PCIe 5.0 x16) + GTX 1650 4 GB (PCIe 3.0 x4, no display, hidden from CUDA) · Windows 11 Pro 26H2 build 26300.9711 · NVIDIA 617.14 · HAGS on · Ryzen 7 9800X3D · 32 GB

Originally created by @KLOP09 on GitHub (Oct 15, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/2535 ### What happened On Windows, adding a second NVIDIA card (a GTX 1650 that drives no display and is hidden from CUDA with `CUDA_VISIBLE_DEVICES=<RTX 5070 UUID>`) made the low-RAM resident mode stop page-locking its RAM copy. Same config, same engine, before and after: ``` # GTX 1650 enabled FileExpertSource: allocating 14.00 GiB page-locked cache complement FileExpertSource: locked resident cache complement ready: resident 14.00 GiB, pinned 0.00 GiB; page-locking refused (out of memory); locked 14335 MiB via working-set minimum + VirtualLock # GTX 1650 disabled in Device Manager (nothing else changed) FileExpertSource: mapped pinned cache complement ready: resident 14.00 GiB, pinned 14.00 GiB; page-locked and mapped ``` **Cause: the largest single pinned allocation is halved, the total is not.** Measured with the CUDA driver API (`cuMemHostAlloc`, `PORTABLE | DEVICEMAP`, the same flags as the complement), only the RTX 5070 visible, ~26 GB RAM available: | | GTX 1650 enabled | GTX 1650 disabled | |---|---|---| | largest single allocation | **7.344 GiB** (7.375 fails at once) | **14.719 GiB** | | total held in 0.5 GiB pieces | 14.0 GiB | 14.5 GiB | | 4 + 4 + 4 GiB held at once | the third one fails | — | It looks like two ~7.3 GiB regions instead of one ~14.7 GiB region. Logging out does not change it (7.344 / 14.0 GiB again). With both GPUs visible to CUDA, and with the `default` flags, 6 GiB is granted and 8 GiB refused, as with only the 5070 visible. Windows reports 15,945 MB of shared GPU memory per adapter (half of 31.1 GB). Before the 1650 went in, a 14 GiB complement was pinned on this PC and a 19.8 GiB one was refused. **Why the engine is hit:** on Windows, `FileExpertSource::pin_cache_complement` (v0.1.44.1, the same file on main today — read, not run) still asks for the whole complement with one `cudaHostAlloc(Mapped | Portable)`. The stepped registration of #1250 is only switched on inside `#if defined(__linux__)`, and `STRATA_PARTIAL_PIN` registers a single prefix. So with the default settings the whole 14 GiB stays pageable, the prompt path streams it through the stager, and the decode's PCIe share is off. `STRATA_PIN_BY_NEED` is in `ArenaExpertSource::open` only. **Suggested fix:** #2485 does this for the SYCL port (2 GiB chunks, `complement_at()`), as `GgufExpertSource::mirror` already does. A CUDA counterpart would fix it here, with two changes for this kind of limit: - 2 GiB chunks would reach only about 12 GiB here (three per 7.34 GiB region), so chunks of 1 GiB or less (or one per layer, as the arena does). - keep the chunks that were granted, hottest experts first, and lock only the rest, rather than all-or-nothing. ### What it costs (0.1.31, Qwen3.8-Flash-Next IQ2_XS, `--resident-budget-gib 14`, 64K, MTP, the same agentic tasks on two runs, logged in both times) | medians, same task stage | complement pageable (1650 on) | complement pinned (1650 off) | |---|---|---| | decode, short-context tasks (replies ≥ 1,000 tokens) | 46.5 tok/s | 48.0 tok/s | | decode, long-context repo tasks | 40.2 tok/s | 42.2 tok/s | | new-session prompt read (8–10K tokens), short-context tasks | 229 tok/s | 233 tok/s | | new-session prompt read (8–10K tokens), repo tasks | 230 tok/s | 254 tok/s | So pinning is worth 3–5 % in decode and 2–10 % in prompt reading here: modest. The bigger reason is the next part. **Possibly related to #879/#606 (not proven):** the all-NaN signature hit twice in the pageable run, 2 of 30 new sessions. Replies were `!` only, with the expert-cache hit at 99.1–99.9 % and decode at 74–127 tok/s. In the first event 14 requests in a row each ran to 32,000 tokens, until we stopped the server; the second was cut by a watcher after 61 s. Both times it struck the first request of a new session right after a ~31K-token session ended. That request read its 8.5–9.4K-token prompt from token 0. In the first event a dozen tokens came out normal and then the run collapsed; the fresh prompts that followed (also read from token 0) did the same, so the poisoned state was not only the conversation's K/V. With the complement pinned it was 0 of 233 new sessions before the 1650 went in. A replicate the next morning with the 1650 disabled gave 0 of 28 new sessions, 8 of them right after a ≥ 29K-token session. 2 of 30 against 0 of 28 alone is not significant (one-sided Fisher p ≈ 0.26). Against all pinned runs it is 0 of 261 (p ≈ 0.01, mixed conditions). The second GPU and a Windows update arrived on the same day, but pinned vs. pageable is the one engine-side difference we found. **Workarounds (not yet measured):** disable the second card while Strata runs; `--resident-budget-gib 7` (fits one region); `STRATA_PARTIAL_PIN=1 STRATA_PARTIAL_PIN_GIB=7` (half pinned). <details><summary>Probe script (Python, ctypes, CUDA driver API)</summary> ```python import ctypes, os cuda = ctypes.WinDLL('nvcuda.dll'); cuda.cuInit(0) dev = ctypes.c_int(); cuda.cuDeviceGet(ctypes.byref(dev), 0) ctx = ctypes.c_void_p(); cuda.cuDevicePrimaryCtxRetain(ctypes.byref(ctx), dev); cuda.cuCtxSetCurrent(ctx) def alloc(n): p = ctypes.c_void_p() return p if cuda.cuMemHostAlloc(ctypes.byref(p), ctypes.c_size_t(n), ctypes.c_uint(3)) == 0 else None # PORTABLE|DEVICEMAP lo, hi = 1, 16 * 32 # 1/32 GiB steps while hi - lo > 1: mid = (lo + hi) // 2 p = alloc(mid * 2 ** 25) if p: cuda.cuMemFreeHost(p); lo = mid else: hi = mid held = [] while len(held) < 64: p = alloc(2 ** 29) if not p: break held.append(p) print(f'largest single allocation {lo/32:.3f} GiB | total in 0.5 GiB pieces {len(held)*0.5:.1f} GiB') for p in held: cuda.cuMemFreeHost(p) ``` </details> ### Strata version, GPU, OS 0.1.31 (the code path above is the same in v0.1.44.1 / main) · RTX 5070 12 GB (PCIe 5.0 x16) + GTX 1650 4 GB (PCIe 3.0 x4, no display, hidden from CUDA) · Windows 11 Pro 26H2 build 26300.9711 · NVIDIA 617.14 · HAGS on · Ryzen 7 9800X3D · 32 GB
Author
Owner

@KLOP09 commented on GitHub (Oct 15, 2026):

Follow-up with the second GPU enabled again. Same PC, same 0.1.31 engine and config, one server start per setting. Short probe: 1 warm-up, 2 reads of a 17,937-token prompt, 2 generations of 400 tokens.

setting complement (engine log) prompt read tok/s decode tok/s
default, --resident-budget-gib 14 pinned 0 (page-locking refused) 356.7, 354.8 42.9, 55.0
STRATA_PARTIAL_PIN=1 STRATA_PARTIAL_PIN_GIB=7 pinned 7.00 GiB (the hottest half) + 7 GiB locked 366.2, 364.0 47.1, 54.1
--resident-budget-gib 7 7.00 GiB, all of it pinned 313.8, 290.1 34.9, 42.1
FileExpertSource: mapped pinned cache complement ready: resident 14.00 GiB, pinned 7.00 GiB; page-locking refused (out of memory); 7.00 GiB of it registered for the GPU (the hottest); locked 7168 MiB via working-set minimum + VirtualLock
  • With the 1650 enabled, STRATA_PARTIAL_PIN_GIB=7 registers a 7 GiB prefix without trouble. That makes it the usable workaround on this machine today. It is no slower than the default, and a little faster in this probe; with two samples the decode spread is wide.
  • Halving the budget so the complement fits one region costs more than it gains: −15 % prompt read and −21 % decode, because half the RAM tier goes back to the SSD.
  • Not known yet: whether the partial pin also avoids the #879-like corruption, since the other 7 GiB still goes through the pageable path. A long run with this setting is in progress, on the same tasks as the two runs above. I'll add the result here.
<!-- gh-comment-id:6183473061 --> @KLOP09 commented on GitHub (Oct 15, 2026): Follow-up with the second GPU enabled again. Same PC, same 0.1.31 engine and config, one server start per setting. Short probe: 1 warm-up, 2 reads of a 17,937-token prompt, 2 generations of 400 tokens. | setting | complement (engine log) | prompt read tok/s | decode tok/s | |---|---|---|---| | default, `--resident-budget-gib 14` | pinned 0 (page-locking refused) | 356.7, 354.8 | 42.9, 55.0 | | `STRATA_PARTIAL_PIN=1 STRATA_PARTIAL_PIN_GIB=7` | pinned 7.00 GiB (the hottest half) + 7 GiB locked | 366.2, 364.0 | 47.1, 54.1 | | `--resident-budget-gib 7` | 7.00 GiB, all of it pinned | 313.8, 290.1 | 34.9, 42.1 | ``` FileExpertSource: mapped pinned cache complement ready: resident 14.00 GiB, pinned 7.00 GiB; page-locking refused (out of memory); 7.00 GiB of it registered for the GPU (the hottest); locked 7168 MiB via working-set minimum + VirtualLock ``` - With the 1650 enabled, `STRATA_PARTIAL_PIN_GIB=7` registers a 7 GiB prefix without trouble. That makes it the usable workaround on this machine today. It is no slower than the default, and a little faster in this probe; with two samples the decode spread is wide. - Halving the budget so the complement fits one region costs more than it gains: −15 % prompt read and −21 % decode, because half the RAM tier goes back to the SSD. - Not known yet: whether the partial pin also avoids the #879-like corruption, since the other 7 GiB still goes through the pageable path. A long run with this setting is in progress, on the same tasks as the two runs above. I'll add the result here.
Author
Owner

@KLOP09 commented on GitHub (Oct 15, 2026):

Long-run result with the partial pin, as promised. Same 0.1.31 config and the same task set each time: 12 agentic runs, 12 repo runs and 4 high-effort runs, roughly 3 hours, with a fresh server for each stage.

run complement new sessions hit by the all-! corruption of those sessions, right after a ≥ 29K-token one decode median, short / repo tasks
1650 enabled, default pageable (pinned 0) 2 of 30 2 of 9 46.5 / 40.2 tok/s
1650 disabled, default pinned 14 GiB 0 of 28 0 of 8 48.0 / 42.2 tok/s
1650 enabled, STRATA_PARTIAL_PIN=1 STRATA_PARTIAL_PIN_GIB=7 pinned 7 GiB + 7 GiB locked 0 of 28 0 of 12 49.2 / 43.5 tok/s
  • With the partial pin, task results were the same or better than with the pageable complement: 10/12, 12/12 and 4/4, against 9/12, 12/12 and 3/4.
  • So on this machine the partial pin is a usable stopgap. It is as fast as full pinning, and none of its 28 new sessions was corrupted.
  • The statistics are still thin. 2/30 against 0/28 gives a one-sided Fisher p ≈ 0.26. Against every pinned run on this PC, 0/289, it is p ≈ 0.009, but with mixed conditions.
  • The commit headroom was tighter with the partial pin: 826 MB at the lowest point, against 1.9 GB fully pinned.

Related reports from my search for a driver-side fix. I found none: nobody reports a setting that changes this limit.

So with a second NVIDIA card installed, an engine-side split still looks like the only fix without a loss: chunks of 1 GiB or less, keeping whatever is granted.

<!-- gh-comment-id:6185859720 --> @KLOP09 commented on GitHub (Oct 15, 2026): Long-run result with the partial pin, as promised. Same 0.1.31 config and the same task set each time: 12 agentic runs, 12 repo runs and 4 high-effort runs, roughly 3 hours, with a fresh server for each stage. | run | complement | new sessions hit by the all-`!` corruption | of those sessions, right after a ≥ 29K-token one | decode median, short / repo tasks | |---|---|---|---|---| | 1650 enabled, default | pageable (pinned 0) | 2 of 30 | 2 of 9 | 46.5 / 40.2 tok/s | | 1650 disabled, default | pinned 14 GiB | 0 of 28 | 0 of 8 | 48.0 / 42.2 tok/s | | 1650 enabled, `STRATA_PARTIAL_PIN=1 STRATA_PARTIAL_PIN_GIB=7` | pinned 7 GiB + 7 GiB locked | 0 of 28 | 0 of 12 | 49.2 / 43.5 tok/s | - With the partial pin, task results were the same or better than with the pageable complement: 10/12, 12/12 and 4/4, against 9/12, 12/12 and 3/4. - So on this machine the partial pin is a usable stopgap. It is as fast as full pinning, and none of its 28 new sessions was corrupted. - The statistics are still thin. 2/30 against 0/28 gives a one-sided Fisher p ≈ 0.26. Against every pinned run on this PC, 0/289, it is p ≈ 0.009, but with mixed conditions. - The commit headroom was tighter with the partial pin: 826 MB at the lowest point, against 1.9 GB fully pinned. Related reports from my search for a driver-side fix. I found none: nobody reports a setting that changes this limit. - NVIDIA forum, 2021: the largest pinnable buffer shrinks with the number of installed GPUs (8 × RTX 3090: about 6 GB). https://forums.developer.nvidia.com/t/max-amount-of-host-pinned-memory-available-for-allocation/56053 - NVIDIA forum, 2022: NVIDIA's answer is that the limit is managed by Windows. In the same thread, a single allocation of 15,402 MiB was the largest on a 32 GB system. https://forums.developer.nvidia.com/t/change-limit-of-50-for-cudahostalloc-pinned-memory-on-windows-10-11/228235 - ComfyUI #15255 (open since 2026-08): host-memory failures that reproduce only with several GPUs initialized. ComfyUI now forces single-GPU mode on Windows "due to a Nvidia related issue" unless told otherwise. https://github.com/Comfy-Org/ComfyUI/issues/15255 So with a second NVIDIA card installed, an engine-side split still looks like the only fix without a loss: chunks of 1 GiB or less, keeping whatever is granted.
Author
Owner

@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:

  1. Re-test on 0.2.0-beta. It may already be fixed. Write down what you see.
  2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other].
  3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system.
  4. Comment /reopen. A check runs and either reopens the issue or lists what is still missing.

The rules are in CONTRIBUTING.md.

<!-- gh-comment-id:6271106337 --> @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: 1. Re-test on 0.2.0-beta. It may already be fixed. Write down what you see. 2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other]. 3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system. 4. Comment `/reopen`. A check runs and either reopens the issue or lists what is still missing. The rules are in [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md).
Author
Owner

@thestigma commented on GitHub (Oct 31, 2026):

Closing note with fresh measurements: the 'halved largest pinned allocation' on a 2-GPU box is the per-allocation ceiling of the shared non-local pool — on a 64 GiB RAM desktop with two NVIDIA cards the DXGI NON_LOCAL budget is 47268 MiB and cumulative 1-GiB pins reach 45.0 GiB, while a SINGLE cudaHostAlloc/cudaHostRegister fails at 24 GiB and succeeds at 23 even with 58 GiB free RAM (one global pool, per-allocation cap ≈ half of it). Stock 0.1.55 hits exactly this: 'allocating 23.24 GiB page-locked cache complement -> page-locking refused -> trying pageable memory' with ~22 GiB of pool still free. PR #4860 adds an opt-in sliced-registration path (STRATA_RESIDENT_PIN_MODE=register) that keeps each call under the ceiling and pins the full complement (verified: '43 slices pinned (20 GiB); locked 2518 MiB via working-set minimum + VirtualLock').

<!-- gh-comment-id:6550022448 --> @thestigma commented on GitHub (Oct 31, 2026): Closing note with fresh measurements: the 'halved largest pinned allocation' on a 2-GPU box is the per-allocation ceiling of the shared non-local pool — on a 64 GiB RAM desktop with two NVIDIA cards the DXGI NON_LOCAL budget is 47268 MiB and cumulative 1-GiB pins reach 45.0 GiB, while a SINGLE cudaHostAlloc/cudaHostRegister fails at 24 GiB and succeeds at 23 even with 58 GiB free RAM (one global pool, per-allocation cap ≈ half of it). Stock 0.1.55 hits exactly this: 'allocating 23.24 GiB page-locked cache complement -> page-locking refused -> trying pageable memory' with ~22 GiB of pool still free. PR #4860 adds an opt-in sliced-registration path (STRATA_RESIDENT_PIN_MODE=register) that keeps each call under the ceiling and pins the full complement (verified: '43 slices pinned (20 GiB); locked 2518 MiB via working-set minimum + VirtualLock').
Sign in to join this conversation.
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
Niko1221/Strata#1027
No description provided.