[PR #4808] [Engine] register the partial-pin prefix in slices on Windows (STRATA_PARTIAL_PIN_SLICED) #5194

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

📋 Pull Request Information

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

Base: main ← Head: pr/partial-pin-sliced


📝 Commits (1)

  • df4c3c9 [Engine] register the partial-pin prefix in slices on Windows (STRATA_PARTIAL_PIN_SLICED)

📊 Changes

3 files changed (+80 additions, -3 deletions)

View changed files

📝 docs/UNSLOTH_Q4.md (+1 -0)
📝 include/strata/core/expert_source.hpp (+2 -0)
📝 src/core/expert_source.cpp (+77 -3)

📄 Description

Problem and result

On Windows the RAM-budget complement (--resident-budget-gib N) is refused by cudaHostAlloc as one block once it passes the driver's single-allocation limit, so it falls back to pageable memory. STRATA_PARTIAL_PIN=1 helps, but it also registers one block: it steps down 2 GiB at a time until the driver accepts. On this PC that stops at ~20 GiB of a 34.7 GiB complement, while the expert arena on the same PC pins 41 GiB in 43 slices of 1 GiB.

With STRATA_PARTIAL_PIN_SLICED=1 (together with STRATA_PARTIAL_PIN=1), the same hottest prefix is registered slice by slice. All 34.73 GiB were registered in 35 slices.

Related discussion

#2535 (closed in the 0.2.0-beta tracker reset, not rejected) measured this limit with two NVIDIA cards and suggested exactly this: slices of 1 GiB or less, keeping the hottest ones granted. This PR is a focused, opt-in fix, so I did not open a new scope issue first; happy to move it to one if you prefer.

Approach

  • Slices of STRATA_PARTIAL_PIN_SLICE_MIB (default 1024). Each is cut at an expert boundary, so a blob never straddles two registrations. It stops at STRATA_PARTIAL_PIN_GIB or at the first refusal.
  • Under WDDM, cudaHostGetDevicePointer on a registered slice does not return its host address. My first version assumed it did and registered nothing. So each slice keeps its own device alias, and FileExpertSource::device_alias() picks the blob's slice with an upper_bound over the slice offsets. This is the same idea as ArenaExpertSource's dev_slice_ and pin_dev_.
  • Teardown (close() and the error-path release) unregisters each slice.
  • Off by default. Without the variable, the code path is byte-for-byte the existing one, and complement_partial_ / pinned() are unchanged: the slices form one contiguous prefix of complement_pin_limit_ bytes.
  • The Linux paced path (#1250) is untouched; this branch is only reached when the registration is not paced.
  • Docs: one row in the docs/UNSLOTH_Q4.md switch table, next to STRATA_PARTIAL_PIN.

Validation

Environment:

  • Windows 11 Pro 26200, NVIDIA 621.01.
  • RTX 3090 24 GB (PCIe 4.0 x8, the engine's GPU, "gpu": [1]) + RTX 3080 10 GB (drives the display, unused by Strata).
  • Ryzen 5 3600XT, 64 GB DDR4.
  • Model: Qwen3.8-Flash-Next GSQ-RCO IQ3_S, MTP draft.
  • Flags: --resident-budget-gib 35 --conversation-cache-mib 1536 --max-context 262144 --kv int8 --kv-resident 32768 --spec 4 --vram-reserve-later-mib 1000, plus STRATA_STAGE_TRIM=1 STRATA_KV_PREFETCH=1 STRATA_CACHE_MESSAGE_BOUNDARY=1.
  • Revision: v0.2.9 + this patch. Engine built from source with CUDA 13.3, MSVC 14.50, -DCMAKE_CUDA_ARCHITECTURES=86 -DSTRATA_BUILD_TESTS=OFF.

Speed: my own script, not the benchmark protocol, run through serve/server.py's OpenAI endpoint.

  • Decode: 3 fixed prompts (code / prose / chat), temperature 0.
  • Prompt reads: fresh 4K / 16K / 32K-token prompts with a unique prefix, so no cache reuse.
  • 2 runs each, medians shown. A fresh server for each row, one start per row.
Engine STRATA_PARTIAL_PIN_* Registered Decode code / prose / chat (tok/s) Prompt 4K / 16K / 32K (tok/s)
official 0.1.55 =1, _GIB=34 20.00 GiB, one block 77.2 / 79.0 / 78.2 1013 / 1668 / 1835
this build =1, _GIB=40, _SLICED=0 20.73 GiB, one block 76.1 / 77.6 / 77.9 1011 / 1661 / 1840
this build =1, _GIB=40, _SLICED=1 34.73 GiB, 35 slices 89.4 / 86.0 / 86.9 1044 / 1705 / 1877
official 0.1.55, expert arena (no budget), for reference n/a 41 GiB, 43 slices 109.8 / 107.8 / 112.0 1048 / 1714 / 1882
  • With all of the complement registered, decode is +12–17 % over the one-block prefix, and prompt reads are +2–3 %, at the level of the full arena.
  • The second row is the same binary with the switch off. It matches the official engine, so the build itself is not the difference.
  • Load time was about the same: 107 s sliced against 113 s one-block.

Passed:

  • CUDA build, Windows, sm_86 (cmake --build build --target strata), no new warnings in the touched file.
  • Hardware run of each row above: the engine log line 34.73 GiB of it registered for the GPU in 35 slices (the hottest), with no errors in the log.
  • Short answer checks at temperature 0 on the sliced build: 17×23 → 391, 12×12 → 144, a correct is_prime, and a coherent French paragraph.

Failed: the first version, with the UVA assumption, registered 0 slices. That is fixed by the per-slice alias above, and the numbers are from the fixed build.

Not run:

  • HIP build (gfx906 / RDNA). The patch only uses cudaHostRegister / cudaHostGetDevicePointer / cudaHostUnregister, which this file already calls, but I have no AMD toolchain. That is why this is a draft.
  • Linux build and run.
  • The test suite (built with tests off).
  • Long agentic sessions. I have not checked the all-! corruption that #2535 associated with pageable complements.
  • Other GPUs or RAM sizes.

Limits

  • Only with a RAM budget and STRATA_PARTIAL_PIN=1, as before.
  • STRATA_PARTIAL_PIN_GIB still caps the prefix (default 24), so it must be raised to cover the whole budget.
  • The speed gain is from one PC and one model. The PCIe share of the misses changes the numerics of those experts, as STRATA_PARTIAL_PIN already does. I am not proposing a default change.

🤖 Generated with Claude Code


🔄 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/4808 **Author:** [@nmqx](https://github.com/nmqx) **Created:** 10/31/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `pr/partial-pin-sliced` --- ### 📝 Commits (1) - [`df4c3c9`](https://github.com/Niko1221/Strata/commit/df4c3c9fa3e8ebb4142ebbbf055e0f0bfea040f7) [Engine] register the partial-pin prefix in slices on Windows (STRATA_PARTIAL_PIN_SLICED) ### 📊 Changes **3 files changed** (+80 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `docs/UNSLOTH_Q4.md` (+1 -0) 📝 `include/strata/core/expert_source.hpp` (+2 -0) 📝 `src/core/expert_source.cpp` (+77 -3) </details> ### 📄 Description **Problem and result** On Windows the RAM-budget complement (`--resident-budget-gib N`) is refused by `cudaHostAlloc` as one block once it passes the driver's single-allocation limit, so it falls back to pageable memory. `STRATA_PARTIAL_PIN=1` helps, but it also registers one block: it steps down 2 GiB at a time until the driver accepts. On this PC that stops at ~20 GiB of a 34.7 GiB complement, while the expert arena on the same PC pins 41 GiB in 43 slices of 1 GiB. With `STRATA_PARTIAL_PIN_SLICED=1` (together with `STRATA_PARTIAL_PIN=1`), the same hottest prefix is registered slice by slice. All 34.73 GiB were registered in 35 slices. **Related discussion** #2535 (closed in the 0.2.0-beta tracker reset, not rejected) measured this limit with two NVIDIA cards and suggested exactly this: slices of 1 GiB or less, keeping the hottest ones granted. This PR is a focused, opt-in fix, so I did not open a new scope issue first; happy to move it to one if you prefer. **Approach** - Slices of `STRATA_PARTIAL_PIN_SLICE_MIB` (default 1024). Each is cut at an expert boundary, so a blob never straddles two registrations. It stops at `STRATA_PARTIAL_PIN_GIB` or at the first refusal. - Under WDDM, `cudaHostGetDevicePointer` on a registered slice does not return its host address. My first version assumed it did and registered nothing. So each slice keeps its own device alias, and `FileExpertSource::device_alias()` picks the blob's slice with an `upper_bound` over the slice offsets. This is the same idea as `ArenaExpertSource`'s `dev_slice_` and `pin_dev_`. - Teardown (`close()` and the error-path `release`) unregisters each slice. - Off by default. Without the variable, the code path is byte-for-byte the existing one, and `complement_partial_` / `pinned()` are unchanged: the slices form one contiguous prefix of `complement_pin_limit_` bytes. - The Linux paced path (#1250) is untouched; this branch is only reached when the registration is not paced. - Docs: one row in the `docs/UNSLOTH_Q4.md` switch table, next to `STRATA_PARTIAL_PIN`. **Validation** Environment: - Windows 11 Pro 26200, NVIDIA 621.01. - RTX 3090 24 GB (PCIe 4.0 x8, the engine's GPU, `"gpu": [1]`) + RTX 3080 10 GB (drives the display, unused by Strata). - Ryzen 5 3600XT, 64 GB DDR4. - Model: Qwen3.8-Flash-Next GSQ-RCO IQ3_S, MTP draft. - Flags: `--resident-budget-gib 35 --conversation-cache-mib 1536 --max-context 262144 --kv int8 --kv-resident 32768 --spec 4 --vram-reserve-later-mib 1000`, plus `STRATA_STAGE_TRIM=1 STRATA_KV_PREFETCH=1 STRATA_CACHE_MESSAGE_BOUNDARY=1`. - Revision: v0.2.9 + this patch. Engine built from source with CUDA 13.3, MSVC 14.50, `-DCMAKE_CUDA_ARCHITECTURES=86 -DSTRATA_BUILD_TESTS=OFF`. Speed: my own script, not the benchmark protocol, run through `serve/server.py`'s OpenAI endpoint. - Decode: 3 fixed prompts (code / prose / chat), temperature 0. - Prompt reads: fresh 4K / 16K / 32K-token prompts with a unique prefix, so no cache reuse. - 2 runs each, medians shown. A fresh server for each row, one start per row. | Engine | `STRATA_PARTIAL_PIN_*` | Registered | Decode code / prose / chat (tok/s) | Prompt 4K / 16K / 32K (tok/s) | | --- | --- | --- | --- | --- | | official 0.1.55 | `=1`, `_GIB=34` | 20.00 GiB, one block | 77.2 / 79.0 / 78.2 | 1013 / 1668 / 1835 | | this build | `=1`, `_GIB=40`, `_SLICED=0` | 20.73 GiB, one block | 76.1 / 77.6 / 77.9 | 1011 / 1661 / 1840 | | this build | `=1`, `_GIB=40`, `_SLICED=1` | **34.73 GiB, 35 slices** | **89.4 / 86.0 / 86.9** | **1044 / 1705 / 1877** | | official 0.1.55, expert arena (no budget), for reference | n/a | 41 GiB, 43 slices | 109.8 / 107.8 / 112.0 | 1048 / 1714 / 1882 | - With all of the complement registered, decode is +12–17 % over the one-block prefix, and prompt reads are +2–3 %, at the level of the full arena. - The second row is the same binary with the switch off. It matches the official engine, so the build itself is not the difference. - Load time was about the same: 107 s sliced against 113 s one-block. Passed: - CUDA build, Windows, sm_86 (`cmake --build build --target strata`), no new warnings in the touched file. - Hardware run of each row above: the engine log line `34.73 GiB of it registered for the GPU in 35 slices (the hottest)`, with no errors in the log. - Short answer checks at temperature 0 on the sliced build: 17×23 → 391, 12×12 → 144, a correct `is_prime`, and a coherent French paragraph. Failed: the first version, with the UVA assumption, registered 0 slices. That is fixed by the per-slice alias above, and the numbers are from the fixed build. Not run: - HIP build (gfx906 / RDNA). The patch only uses `cudaHostRegister` / `cudaHostGetDevicePointer` / `cudaHostUnregister`, which this file already calls, but I have no AMD toolchain. **That is why this is a draft.** - Linux build and run. - The test suite (built with tests off). - Long agentic sessions. I have not checked the all-`!` corruption that #2535 associated with pageable complements. - Other GPUs or RAM sizes. **Limits** - Only with a RAM budget and `STRATA_PARTIAL_PIN=1`, as before. - `STRATA_PARTIAL_PIN_GIB` still caps the prefix (default 24), so it must be raised to cover the whole budget. - The speed gain is from one PC and one model. The PCIe share of the misses changes the numerics of those experts, as `STRATA_PARTIAL_PIN` already does. I am not proposing a default change. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <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#5194
No description provided.