[PR #848] [CLOSED] Resident RAM mode with a layer split, --vram-reserve-later-mib (#642) #2868

Closed
opened 2026-11-04 02:03:43 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/848
Author: @Hardin22
Created: 10/4/2026
Status: ❌ Closed

Base: main ← Head: pr/split-resident


📝 Commits (3)

  • b77dfba Layer split: --vram-reserve-later-mib, a separate reserve for the later cards
  • 17794ac Resident RAM mode with a layer split
  • 01c141e setup: the low-RAM mode's resident variant on several GPUs (#642)

📊 Changes

4 files changed (+170 additions, -44 deletions)

View changed files

📝 docs/MULTI_GPU.md (+23 -0)
📝 setup.py (+34 -14)
📝 src/program/generate.cpp (+83 -30)
📝 tools/test_setup_risk.py (+30 -0)

📄 Description

Refs #642. Two of the pieces you listed there as still open: the resident RAM mode on a layer split, and --vram-reserve-later-mib. Three commits, each one reviewable by itself:

  1. --vram-reserve-later-mib N: the reserve of every card after the first (default: --vram-reserve-mib's value), used by the split search and by each later card's cache sizing. The card that drives the monitors needs more headroom than one that drives none.
  2. Resident RAM mode with a layer split (engine). --resident-experts no longer turns into --mmap-experts on a split:
    • the RAM copy leaves out the experts every stage's cache holds, not only CUDA0's;
    • when the rest does not fit whole (#467), it keeps the hottest by the whole profile. Ranked by CUDA0's share alone, it kept only layers 0..K-1 (4.0 GiB in RAM instead of 21.2 below);
    • an adaptive swap copies the evicted expert back from the cache of the card that owns its layer, on that card's stream. host_res holds slot numbers of whichever cache owns the layer, so reading a later stage's slot out of CUDA0's cache put another expert's bytes in RAM, and the answers turned to garbage after the first swaps. This was latent upstream because the guard kept the mode off a split.
    • Remote expert caches are still refused with it.
  3. setup: with an engine that has it, the low-RAM mode on several GPUs takes the resident variant (same rule as on one card) instead of recommending one card. At a start, split_mmap leaves a resident config alone. Gated on MIN_ENGINE >= RESIDENT_SPLIT_ENGINE, which I set to (0, 1, 40) as a guess at the release that would carry it: until then setup behaves as today and the golden configs don't move. Please change the number if it's another release.

Measured

Swift 1.5 IQ3_XXS at 160K (q4_0 KV, --prefill 4096, --spec 4 with the stock draft layer, --pool-workers 15). RTX 4060 Ti (layers 0-19) + RTX 5080 (20-47, display), i9-14900KF, 32 GB of RAM, Windows 11. Four greedy prompts (code, Italian prose, C, English prose), 400 tokens max, decode tok/s averaged over the four:

round 1 round 2 round 3 round 4
upstream 6f32ec0, 5080 alone, --resident-experts 24.8 27.5 27.0 28.8
upstream 6f32ec0, split 20, --mmap-experts (what --resident-experts becomes) 31.9 53.8 64.7 64.0
this PR, split 20, --resident-experts (21.8-22.1 GiB of experts locked in RAM) 70.6 69.1 70.3 69.0

The mmap split catches up once the OS file cache holds the experts, and only because nothing else was running on the PC. The resident copy is there from the first request, and it stays locked when other programs want the RAM.

  • Correctness:
    • With --pcie-frac 0 --adapt-every 0 STRATA_IQ_MT_MIN=1, the split's greedy output is identical to upstream's --mmap-experts on the same split (4/4 prompts, 400 tokens each).
    • With adaptive swaps on, 33 varied requests at temperature 0.6 (thinking on/off, five languages, code, each checked for degenerate output) exchanged 81,783 experts between RAM and the two caches. Every answer was clean.
  • One card: unchanged; same numbers as upstream within noise.
  • --vram-reserve-mib 300 --vram-reserve-later-mib 1800 on the same PC: the 4060 Ti's cache goes from 4551 to 4867 slots (vs --vram-reserve-mib 1000 for both), and the 5080 keeps 1.3 GB free with everything loaded.
  • setup: tools/test_setup_*.py pass (260 tests). Two new tests in test_setup_risk.py run the new paths with MIN_ENGINE patched.

Notes

  • #833 (STRATA_RESIDENT_REMOTE=1) edits the same guard in generate.cpp, so whichever goes second has a small textual conflict there.
  • Not in this PR: the pipelined windows from the fork. They sit on top of this and need more porting onto the batch-slot code. That will be a separate PR.

🔄 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/848 **Author:** [@Hardin22](https://github.com/Hardin22) **Created:** 10/4/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/split-resident` --- ### 📝 Commits (3) - [`b77dfba`](https://github.com/Niko1221/Strata/commit/b77dfbaca610b2d50a51c15700d5445c3bff5500) Layer split: --vram-reserve-later-mib, a separate reserve for the later cards - [`17794ac`](https://github.com/Niko1221/Strata/commit/17794acd68d05f71109a006e06a8799eda2a1577) Resident RAM mode with a layer split - [`01c141e`](https://github.com/Niko1221/Strata/commit/01c141e0d9afbd084164b6acd3293f3057397a0c) setup: the low-RAM mode's resident variant on several GPUs (#642) ### 📊 Changes **4 files changed** (+170 additions, -44 deletions) <details> <summary>View changed files</summary> 📝 `docs/MULTI_GPU.md` (+23 -0) 📝 `setup.py` (+34 -14) 📝 `src/program/generate.cpp` (+83 -30) 📝 `tools/test_setup_risk.py` (+30 -0) </details> ### 📄 Description Refs #642. Two of the pieces you listed there as still open: the resident RAM mode on a layer split, and `--vram-reserve-later-mib`. Three commits, each one reviewable by itself: 1. **`--vram-reserve-later-mib N`**: the reserve of every card after the first (default: `--vram-reserve-mib`'s value), used by the split search and by each later card's cache sizing. The card that drives the monitors needs more headroom than one that drives none. 2. **Resident RAM mode with a layer split** (engine). `--resident-experts` no longer turns into `--mmap-experts` on a split: - the RAM copy leaves out the experts every stage's cache holds, not only CUDA0's; - when the rest does not fit whole (#467), it keeps the hottest by the whole profile. Ranked by CUDA0's share alone, it kept only layers 0..K-1 (4.0 GiB in RAM instead of 21.2 below); - an adaptive swap copies the evicted expert back from the cache of the card that owns its layer, on that card's stream. `host_res` holds slot numbers of whichever cache owns the layer, so reading a later stage's slot out of CUDA0's cache put another expert's bytes in RAM, and the answers turned to garbage after the first swaps. This was latent upstream because the guard kept the mode off a split. - Remote expert caches are still refused with it. 3. **setup**: with an engine that has it, the low-RAM mode on several GPUs takes the resident variant (same rule as on one card) instead of recommending one card. At a start, `split_mmap` leaves a resident config alone. Gated on `MIN_ENGINE >= RESIDENT_SPLIT_ENGINE`, which I set to `(0, 1, 40)` as a guess at the release that would carry it: until then setup behaves as today and the golden configs don't move. Please change the number if it's another release. ## Measured Swift 1.5 IQ3_XXS at 160K (q4_0 KV, `--prefill 4096`, `--spec 4` with the stock draft layer, `--pool-workers 15`). RTX 4060 Ti (layers 0-19) + RTX 5080 (20-47, display), i9-14900KF, 32 GB of RAM, Windows 11. Four greedy prompts (code, Italian prose, C, English prose), 400 tokens max, decode tok/s averaged over the four: | | round 1 | round 2 | round 3 | round 4 | |---|---|---|---|---| | upstream 6f32ec0, 5080 alone, `--resident-experts` | 24.8 | 27.5 | 27.0 | 28.8 | | upstream 6f32ec0, split 20, `--mmap-experts` (what `--resident-experts` becomes) | 31.9 | 53.8 | 64.7 | 64.0 | | this PR, split 20, `--resident-experts` (21.8-22.1 GiB of experts locked in RAM) | 70.6 | 69.1 | 70.3 | 69.0 | The mmap split catches up once the OS file cache holds the experts, and only because nothing else was running on the PC. The resident copy is there from the first request, and it stays locked when other programs want the RAM. - **Correctness**: - With `--pcie-frac 0 --adapt-every 0 STRATA_IQ_MT_MIN=1`, the split's greedy output is identical to upstream's `--mmap-experts` on the same split (4/4 prompts, 400 tokens each). - With adaptive swaps on, 33 varied requests at temperature 0.6 (thinking on/off, five languages, code, each checked for degenerate output) exchanged 81,783 experts between RAM and the two caches. Every answer was clean. - **One card**: unchanged; same numbers as upstream within noise. - **`--vram-reserve-mib 300 --vram-reserve-later-mib 1800`** on the same PC: the 4060 Ti's cache goes from 4551 to 4867 slots (vs `--vram-reserve-mib 1000` for both), and the 5080 keeps 1.3 GB free with everything loaded. - **setup**: `tools/test_setup_*.py` pass (260 tests). Two new tests in `test_setup_risk.py` run the new paths with `MIN_ENGINE` patched. ## Notes - #833 (`STRATA_RESIDENT_REMOTE=1`) edits the same guard in generate.cpp, so whichever goes second has a small textual conflict there. - Not in this PR: the pipelined windows from the fork. They sit on top of this and need more porting onto the batch-slot code. That will be a separate PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 02:03:43 +07:00
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#2868
No description provided.