[PR #4860] [Engine] resident: register the complement slice by slice on WDDM (opt-in STRATA_RESIDENT_PIN_MODE=register) #5218

Open
opened 2026-11-07 16:33:33 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4860
Author: @thestigma
Created: 10/31/2026
Status: 🔄 Open

Base: main ← Head: pr-resident-register


📝 Commits (1)

  • fea1c56 [Engine] resident: register the complement slice by slice on WDDM (opt-in STRATA_RESIDENT_PIN_MODE=register) + STRATA_KV_HOST_REGISTER on Windows + a fully registered complement is not partial

📊 Changes

3 files changed (+123 additions, -6 deletions)

View changed files

📝 include/strata/core/expert_source.hpp (+3 -0)
📝 src/core/expert_source.cpp (+82 -5)
📝 src/core/layer.cpp (+38 -1)

📄 Description

Problem. --resident-experts pins the cache complement as ONE cudaHostAlloc(Mapped|Portable) (expert_source.cpp, pin_cache_complement). On Windows two limits bite, and neither is the pool:

  1. A single pinned allocation caps at ~23 GiB regardless of free RAM or pool. Measured on a desktop RTX 3090 Ti + RTX 3090, 64 GiB RAM, Win11 Home, CUDA 13: one-shot cudaHostAlloc and cudaHostRegister succeed at 23 GiB and fail at 24 GiB with 58 GiB RAM free — while cumulative 1-GiB pins reach 45.0 GiB (46.0 fails), exactly the IDXGIAdapter3 NON_LOCAL budget (47268 MiB, one global pool shared by all adapters incl. desktop D3D charges). The folklore "50% of RAM" is this per-allocation ceiling, not a pool rule.
  2. Stock 0.1.55 at a 23.24 GiB complement logs page-locking refused (out of memory); trying pageable memory — silent degradation to CPU staging with ~22 GiB of pool still free.

Related: STRATA_KV_HOST_REGISTER's register arm is compiled out on _WIN32 (layer.cpp) although DETAILS.md promises it on any system; and a fully REGISTERED complement is marked complement_partial_ (the exemption only covered the paced arm), so STRATA_EXCHANGE_ROTATE silently stays off in a registered lane.

Change (opt-in; default path byte-identical). STRATA_RESIDENT_PIN_MODE=register pins the complement through the arena's own PinnedArena with sliced cudaHostRegister — slice bounds at each layer's first complement blob (no blob straddles a boundary), per-slice device aliases (ArenaExpertSource pattern), whole-arena registration aliased too. cudaHostAlloc / malloc+working-set+VirtualLock / STRATA_PARTIAL_PIN arms stay as fallbacks; teardown goes through the PinnedArena. kv_host_alloc honours STRATA_KV_HOST_REGISTER=1 on Windows. complement_partial_ = registered && (partial_pin < bytes).

Validation (measured on the hardware above, engine 0.1.55 + prototype commit):

  • Passed: full pin — resident 14.17 GiB, pinned 14.17 GiB; complement registered slice by slice ... cudaHostRegister PORTABLE ok.
  • Passed: degradation ladder in one load when the single whole-arena registration fails above the ceiling — 43 slices pinned (20 GiB); locked 2518 MiB via working-set minimum + VirtualLock.
  • Passed: token-for-token parity — same binary with and without the env, temp 0, two captures per arm: 4/4 byte-identical; plus 2/3 prompts byte-identical against the stock release build (the third varies across cold loads on ANY build — speculative-decode timing, not the patch).
  • Passed: decode, tool calls and /health on a register-mode lane.
  • Copy rates: queued 1.28 MB H2D 6.25 GB/s registered vs 4.29 GB/s Mapped|Portable (measured 2026-10-24, engine 0.1.48 prototype).
  • Not run: full end-to-end load of a >23 GiB complement (needs a machine with the brain lane stopped), prefill-speed A/B at 0.1.55, Linux/HIP/SYCL (register mode compiles cross-platform but is unmeasured there; default path untouched everywhere).

Limits. Registered bytes still charge the WDDM non-local pool (the existing STRATA_ARENA_PIN_GIB=auto DXGI cap applies); QueryVideoMemoryInfo.CurrentUsage is per-process, so the pin-budget guard cannot see other processes' pins — multi-lane boxes can still exhaust the pool (separate known issue). Opt-ins only; no default behavior changes.

Refs. #243 (sliced pin budget — same mechanism, this extends it to the resident complement), #1237 (stage-buffer pinning, complementary), #1571 (complement working-set spike), #31 (WDDM copy-engine pathology).


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/4860 **Author:** [@thestigma](https://github.com/thestigma) **Created:** 10/31/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `pr-resident-register` --- ### 📝 Commits (1) - [`fea1c56`](https://github.com/Niko1221/Strata/commit/fea1c56982deaaf9ec733ecd55f3842ef22abdea) [Engine] resident: register the complement slice by slice on WDDM (opt-in STRATA_RESIDENT_PIN_MODE=register) + STRATA_KV_HOST_REGISTER on Windows + a fully registered complement is not partial ### 📊 Changes **3 files changed** (+123 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `include/strata/core/expert_source.hpp` (+3 -0) 📝 `src/core/expert_source.cpp` (+82 -5) 📝 `src/core/layer.cpp` (+38 -1) </details> ### 📄 Description **Problem.** `--resident-experts` pins the cache complement as ONE `cudaHostAlloc(Mapped|Portable)` (`expert_source.cpp`, `pin_cache_complement`). On Windows two limits bite, and neither is the pool: 1. A single pinned allocation caps at ~23 GiB regardless of free RAM or pool. Measured on a desktop RTX 3090 Ti + RTX 3090, 64 GiB RAM, Win11 Home, CUDA 13: one-shot `cudaHostAlloc` and `cudaHostRegister` succeed at 23 GiB and fail at 24 GiB with 58 GiB RAM free — while cumulative 1-GiB pins reach 45.0 GiB (46.0 fails), exactly the `IDXGIAdapter3` NON_LOCAL budget (47268 MiB, one global pool shared by all adapters incl. desktop D3D charges). The folklore "50% of RAM" is this per-allocation ceiling, not a pool rule. 2. Stock 0.1.55 at a 23.24 GiB complement logs `page-locking refused (out of memory); trying pageable memory` — silent degradation to CPU staging with ~22 GiB of pool still free. Related: `STRATA_KV_HOST_REGISTER`'s register arm is compiled out on `_WIN32` (`layer.cpp`) although DETAILS.md promises it on any system; and a fully REGISTERED complement is marked `complement_partial_` (the exemption only covered the paced arm), so `STRATA_EXCHANGE_ROTATE` silently stays off in a registered lane. **Change (opt-in; default path byte-identical).** `STRATA_RESIDENT_PIN_MODE=register` pins the complement through the arena's own `PinnedArena` with sliced `cudaHostRegister` — slice bounds at each layer's first complement blob (no blob straddles a boundary), per-slice device aliases (ArenaExpertSource pattern), whole-arena registration aliased too. `cudaHostAlloc` / malloc+working-set+`VirtualLock` / `STRATA_PARTIAL_PIN` arms stay as fallbacks; teardown goes through the `PinnedArena`. `kv_host_alloc` honours `STRATA_KV_HOST_REGISTER=1` on Windows. `complement_partial_ = registered && (partial_pin < bytes)`. **Validation (measured on the hardware above, engine 0.1.55 + prototype commit):** - Passed: full pin — `resident 14.17 GiB, pinned 14.17 GiB; complement registered slice by slice ... cudaHostRegister PORTABLE ok`. - Passed: degradation ladder in one load when the single whole-arena registration fails above the ceiling — `43 slices pinned (20 GiB); locked 2518 MiB via working-set minimum + VirtualLock`. - Passed: token-for-token parity — same binary with and without the env, temp 0, two captures per arm: 4/4 byte-identical; plus 2/3 prompts byte-identical against the stock release build (the third varies across cold loads on ANY build — speculative-decode timing, not the patch). - Passed: decode, tool calls and `/health` on a register-mode lane. - Copy rates: queued 1.28 MB H2D 6.25 GB/s registered vs 4.29 GB/s `Mapped|Portable` (measured 2026-10-24, engine 0.1.48 prototype). - Not run: full end-to-end load of a >23 GiB complement (needs a machine with the brain lane stopped), prefill-speed A/B at 0.1.55, Linux/HIP/SYCL (register mode compiles cross-platform but is unmeasured there; default path untouched everywhere). **Limits.** Registered bytes still charge the WDDM non-local pool (the existing `STRATA_ARENA_PIN_GIB=auto` DXGI cap applies); `QueryVideoMemoryInfo.CurrentUsage` is per-process, so the pin-budget guard cannot see other processes' pins — multi-lane boxes can still exhaust the pool (separate known issue). Opt-ins only; no default behavior changes. **Refs.** #243 (sliced pin budget — same mechanism, this extends it to the resident complement), #1237 (stage-buffer pinning, complementary), #1571 (complement working-set spike), #31 (WDDM copy-engine pathology). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#5218
No description provided.