[PR #5258] [CLOSED] [Engine] split engine: optional per-pool floor for expert residency (FNX_POOL_MIN_RESIDENT) #5367

Closed
opened 2026-11-07 16:34:41 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/5258
Author: @nabe2030
Created: 11/4/2026
Status: ❌ Closed

Base: main ← Head: pool-floor


📝 Commits (2)

  • 3196594 split: add FNX_POOL_MIN_RESIDENT, an optional per-pool floor in choose_residency() (default off = unchanged)
  • f8db072 docs: SPLIT_ENGINE.md: when the split engine or the layer split is faster, by answer length

📊 Changes

2 files changed (+27 additions, -0 deletions)

View changed files

📝 docs/SPLIT_ENGINE.md (+6 -0)
📝 src/split/src/model.cpp (+21 -0)

📄 Description

Problem and result

On a mixed-quantization file (here Qwen3.8-Flash-Next IQ3_S) the all-cards split engine cannot start when part of the routed experts live in host memory (FNX_EXPERT_RAM_GIB, or the engine's own "VRAM short" loop). choose_residency() moves the coldest experts per byte to RAM first. The experts of different layers have different sizes and fall into 7 size pools; the expert cache needs 2*MAXT*TOPK (320) slots in every pool. The cold-first order empties the smallest pool (pool 3, 3 layers, 1,536 experts) and place_experts() throws expert cache: pool 3 has 235 slots, a window needs 320 (fewer experts in RAM). On two 16 GB cards this happened for every FNX_EXPERT_RAM_GIB from 12 up (reproduced), and the 3 GiB default runs out of VRAM instead.

With FNX_POOL_MIN_RESIDENT=N a pool never drops below N resident experts: its next-coldest expert stays in VRAM. Default 0 = unchanged. With N=384, FNX_ARENA=1 FNX_EXPERT_RAM_GIB=20 on 2x RTX 4060 Ti 16 GB the engine loads (17,502 of 24,576 experts in RAM) and runs.

Niko1221/Strata#5187. A commenter there supported sending the floor as its own PR, default off. This PR contains only the floor (one code change plus a documentation paragraph). The launcher/env-switch changes discussed in the issue are not part of it.

Approach

  • One new environment variable, read in Model::choose_residency(). Pools are keyed by the layer's gate+up and down expert byte sizes, which is what the expert cache keys its pools on (up to 16-byte padding). The tensors it reads for the key are the ones the function already reads a few lines earlier.
  • The "VRAM short" loop goes through the same function, so the floor applies there too.
  • A non-numeric or negative value throws a one-line error. Unset or 0: the skip test is never true, so the same experts are moved in the same order as before.
  • docs/SPLIT_ENGINE.md: one paragraph describing the variable, and a second short section with the measured crossover between the split engine and the layer split by answer length (about 730 generated tokens per request on the two-card 16 GB box; the number is specific to that box and one run each). It is in a separate commit.
  • If the cards are too small for the cache and the floor together, the start fails later with an ordinary out-of-memory error (seen at FNX_EXPERT_RAM_GIB 12 and 16 on this box); the floor does not make smaller cards fit.

Validation

Passed:

  • Hardware run (RTX 4060 Ti 16 GB x2, Linux, CUDA 13.4, sm_89, IQ3_S, --spec 6 --lookup 15 --batch 1 --max-context 8192): an engine built from v0.2.10 plus this model.cpp change loads with FNX_ARENA=1 FNX_EXPERT_RAM_GIB=20 FNX_POOL_MIN_RESIDENT=384 in about 100 s, then ran 200 ShareGPT requests (concurrency 1) and the 2,309 JamC-QA items without a failed request; short-prompt decode was 50 to 60 tok/s. Higher FNX_EXPERT_RAM_GIB values (up to 30) also load.
  • Same box, floor not applied (FNX_POOL_MIN_RESIDENT unset), FNX_EXPERT_RAM_GIB 12 and 24: pool 3 has 235 / 113 slots, a window needs 320.
  • python -m pytest tests/split on this branch rebased onto main (9f7d977): 65 passed (the same 65 on main, which has grown since the first version of this PR).

Failed:

  • With the floor on and a smaller FNX_EXPERT_RAM_GIB: 12 fails later at cudaMalloc of 810 MiB on card 0: out of memory (MTP buffers, 5997 of 24576 in RAM), 16 fails at prefill: cudaMalloc of 20 MiB ... out of memory. This is plain VRAM shortage, no longer the pool error. With the floor the "pool P has K slots" placement error is gone and the failure moves to where it belongs; that is the behaviour I would expect from the floor: it is a placement rule, not a memory budget, so cards that are too small still fail, but with an ordinary out-of-memory message instead of a placement exception.

Not run:

  • The tested binary was built from v0.2.10 with the same model.cpp change (identical code). I did not rebuild this exact branch commit after rebasing onto the current main; the rebase conflicted only in docs/SPLIT_ENGINE.md and model.cpp merged without changes.
  • HIP and SYCL builds (the change is in shared src/split C++ with no backend-specific code, but it was not compiled for them).
  • A file with a single quantization type (one pool) and a comparison of outputs with the variable unset against an unpatched build. The reasoning that the default path is unchanged comes from the code, not from a byte-for-byte comparison.
  • Starting through strata launch: the launcher refuses this case on stock main (experts do not fit in VRAM), so the engine was started directly from a server run config.

Limits

  • N=384 worked on this box; it is 320 + margin, not a tuned value.
  • Only one model and one quantization were tried. The effect on files where all experts fit in VRAM should be none, since no expert is moved to RAM there.

🔄 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/5258 **Author:** [@nabe2030](https://github.com/nabe2030) **Created:** 11/4/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pool-floor` --- ### 📝 Commits (2) - [`3196594`](https://github.com/Niko1221/Strata/commit/31965949ae0d61e29a561183587485bdc4ee1c21) split: add FNX_POOL_MIN_RESIDENT, an optional per-pool floor in choose_residency() (default off = unchanged) - [`f8db072`](https://github.com/Niko1221/Strata/commit/f8db072c3f8803a92aa382f2ce166be45e11460d) docs: SPLIT_ENGINE.md: when the split engine or the layer split is faster, by answer length ### 📊 Changes **2 files changed** (+27 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `docs/SPLIT_ENGINE.md` (+6 -0) 📝 `src/split/src/model.cpp` (+21 -0) </details> ### 📄 Description ## Problem and result On a mixed-quantization file (here Qwen3.8-Flash-Next IQ3_S) the all-cards split engine cannot start when part of the routed experts live in host memory (`FNX_EXPERT_RAM_GIB`, or the engine's own "VRAM short" loop). `choose_residency()` moves the coldest experts per byte to RAM first. The experts of different layers have different sizes and fall into 7 size pools; the expert cache needs `2*MAXT*TOPK` (320) slots in every pool. The cold-first order empties the smallest pool (pool 3, 3 layers, 1,536 experts) and `place_experts()` throws `expert cache: pool 3 has 235 slots, a window needs 320 (fewer experts in RAM)`. On two 16 GB cards this happened for every `FNX_EXPERT_RAM_GIB` from 12 up (reproduced), and the 3 GiB default runs out of VRAM instead. With `FNX_POOL_MIN_RESIDENT=N` a pool never drops below N resident experts: its next-coldest expert stays in VRAM. Default 0 = unchanged. With `N=384`, `FNX_ARENA=1 FNX_EXPERT_RAM_GIB=20` on 2x RTX 4060 Ti 16 GB the engine loads (17,502 of 24,576 experts in RAM) and runs. ## Related discussion Niko1221/Strata#5187. A commenter there supported sending the floor as its own PR, default off. This PR contains only the floor (one code change plus a documentation paragraph). The launcher/env-switch changes discussed in the issue are not part of it. ## Approach - One new environment variable, read in `Model::choose_residency()`. Pools are keyed by the layer's gate+up and down expert byte sizes, which is what the expert cache keys its pools on (up to 16-byte padding). The tensors it reads for the key are the ones the function already reads a few lines earlier. - The "VRAM short" loop goes through the same function, so the floor applies there too. - A non-numeric or negative value throws a one-line error. Unset or 0: the skip test is never true, so the same experts are moved in the same order as before. - `docs/SPLIT_ENGINE.md`: one paragraph describing the variable, and a second short section with the measured crossover between the split engine and the layer split by answer length (about 730 generated tokens per request on the two-card 16 GB box; the number is specific to that box and one run each). It is in a separate commit. - If the cards are too small for the cache and the floor together, the start fails later with an ordinary out-of-memory error (seen at `FNX_EXPERT_RAM_GIB` 12 and 16 on this box); the floor does not make smaller cards fit. ## Validation **Passed:** - Hardware run (RTX 4060 Ti 16 GB x2, Linux, CUDA 13.4, sm_89, IQ3_S, `--spec 6 --lookup 15 --batch 1 --max-context 8192`): an engine built from `v0.2.10` plus this `model.cpp` change loads with `FNX_ARENA=1 FNX_EXPERT_RAM_GIB=20 FNX_POOL_MIN_RESIDENT=384` in about 100 s, then ran 200 ShareGPT requests (concurrency 1) and the 2,309 JamC-QA items without a failed request; short-prompt decode was 50 to 60 tok/s. Higher `FNX_EXPERT_RAM_GIB` values (up to 30) also load. - Same box, floor not applied (`FNX_POOL_MIN_RESIDENT` unset), `FNX_EXPERT_RAM_GIB` 12 and 24: `pool 3 has 235 / 113 slots, a window needs 320`. - `python -m pytest tests/split` on this branch rebased onto `main` (`9f7d977`): 65 passed (the same 65 on `main`, which has grown since the first version of this PR). **Failed:** - With the floor on and a smaller `FNX_EXPERT_RAM_GIB`: 12 fails later at `cudaMalloc of 810 MiB on card 0: out of memory` (MTP buffers, `5997 of 24576` in RAM), 16 fails at `prefill: cudaMalloc of 20 MiB ... out of memory`. This is plain VRAM shortage, no longer the pool error. With the floor the "pool P has K slots" placement error is gone and the failure moves to where it belongs; that is the behaviour I would expect from the floor: it is a placement rule, not a memory budget, so cards that are too small still fail, but with an ordinary out-of-memory message instead of a placement exception. **Not run:** - The tested binary was built from `v0.2.10` with the same `model.cpp` change (identical code). I did not rebuild this exact branch commit after rebasing onto the current `main`; the rebase conflicted only in `docs/SPLIT_ENGINE.md` and `model.cpp` merged without changes. - HIP and SYCL builds (the change is in shared `src/split` C++ with no backend-specific code, but it was not compiled for them). - A file with a single quantization type (one pool) and a comparison of outputs with the variable unset against an unpatched build. The reasoning that the default path is unchanged comes from the code, not from a byte-for-byte comparison. - Starting through `strata launch`: the launcher refuses this case on stock `main` (experts do not fit in VRAM), so the engine was started directly from a server run config. ## Limits - `N=384` worked on this box; it is `320 + margin`, not a tuned value. - Only one model and one quantization were tried. The effect on files where all experts fit in VRAM should be none, since no expert is moved to RAM there. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi changed title from [PR #5258] [Engine] split engine: optional per-pool floor for expert residency (FNX_POOL_MIN_RESIDENT) to [PR #5258] [CLOSED] [Engine] split engine: optional per-pool floor for expert residency (FNX_POOL_MIN_RESIDENT) 2026-11-08 00:46:51 +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#5367
No description provided.