[GH-ISSUE #5440] [Engine] Split engine: the FNX_PF_STAGE_ROWS default (2048) makes 200-800-token prompts up to 2.5x slower when most routed experts live in RAM #3251

Open
opened 2026-11-07 14:39:11 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @nabe2030 on GitHub (Nov 7, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/5440

Follow-up to #5187, as announced there.

Area

[Engine] (speed, kernels, models, the server and API)

What do you want to do?

Make the split engine's prompt-read path pick staging vs. reading in place by how many experts are actually non-resident, instead of by a fixed row count (FNX_PF_STAGE_ROWS, default 2048). With most routed experts in RAM, the fixed default makes 200-800-token prompts the slowest ones.

Derive the threshold from the non-resident share instead of a fixed row count. prefill_pass already counts the non-resident experts per layer (n_ram, from ec.slot_of), and pf_stage_bytes knows the non-resident bytes, so a rough rule could be: stage when the non-resident bytes / PCIe bandwidth is below the expected in-place read time for this many rows (in place approaches "all non-resident experts" quickly as rows grow; about 780 rows already touch nearly all of them here). With every expert resident, the non-resident share is 0 and the current behaviour stays as it is. A simpler version would be a lower default whenever the non-resident share is above some level (on this box anything from 8 to 64 rows gave the same result for prompts of 200 tokens and up).

Happy to test a patch on this box.

What do you do today instead?

We run with FNX_PF_STAGE_ROWS=8. For an agent harness this matters on every turn: tool results and short follow-ups are exactly the 50-800-token prompts, so the default costs 0.7-3.7 s per request on this box.

Evidence

Setup. 2x RTX 4060 Ti 16 GB (no P2P), Linux, all-cards split engine built for sm_89 from the PR #5258 branch (includes v0.2.11), Qwen3.8-Flash-Next IQ3_S, FNX_ARENA=1 FNX_EXPERT_RAM_GIB=20 FNX_POOL_MIN_RESIDENT=384, so about 69% of the routed experts (17,047 of 24,576) stay in RAM. Context 8192, --batch 1, MTP, FNX_PF_TIMING=1, a different prompt each time, median of 3.

What happens. In Engine::prefill the choice between reading the RAM-resident experts in place over PCIe and staging them into VRAM first is tokens.size() >= stage_rows, with FNX_PF_STAGE_ROWS defaulting to 2048. That fits a box where (almost) every expert is resident. Here, a pass read in place has to pull most of the non-resident experts over PCIe at low efficiency, so prompts below 2048 tokens are the slowest ones:

prompt default (2048) FNX_PF_STAGE_ROWS=8
48 tokens 2.65 s 1.95 s
200 tokens 3.73 s 2.02 s
780 tokens 6.09 s 2.40 s
3.4K tokens 4.18 s 4.22 s (both staged)

Only the head pass (N-6 rows) changes: read in place it grows with the row count (2.2 s for 48 tokens, 5.7 s for 780), while staging costs about 1.6 s (each card copies 16.4-16.8 GiB) plus compute. The 6-row tail pass is read in place in both settings (0.26-0.36 s), which is the right choice for it. 0.2.10 gave the same numbers within 0.1-0.3 s, and the decision line is unchanged between the two versions.

Originally created by @nabe2030 on GitHub (Nov 7, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/5440 Follow-up to #5187, as announced there. ### Area [Engine] (speed, kernels, models, the server and API) ### What do you want to do? Make the split engine's prompt-read path pick staging vs. reading in place by how many experts are actually non-resident, instead of by a fixed row count (`FNX_PF_STAGE_ROWS`, default 2048). With most routed experts in RAM, the fixed default makes 200-800-token prompts the slowest ones. Derive the threshold from the non-resident share instead of a fixed row count. `prefill_pass` already counts the non-resident experts per layer (`n_ram`, from `ec.slot_of`), and `pf_stage_bytes` knows the non-resident bytes, so a rough rule could be: stage when the non-resident bytes / PCIe bandwidth is below the expected in-place read time for this many rows (in place approaches "all non-resident experts" quickly as rows grow; about 780 rows already touch nearly all of them here). With every expert resident, the non-resident share is 0 and the current behaviour stays as it is. A simpler version would be a lower default whenever the non-resident share is above some level (on this box anything from 8 to 64 rows gave the same result for prompts of 200 tokens and up). Happy to test a patch on this box. ### What do you do today instead? We run with `FNX_PF_STAGE_ROWS=8`. For an agent harness this matters on every turn: tool results and short follow-ups are exactly the 50-800-token prompts, so the default costs 0.7-3.7 s per request on this box. ### Evidence **Setup.** 2x RTX 4060 Ti 16 GB (no P2P), Linux, all-cards split engine built for sm_89 from the PR #5258 branch (includes v0.2.11), Qwen3.8-Flash-Next IQ3_S, `FNX_ARENA=1 FNX_EXPERT_RAM_GIB=20 FNX_POOL_MIN_RESIDENT=384`, so about 69% of the routed experts (17,047 of 24,576) stay in RAM. Context 8192, `--batch 1`, MTP, `FNX_PF_TIMING=1`, a different prompt each time, median of 3. **What happens.** In `Engine::prefill` the choice between reading the RAM-resident experts in place over PCIe and staging them into VRAM first is `tokens.size() >= stage_rows`, with `FNX_PF_STAGE_ROWS` defaulting to 2048. That fits a box where (almost) every expert is resident. Here, a pass read in place has to pull most of the non-resident experts over PCIe at low efficiency, so prompts below 2048 tokens are the slowest ones: | prompt | default (2048) | `FNX_PF_STAGE_ROWS=8` | |---|---|---| | 48 tokens | 2.65 s | 1.95 s | | 200 tokens | 3.73 s | 2.02 s | | 780 tokens | 6.09 s | 2.40 s | | 3.4K tokens | 4.18 s | 4.22 s (both staged) | Only the head pass (N-6 rows) changes: read in place it grows with the row count (2.2 s for 48 tokens, 5.7 s for 780), while staging costs about 1.6 s (each card copies 16.4-16.8 GiB) plus compute. The 6-row tail pass is read in place in both settings (0.26-0.36 s), which is the right choice for it. 0.2.10 gave the same numbers within 0.1-0.3 s, and the decision line is unchanged between the two versions.
Author
Owner

@github-actions[bot] commented on GitHub (Nov 7, 2026):

Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing:

  • Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other], then a short description. Example: "[Engine] decode stops after 2 minutes".

Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment /reopen.

Details: CONTRIBUTING.md

<!-- gh-comment-id:6699298774 --> @github-actions[bot] commented on GitHub (Nov 7, 2026): Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing: - [ ] Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other], then a short description. Example: "[Engine] decode stops after 2 minutes". Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment `/reopen`. Details: [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md)
bsakaguchi changed title from [GH-ISSUE #5440] Split engine: the FNX_PF_STAGE_ROWS default (2048) makes 200-800-token prompts up to 2.5x slower when most routed experts live in RAM to [GH-ISSUE #5440] [Engine] Split engine: the FNX_PF_STAGE_ROWS default (2048) makes 200-800-token prompts up to 2.5x slower when most routed experts live in RAM 2026-11-08 00:46:30 +07:00
Author
Owner

@github-actions[bot] commented on GitHub (Nov 7, 2026):

Thanks, this follows the format now.

<!-- gh-comment-id:6710365246 --> @github-actions[bot] commented on GitHub (Nov 7, 2026): Thanks, this follows the format now.
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#3251
No description provided.