[PR #2968] [Engine] prompt path: experts staged from the resident arena keep the full streamed ring and 8 copy threads (unpinned 32K +5-19%); STRATA_ARENA_PIN_GIB=none #4369

Open
opened 2026-11-07 15:35:13 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/2968
Author: @sergqwer
Created: 10/17/2026
Status: 🔄 Open

Base: main ← Head: pr/unpinned-staging


📝 Commits (1)

  • 2681789 prompt path: experts staged from the resident arena keep the full streamed ring and get 8 copy threads, 64 buffers; STRATA_ARENA_PIN_GIB=none

📊 Changes

5 files changed (+49 additions, -10 deletions)

View changed files

📝 include/strata/core/pinned.hpp (+2 -1)
📝 include/strata/prefill/prefill.hpp (+3 -0)
📝 src/core/pinned.cu (+5 -0)
📝 src/prefill/prefill.cpp (+31 -5)
📝 src/program/generate.cpp (+8 -4)

📄 Description

Problem and result

Some experts the GPU cannot DMA directly: the arena's pin is capped or refused (a multi-GPU run under WDDM, which caps it at 8 GiB by default, STRATA_ARENA_PIN_GIB, the remainder STRATA_PIN_BY_NEED leaves). The prompt path's stager copies these into pinned buffers and DMAs them from there. When more than 10% of the bytes are unpinned, the streamed ring is cut to a quarter (96 slots) and the stager keeps 4 copy threads and 16 buffers. The 96 slots were measured where the host copies were the limit (file reads, IQ3_S on a 64 GB PC). From the expert arena these copies are plain memcpy from resident RAM, so the small ring only slows the prompt.

  • Before (main e88ee39d), a 32K prompt read with nothing pinned: 3086 / 3289 tok/s at the default 8K chunks, 5774 / 5808 with --prefill auto:32768; with an 8 GiB pin (88% not pinned) 3393 / 3286.
  • After: 3096 / 3565 (+4.5%), 6858 / 6898 (+18.8%, 98% of the fully pinned arena's 6998), and 3760 / 3791 (+13%). 2K prompts stay RAM-bound (-1 to -2.5%). A fully pinned arena (the one-GPU default) and the low-RAM file tier are unchanged.

None beyond this PR. It was #2968 before the 0.2.0-beta tracker reset, unchanged except for the rebase. It changes no output and no default on one GPU (the arena is pinned whole there); on a multi-GPU Windows run, whose arena pin is capped by default, it changes the staging sizes as measured below.

Approach

  • When the unpinned source is the arena (Prefill::set_resident_stage, set where the engine sets the pinned share): the ring keeps its pinned size (384, or 1024 fused), and the stager gets max(4, min(8, CPUs/4)) threads and 64 buffers.
  • Unchanged: the low-RAM file tier, and a fully pinned arena.
  • Overrides: STRATA_STAGE_RESIDENT=0 restores the old sizing, =1 forces the new one; STRATA_STAGER_THREADS, STRATA_STAGER_RING and STRATA_PREFILL_RING still take precedence.
  • One log line: prefill: 100% of the expert bytes are not pinned: the stager copies them from resident RAM with 8 threads into 64 pinned buffers (169 MiB) and the streamed ring keeps its pinned size ....
  • STRATA_ARENA_PIN_GIB=none pins nothing: the unpinned arm by name. 0 keeps meaning "the whole arena", as documented; until now nothing pinned needed a 1 GiB cap below a layer's 1.32 GiB slice. none is a one-byte cap, so no slice is registered; the arena stays resident through the working-set lock or its large pages.
  • VRAM: no new device allocation. The larger ring is borrowed from the expert cache during a prompt and refilled after it, as today: unpinned, a prompt borrows 288 more slots (~0.74 GiB of NVFP4 blobs; with --no-prefill-borrow that stays reserved). Pinned host memory: 64 stage buffers = 169 MiB, up from 16.

Validation

Revision: this branch, one commit 2681789b on main e88ee39d (v0.2.0-beta + 12 commits), against a build of main e88ee39d with the same configure. RTX 5090 (PCIe 5), Ryzen 9 9950X3D, 128 GB DDR5 (dual channel), Windows 11; MSVC 2022 17.14, CUDA 13.3, release configure (-DSTRATA_PORTABLE=ON, 75-real;86-real;89-real;120-real, ggml at the pinned 3cf03257). Model: the NVFP4 GPTQ pack (Maximilian228/Qwen3.8-Flash-Next-NVFP4-GPTQ-Strata, upstream setup's --family nvfp4 --model NVFP4 files).

Passed:

  • Identity with the default whole-arena pin: strata --serve with setup's model files plus --expert-cache 3000 --prefill auto --spec 6 --spec-min-p 0.7 --max-context 262144 --kv int8 --gpu 0 --pcie-frac 0 --adapt-every 1000000, env STRATA_PREFILL_CPU_SHARE=0 STRATA_PCIE_BALANCE=0 STRATA_IQ_MT_MIN=1 STRATA_DUMP_FIRST_LOGITS=<file>; a 2,100-token and a 32,037-token prompt, 32 greedy tokens each: first-token logits and tokens byte-identical to main's (2K 1e9c612c2e6c7a32..., 4 tokens; 32K f5b2872c7ac30b17..., 20 tokens).

  • Prompt speed. One GPU, strata --serve with setup's model files plus --expert-cache auto --vram-reserve-mib 2048 --prefill auto --spec 6 --spec-min-p 0.7 --max-context 262144 --kv int8 (at the default 700 MiB reserve the cache filled the card and WDDM paged in an earlier batch). Each start reads a 32K prompt twice and a 2K prompt three times, each fresh (a distinct first token); prompt tok/s from the engine's prompt ... read in line. "Nothing pinned" is STRATA_ARENA_PIN_GIB=1 on main (no 1.32 GiB slice fits, 0 slices pinned) and =none on this branch. Two starts per arm, the order alternating:

    arm (2 starts each) main 32K, 1st / 2nd read this branch 32K, 1st / 2nd read main 2K this branch 2K
    nothing pinned 2941 / 3086, 3270 / 3289 3016 / 3096, 3489 / 3565 836-978 (mean 914) 806-948 (mean 891)
    8 GiB pinned (88% not pinned) 3307 / 3393, 3085 / 3286 3669 / 3760, 3721 / 3791 993-1040 (1016) 1010-1033 (1022)
    all pinned (the unchanged path, 1 start each) 6157 / 6415 6161 / 6396 1898-1939 1898-1937
    nothing pinned, --prefill auto:32768 5324 / 5774, 5339 / 5808 6281 / 6858, 6293 / 6898 967-976 (972) 947-963 (959)
    all pinned, --prefill auto:32768 (main, 1 start) 6586 / 6998 - 1895-1932 -
    • Mean of the second 32K reads, main -> this branch: nothing pinned +4.5% (the first pair +0.3%, the second +8.4%), 8 GiB +13.1%, nothing pinned with 32K chunks +18.8%. Unpinned with 32K chunks went from 83% to 98% of the pinned arena.
    • 2K: -2.5% nothing pinned, +0.7% at 8 GiB, -1.3% with 32K chunks: RAM-bound, within the spread of the starts.
    • The prompt path borrows 288 more cache slots unpinned (1615 instead of 1327 at 8K chunks, 5118 instead of 4829 at 32K); the expert cache's auto size was 6989-7014 slots in both builds.

Failed: none observed.

Not run:

  • A real multi-GPU PC under WDDM (one card here); the unpinned arms are forced with STRATA_ARENA_PIN_GIB.
  • STRATA_PIN_BY_NEED with a partial pin.
  • HIP and Metal builds: both compile prefill.cpp, pinned.cu and generate.cpp; no ROCm or Mac here. SYCL keeps its own copies (unchanged).

Limits

  • At the default 8K chunks each chunk streams every expert again, and a staged byte crosses DRAM three times (read, write, the DMA's read), so the gain is smaller there than with 32K chunks. 2K prompts stay RAM-bound.
  • Earlier, on our fork's 0.1.43.1 code (32K prompt chunks by default there; RTX 5090, same PC): nothing pinned 6065-6434 -> 7402-7965 tok/s at 32K. A rented RTX 4090 (Linux, PCIe 4, DDR4), nothing pinned: 32K 3153 -> 4363, 2K 554 -> 824; that run also had the fork's Linux fix that moves the stager's copy threads off the host CPU, which is not part of this PR.

🤖 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/2968 **Author:** [@sergqwer](https://github.com/sergqwer) **Created:** 10/17/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `pr/unpinned-staging` --- ### 📝 Commits (1) - [`2681789`](https://github.com/Niko1221/Strata/commit/2681789bcf6051eefe2ee2dc319f5bf817ccd6d4) prompt path: experts staged from the resident arena keep the full streamed ring and get 8 copy threads, 64 buffers; STRATA_ARENA_PIN_GIB=none ### 📊 Changes **5 files changed** (+49 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `include/strata/core/pinned.hpp` (+2 -1) 📝 `include/strata/prefill/prefill.hpp` (+3 -0) 📝 `src/core/pinned.cu` (+5 -0) 📝 `src/prefill/prefill.cpp` (+31 -5) 📝 `src/program/generate.cpp` (+8 -4) </details> ### 📄 Description ## Problem and result Some experts the GPU cannot DMA directly: the arena's pin is capped or refused (a multi-GPU run under WDDM, which caps it at 8 GiB by default, `STRATA_ARENA_PIN_GIB`, the remainder `STRATA_PIN_BY_NEED` leaves). The prompt path's stager copies these into pinned buffers and DMAs them from there. When more than 10% of the bytes are unpinned, the streamed ring is cut to a quarter (96 slots) and the stager keeps 4 copy threads and 16 buffers. The 96 slots were measured where the host copies were the limit (file reads, IQ3_S on a 64 GB PC). From the expert arena these copies are plain memcpy from resident RAM, so the small ring only slows the prompt. - Before (`main` e88ee39d), a 32K prompt read with nothing pinned: 3086 / 3289 tok/s at the default 8K chunks, 5774 / 5808 with `--prefill auto:32768`; with an 8 GiB pin (88% not pinned) 3393 / 3286. - After: 3096 / 3565 (+4.5%), 6858 / 6898 (+18.8%, 98% of the fully pinned arena's 6998), and 3760 / 3791 (+13%). 2K prompts stay RAM-bound (-1 to -2.5%). A fully pinned arena (the one-GPU default) and the low-RAM file tier are unchanged. ## Related discussion None beyond this PR. It was #2968 before the 0.2.0-beta tracker reset, unchanged except for the rebase. It changes no output and no default on one GPU (the arena is pinned whole there); on a multi-GPU Windows run, whose arena pin is capped by default, it changes the staging sizes as measured below. ## Approach - When the unpinned source is the arena (`Prefill::set_resident_stage`, set where the engine sets the pinned share): the ring keeps its pinned size (384, or 1024 fused), and the stager gets max(4, min(8, CPUs/4)) threads and 64 buffers. - Unchanged: the low-RAM file tier, and a fully pinned arena. - Overrides: `STRATA_STAGE_RESIDENT=0` restores the old sizing, `=1` forces the new one; `STRATA_STAGER_THREADS`, `STRATA_STAGER_RING` and `STRATA_PREFILL_RING` still take precedence. - One log line: `prefill: 100% of the expert bytes are not pinned: the stager copies them from resident RAM with 8 threads into 64 pinned buffers (169 MiB) and the streamed ring keeps its pinned size ...`. - `STRATA_ARENA_PIN_GIB=none` pins nothing: the unpinned arm by name. `0` keeps meaning "the whole arena", as documented; until now nothing pinned needed a 1 GiB cap below a layer's 1.32 GiB slice. `none` is a one-byte cap, so no slice is registered; the arena stays resident through the working-set lock or its large pages. - VRAM: no new device allocation. The larger ring is borrowed from the expert cache during a prompt and refilled after it, as today: unpinned, a prompt borrows 288 more slots (~0.74 GiB of NVFP4 blobs; with `--no-prefill-borrow` that stays reserved). Pinned host memory: 64 stage buffers = 169 MiB, up from 16. ## Validation Revision: this branch, one commit 2681789b on `main` **e88ee39d** (v0.2.0-beta + 12 commits), against a build of `main` e88ee39d with the same configure. RTX 5090 (PCIe 5), Ryzen 9 9950X3D, 128 GB DDR5 (dual channel), Windows 11; MSVC 2022 17.14, CUDA 13.3, release configure (`-DSTRATA_PORTABLE=ON`, `75-real;86-real;89-real;120-real`, ggml at the pinned 3cf03257). Model: the NVFP4 GPTQ pack (`Maximilian228/Qwen3.8-Flash-Next-NVFP4-GPTQ-Strata`, upstream setup's `--family nvfp4 --model NVFP4` files). **Passed:** - **Identity** with the default whole-arena pin: `strata --serve` with setup's model files plus `--expert-cache 3000 --prefill auto --spec 6 --spec-min-p 0.7 --max-context 262144 --kv int8 --gpu 0 --pcie-frac 0 --adapt-every 1000000`, env `STRATA_PREFILL_CPU_SHARE=0 STRATA_PCIE_BALANCE=0 STRATA_IQ_MT_MIN=1 STRATA_DUMP_FIRST_LOGITS=<file>`; a 2,100-token and a 32,037-token prompt, 32 greedy tokens each: first-token logits and tokens byte-identical to `main`'s (2K `1e9c612c2e6c7a32...`, 4 tokens; 32K `f5b2872c7ac30b17...`, 20 tokens). - **Prompt speed.** One GPU, `strata --serve` with setup's model files plus `--expert-cache auto --vram-reserve-mib 2048 --prefill auto --spec 6 --spec-min-p 0.7 --max-context 262144 --kv int8` (at the default 700 MiB reserve the cache filled the card and WDDM paged in an earlier batch). Each start reads a 32K prompt twice and a 2K prompt three times, each fresh (a distinct first token); prompt tok/s from the engine's `prompt ... read in` line. "Nothing pinned" is `STRATA_ARENA_PIN_GIB=1` on `main` (no 1.32 GiB slice fits, 0 slices pinned) and `=none` on this branch. Two starts per arm, the order alternating: | arm (2 starts each) | `main` 32K, 1st / 2nd read | this branch 32K, 1st / 2nd read | `main` 2K | this branch 2K | | --- | --- | --- | --- | --- | | nothing pinned | 2941 / 3086, 3270 / 3289 | 3016 / 3096, 3489 / 3565 | 836-978 (mean 914) | 806-948 (mean 891) | | 8 GiB pinned (88% not pinned) | 3307 / 3393, 3085 / 3286 | 3669 / 3760, 3721 / 3791 | 993-1040 (1016) | 1010-1033 (1022) | | all pinned (the unchanged path, 1 start each) | 6157 / 6415 | 6161 / 6396 | 1898-1939 | 1898-1937 | | nothing pinned, `--prefill auto:32768` | 5324 / 5774, 5339 / 5808 | 6281 / 6858, 6293 / 6898 | 967-976 (972) | 947-963 (959) | | all pinned, `--prefill auto:32768` (`main`, 1 start) | 6586 / 6998 | - | 1895-1932 | - | - Mean of the second 32K reads, `main` -> this branch: nothing pinned +4.5% (the first pair +0.3%, the second +8.4%), 8 GiB +13.1%, nothing pinned with 32K chunks +18.8%. Unpinned with 32K chunks went from 83% to 98% of the pinned arena. - 2K: -2.5% nothing pinned, +0.7% at 8 GiB, -1.3% with 32K chunks: RAM-bound, within the spread of the starts. - The prompt path borrows 288 more cache slots unpinned (1615 instead of 1327 at 8K chunks, 5118 instead of 4829 at 32K); the expert cache's auto size was 6989-7014 slots in both builds. **Failed:** none observed. **Not run:** - A real multi-GPU PC under WDDM (one card here); the unpinned arms are forced with `STRATA_ARENA_PIN_GIB`. - `STRATA_PIN_BY_NEED` with a partial pin. - HIP and Metal builds: both compile `prefill.cpp`, `pinned.cu` and `generate.cpp`; no ROCm or Mac here. SYCL keeps its own copies (unchanged). ## Limits - At the default 8K chunks each chunk streams every expert again, and a staged byte crosses DRAM three times (read, write, the DMA's read), so the gain is smaller there than with 32K chunks. 2K prompts stay RAM-bound. - Earlier, on our fork's 0.1.43.1 code (32K prompt chunks by default there; RTX 5090, same PC): nothing pinned 6065-6434 -> 7402-7965 tok/s at 32K. A rented RTX 4090 (Linux, PCIe 4, DDR4), nothing pinned: 32K 3153 -> 4363, 2K 554 -> 824; that run also had the fork's Linux fix that moves the stager's copy threads off the host CPU, which is not part of this PR. 🤖 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#4369
No description provided.