[GH-ISSUE #1922] [Bug]: RouterLookahead overhead with fully resident experts; disabling it improves decode by 19% on RTX 4070 #760

Closed
opened 2026-11-04 01:45:39 +07:00 by bsakaguchi · 4 comments
Owner

Originally created by @Takayuki-Ishimaru on GitHub (Oct 11, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/1922

What happened

With all experts in GPU cache or pinned RAM, the file-tier RouterLookahead still runs CPU router prediction although there are no expert file reads. On the same UD-IQ4_XS model and v0.1.41 binary, disabling it improved mean decode throughput from 32.80 to 39.06 tok/s (+19.1%).

Same model, three 600-token requests per arm Individual tok/s Mean tok/s
Default lookahead 31.96 / 33.97 / 32.48 32.80
STRATA_LOOKAHEAD=0 38.79 / 40.27 / 38.11 39.06
Default lookahead, paced pinning control 33.36 / 31.29 / 32.85 32.50

The off arm automatically used paced cudaHostRegister; the first on arm used bulk allocation. To check that confound, I repeated the on arm with STRATA_PIN_GUARD=2. Both paced arms fully pinned 54.85 GiB; the comparison still shows +20.2% throughput. The pin guard is only a diagnostic control, not the proposed workaround.

In those paced arms, total host-pool time fell from 18.38 to 13.29 ms/output token; CPU expert work was 13.14 to 12.66 ms and GPU-reach time 8.97 to 8.93 ms. This supports predictor overhead/competition as an explanation, but does not isolate mutex, scheduling, or memory-bandwidth costs.

Strata version, GPU, OS

v0.1.41, fb58e0dbc8399662c0e47c76578c6e878b14f6cf; RTX 4070 12 GB; Intel i5-13500 (AVX2), five pool workers plus the caller. Ubuntu 24.04 LXC, kernel 6.17.13-21-pve, 96 GiB container RAM; CUDA 13, sm_89 build.

Model: Unsloth Qwen3.8-Flash-Next UD-IQ4_XS native three-part GGUF, pack created with iq_pack.py --compat-bf16. GPU cache: 1,690 slots / 3,886 MiB; pinned RAM complement: 54.85 GiB. A local thinking-budget/stop patch is present; these measurements use the raw engine --serve protocol, bypassing Python HTTP handling. The same binary, weights, pack and MTP are used in all arms.

Reproduction

  1. Start a single engine with a native GGUF and enough RAM for the whole complement. Common options:

    --mmap-experts --resident-experts --expert-cache auto --prefill auto
    --spec 4 --spec-min-p 0.5 --mtp <same-mtp-directory>
    --max-context 196608 --kv int8 --kv-resident 16384 --vram-reserve-mib 980
    

    Actual KV residency was 20,480. Foresight was off; expert file-blob reads stayed at zero. Do not substitute a partial resident budget.

  2. Freeze prompt token IDs; warm with 150 output tokens, then generate 600 tokens for seeds 101–103. Use temperature 0.7, top-p 0.8, top-k 20, ignore EOS and no prompt-cache hits. My short Japanese prompt asks for all 47 prefectures, north to south, with two or three sentences each; numbered markers make each request fresh (60 tokens).

  3. Restart with only STRATA_LOOKAHEAD=0 changed and repeat. Timing instrumentation must match between arms. Check the resident/pin log and expert file-read counter in both.

Expected optimization

Consider automatically skipping file-prefetch prediction after residency is established and all relevant experts are accessible from RAM/GPU. Preserve prediction for partial/file-backed residency, Foresight, STRATA_LOOKAHEAD_STATS, and explicit measurement/override use. The resident flag alone is insufficient because a limited or failed RAM allocation can leave a file tier.

In v0.1.41, lookahead is initialized before the resident complement is filled; FileExpertSource::warms() checks mappings, while warm() later skips RAM-resident experts. The corresponding guards remain in current main's generate.cpp, warms(), and warm(). Current main was inspected, not benchmarked.

One machine, three requests per arm, fixed arm order and one engine startup per arm; no interleaved repeated restarts. Outputs and adaptive routing can differ; paced-arm MTP acceptance moved from 69.8% to 71.6%, adding uncertainty. No quality or long-context A/B for this flag, and no byte-identical output guarantee.

Searches for STRATA_LOOKAHEAD, lookahead, and resident/prefetch found related #1348 (Foresight), #1838 (partial RAM adaptation), and #416 (older Windows mmap benchmarks), but no exact report of this full-resident case. Those configurations differ; this report does not propose disabling prediction globally.

Originally created by @Takayuki-Ishimaru on GitHub (Oct 11, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/1922 ## What happened With all experts in GPU cache or pinned RAM, the file-tier RouterLookahead still runs CPU router prediction although there are no expert file reads. On the same UD-IQ4_XS model and v0.1.41 binary, disabling it improved mean decode throughput from **32.80 to 39.06 tok/s (+19.1%)**. | Same model, three 600-token requests per arm | Individual tok/s | Mean tok/s | |---|---|---:| | Default lookahead | 31.96 / 33.97 / 32.48 | 32.80 | | `STRATA_LOOKAHEAD=0` | 38.79 / 40.27 / 38.11 | 39.06 | | Default lookahead, paced pinning control | 33.36 / 31.29 / 32.85 | 32.50 | The off arm automatically used paced `cudaHostRegister`; the first on arm used bulk allocation. To check that confound, I repeated the on arm with `STRATA_PIN_GUARD=2`. Both paced arms fully pinned 54.85 GiB; the comparison still shows +20.2% throughput. The pin guard is only a diagnostic control, not the proposed workaround. In those paced arms, total host-pool time fell from 18.38 to 13.29 ms/output token; CPU expert work was 13.14 to 12.66 ms and GPU-reach time 8.97 to 8.93 ms. This supports predictor overhead/competition as an explanation, but does not isolate mutex, scheduling, or memory-bandwidth costs. ## Strata version, GPU, OS v0.1.41, `fb58e0dbc8399662c0e47c76578c6e878b14f6cf`; RTX 4070 12 GB; Intel i5-13500 (AVX2), five pool workers plus the caller. Ubuntu 24.04 LXC, kernel 6.17.13-21-pve, 96 GiB container RAM; CUDA 13, sm_89 build. Model: Unsloth Qwen3.8-Flash-Next UD-IQ4_XS native three-part GGUF, pack created with `iq_pack.py --compat-bf16`. GPU cache: 1,690 slots / 3,886 MiB; pinned RAM complement: 54.85 GiB. A local thinking-budget/stop patch is present; these measurements use the raw engine `--serve` protocol, bypassing Python HTTP handling. The same binary, weights, pack and MTP are used in all arms. ## Reproduction 1. Start a single engine with a native GGUF and enough RAM for the **whole** complement. Common options: ```text --mmap-experts --resident-experts --expert-cache auto --prefill auto --spec 4 --spec-min-p 0.5 --mtp <same-mtp-directory> --max-context 196608 --kv int8 --kv-resident 16384 --vram-reserve-mib 980 ``` Actual KV residency was 20,480. Foresight was off; expert file-blob reads stayed at zero. Do not substitute a partial resident budget. 2. Freeze prompt token IDs; warm with 150 output tokens, then generate 600 tokens for seeds 101–103. Use temperature 0.7, top-p 0.8, top-k 20, ignore EOS and no prompt-cache hits. My short Japanese prompt asks for all 47 prefectures, north to south, with two or three sentences each; numbered markers make each request fresh (60 tokens). 3. Restart with only `STRATA_LOOKAHEAD=0` changed and repeat. Timing instrumentation must match between arms. Check the resident/pin log and expert file-read counter in both. ## Expected optimization Consider automatically skipping file-prefetch prediction after residency is established and **all** relevant experts are accessible from RAM/GPU. Preserve prediction for partial/file-backed residency, Foresight, `STRATA_LOOKAHEAD_STATS`, and explicit measurement/override use. The resident flag alone is insufficient because a limited or failed RAM allocation can leave a file tier. In v0.1.41, lookahead is initialized before the resident complement is filled; `FileExpertSource::warms()` checks mappings, while `warm()` later skips RAM-resident experts. The corresponding guards remain in [current main's generate.cpp](https://github.com/Niko1221/Strata/blob/61b3fb5dd3f1e8ec09cf7e4e05208bc6d3c46406/src/program/generate.cpp#L5380-L5420), [warms()](https://github.com/Niko1221/Strata/blob/61b3fb5dd3f1e8ec09cf7e4e05208bc6d3c46406/include/strata/core/expert_source.hpp#L689), and [warm()](https://github.com/Niko1221/Strata/blob/61b3fb5dd3f1e8ec09cf7e4e05208bc6d3c46406/src/core/expert_source.cpp#L2045-L2068). Current main was inspected, **not benchmarked**. ## Limits and related work One machine, three requests per arm, fixed arm order and one engine startup per arm; no interleaved repeated restarts. Outputs and adaptive routing can differ; paced-arm MTP acceptance moved from 69.8% to 71.6%, adding uncertainty. No quality or long-context A/B for this flag, and no byte-identical output guarantee. Searches for `STRATA_LOOKAHEAD`, lookahead, and resident/prefetch found related #1348 (Foresight), #1838 (partial RAM adaptation), and #416 (older Windows mmap benchmarks), but no exact report of this full-resident case. Those configurations differ; this report does not propose disabling prediction globally.
Author
Owner

@Niko1221 commented on GitHub (Oct 11, 2026):

Thank you for the measurement. We tried it on an RTX 3060 with every expert resident (3,539 GPU slots plus the rest pinned in RAM, no file reads): STRATA_LOOKAHEAD=0 against the default gave no decode difference (story +0.0%, code +0.1%, a long document -0.8%, 5 interleaved pairs) and the same tokens. That box has 20 CPU cores, so if the look-ahead threads compete with the decode threads it would show much less there than on a 6-core i5-13500. Could you post the decode numbers on 0.1.43 with and without it, and the pool-workers / CPU lines of the start-up log? If it holds on smaller CPUs, turning the look-ahead off when nothing can be read from disk is a cheap default.

<!-- gh-comment-id:6110178232 --> @Niko1221 commented on GitHub (Oct 11, 2026): Thank you for the measurement. We tried it on an RTX 3060 with every expert resident (3,539 GPU slots plus the rest pinned in RAM, no file reads): STRATA_LOOKAHEAD=0 against the default gave no decode difference (story +0.0%, code +0.1%, a long document -0.8%, 5 interleaved pairs) and the same tokens. That box has 20 CPU cores, so if the look-ahead threads compete with the decode threads it would show much less there than on a 6-core i5-13500. Could you post the decode numbers on 0.1.43 with and without it, and the `pool-workers` / CPU lines of the start-up log? If it holds on smaller CPUs, turning the look-ahead off when nothing can be read from disk is a cheap default.
Author
Owner

@Takayuki-Ishimaru commented on GitHub (Oct 11, 2026):

Thanks for checking this. I updated to 0.1.43 (7695859a) and repeated the measurements on the same RTX 4070 / UD-IQ4_XS configuration. Disabling lookahead still improves decode throughput here:

Workload Default lookahead, mean tok/s STRATA_LOOKAHEAD=0, mean tok/s Improvement Token-identical pairs
Japanese 36.58 44.73 +22.3% 3/5
English 36.88 42.74 +15.9% 1/5
Code 42.08 46.94 +11.6% 0/5

I ran five paired comparisons, alternating ON→OFF and OFF→ON, with a fresh engine for each arm. Each start had a 150-token warmup followed by 600 tokens per workload. Prompt token IDs and seeds matched within each pair. All measured runs reached 600 tokens, with no prompt-cache reuse and zero expert file-blob reads.

Both arms had 1,690 GPU cache slots (3,886 MiB), with the entire 54.85 GiB RAM complement pinned. Both used STRATA_PIN_GUARD=2 and STRATA_DECODE_TIMING=1; all other settings, including 0.1.43's route-tail-skip default, were identical. The three Japanese pairs with identical output tokens improved by 19.2%, 19.9%, and 20.5%.

I also remembered an important constraint: I run Strata in an LXC container on Proxmox in my homelab, with the host's sustained CPU package power limit deliberately set to 35 W to save electricity (120 W short-term). The i5-13500 physically has 6P+8E cores, but this container can use only logical CPUs 0,2,4,6,11,15: five P cores and one E core. Its CPU quota is unlimited.

Startup lines:

strata generate: this CPU has no AVX-512: the expert kernels run on AVX-2 (multi-token for the i-quant gate/up rows)
strata generate: CPU pool tasks/phase: 18 (automatic), participating threads: 6
strata generate: 5 pool workers on logical processors 2,4,6,11,15, the host thread on 0 (draining too) (--host-core first)
strata generate: 5 expert-pool workers + the host thread

This seems consistent with your CPU-contention hypothesis, although I have not repeated the test with the power limit removed.

I think an automatic policy would have practical value for other homelab users running Proxmox or similar environments with power caps and restricted CPU allocations. The CPU model and total host core count alone may not reflect the resources actually available to Strata. Adapting to those constraints could help users get better throughput within their existing power budget.

Would you consider:

  1. Skipping file-prefetch prediction once full GPU/RAM residency is confirmed, provided there is no remaining file-backed expert work, while preserving prediction for Foresight, statistics collection, and explicit overrides?
  2. As a further option, an automatic calibration mode that compares lookahead ON/OFF under the actual CPU affinity, quota, and power constraints, and disables it when a repeatable decode slowdown is observed? This could avoid needing a universal CPU-model or core-count threshold.

The measurements are from one machine and short prompts. Some output tokens and MTP acceptance rates differ, so this is not a fully token-identical benchmark; I have not tested long-context performance or quality differences. The local patch only changes Python server thinking-budget/stop handling, and these measurements use the raw engine protocol.

<!-- gh-comment-id:6111049831 --> @Takayuki-Ishimaru commented on GitHub (Oct 11, 2026): Thanks for checking this. I updated to **0.1.43 (`7695859a`)** and repeated the measurements on the same RTX 4070 / UD-IQ4_XS configuration. Disabling lookahead still improves decode throughput here: | Workload | Default lookahead, mean tok/s | `STRATA_LOOKAHEAD=0`, mean tok/s | Improvement | Token-identical pairs | |---|---:|---:|---:|---:| | Japanese | 36.58 | 44.73 | +22.3% | 3/5 | | English | 36.88 | 42.74 | +15.9% | 1/5 | | Code | 42.08 | 46.94 | +11.6% | 0/5 | I ran five paired comparisons, alternating ON→OFF and OFF→ON, with a fresh engine for each arm. Each start had a 150-token warmup followed by 600 tokens per workload. Prompt token IDs and seeds matched within each pair. All measured runs reached 600 tokens, with no prompt-cache reuse and zero expert file-blob reads. Both arms had 1,690 GPU cache slots (3,886 MiB), with the entire 54.85 GiB RAM complement pinned. Both used `STRATA_PIN_GUARD=2` and `STRATA_DECODE_TIMING=1`; all other settings, including 0.1.43's route-tail-skip default, were identical. The three Japanese pairs with identical output tokens improved by **19.2%, 19.9%, and 20.5%**. I also remembered an important constraint: **I run Strata in an LXC container on Proxmox in my homelab, with the host's sustained CPU package power limit deliberately set to 35 W to save electricity** (120 W short-term). The i5-13500 physically has 6P+8E cores, but this container can use only logical CPUs `0,2,4,6,11,15`: five P cores and one E core. Its CPU quota is unlimited. Startup lines: ```text strata generate: this CPU has no AVX-512: the expert kernels run on AVX-2 (multi-token for the i-quant gate/up rows) strata generate: CPU pool tasks/phase: 18 (automatic), participating threads: 6 strata generate: 5 pool workers on logical processors 2,4,6,11,15, the host thread on 0 (draining too) (--host-core first) strata generate: 5 expert-pool workers + the host thread ``` This seems consistent with your CPU-contention hypothesis, although I have not repeated the test with the power limit removed. I think an automatic policy would have practical value for other homelab users running Proxmox or similar environments with power caps and restricted CPU allocations. The CPU model and total host core count alone may not reflect the resources actually available to Strata. Adapting to those constraints could help users get better throughput within their existing power budget. Would you consider: 1. **Skipping file-prefetch prediction once full GPU/RAM residency is confirmed**, provided there is no remaining file-backed expert work, while preserving prediction for Foresight, statistics collection, and explicit overrides? 2. As a further option, **an automatic calibration mode** that compares lookahead ON/OFF under the actual CPU affinity, quota, and power constraints, and disables it when a repeatable decode slowdown is observed? This could avoid needing a universal CPU-model or core-count threshold. The measurements are from one machine and short prompts. Some output tokens and MTP acceptance rates differ, so this is not a fully token-identical benchmark; I have not tested long-context performance or quality differences. The local patch only changes Python server thinking-budget/stop handling, and these measurements use the raw engine protocol.
Author
Owner

@Niko1221 commented on GitHub (Nov 5, 2026):

Thanks for taking the time to report this.

Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected.

To reopen it takes about two minutes:

  1. Re-test on 0.2.11. It may already be fixed. Write down what you see.
  2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other].
  3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system.
  4. Comment /reopen. A check runs and either reopens the issue or lists what is still missing.

The rules are in CONTRIBUTING.md.

<!-- gh-comment-id:6659213349 --> @Niko1221 commented on GitHub (Nov 5, 2026): Thanks for taking the time to report this. Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected. To reopen it takes about two minutes: 1. Re-test on 0.2.11. It may already be fixed. Write down what you see. 2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other]. 3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system. 4. Comment `/reopen`. A check runs and either reopens the issue or lists what is still missing. The rules are in [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md).
Author
Owner

@Apertur3 commented on GitHub (Nov 6, 2026):

Re-test on 0.2.11 with a different setup. It supports the small-CPU explanation: the look-ahead costs throughput only when no CPU is left over for it.

Setup: Strata 0.2.11 built from source. 2x RTX 3090, AMD EPYC 7443 with 44 logical CPUs visible, Linux. Model Qwen3.8-Flash-Next IQ3_S, layer split auto, MTP on (--spec 4), --resident-budget-gib 60. Most experts sit in the GPU caches and in pinned RAM; a small rest goes through the file tier, so this is not the fully resident case. Each cell is the median of a 512-token bench run. Arms alternate on/off with a fresh engine per arm.

CPUs given to the engine Look-ahead short 30K-token prompt copy-heavy
16 (taskset) default 107.1 / 101.8 114.7 / 121.2 157.6 / 154.5
16 (taskset) STRATA_LOOKAHEAD=0 131.4 / 133.6 132.2 / 135.1 206.9 / 182.7
all 44 default 131.0 126.9 198.2
all 44 STRATA_LOOKAHEAD=0 123.9 125.0 203.7

With 16 CPUs, turning the look-ahead off gives +27% short, +13% at 30K and +25% copy (tok/s). With all CPUs there is no difference beyond run noise (about 6% here).

The start-up log shows the difference between the two cases:

  • 16 CPUs: 15 pool workers on logical processors 1-15, the host thread on 0 and aux cpus: ... none spare
  • all CPUs: 18 pool workers on logical processors 1-18, the host thread on 0 and aux cpus: ... go to CPUs 19

So the look-ahead threads compete with the pool workers when every CPU is already taken by a worker or the host. That is the situation on the 6-core i5 above, and on any box where the engine is pinned to a few cores. In our case it also happens while some experts are still file-backed. A gate on "nothing can be read from disk" alone would therefore miss it; a gate on "no spare aux CPU" (or both) would cover it.

<!-- gh-comment-id:6697126412 --> @Apertur3 commented on GitHub (Nov 6, 2026): Re-test on 0.2.11 with a different setup. It supports the small-CPU explanation: the look-ahead costs throughput only when no CPU is left over for it. **Setup:** Strata 0.2.11 built from source. 2x RTX 3090, AMD EPYC 7443 with 44 logical CPUs visible, Linux. Model Qwen3.8-Flash-Next IQ3_S, layer split auto, MTP on (`--spec 4`), `--resident-budget-gib 60`. Most experts sit in the GPU caches and in pinned RAM; a small rest goes through the file tier, so this is not the fully resident case. Each cell is the median of a 512-token bench run. Arms alternate on/off with a fresh engine per arm. | CPUs given to the engine | Look-ahead | short | 30K-token prompt | copy-heavy | |---|---|---:|---:|---:| | 16 (`taskset`) | default | 107.1 / 101.8 | 114.7 / 121.2 | 157.6 / 154.5 | | 16 (`taskset`) | `STRATA_LOOKAHEAD=0` | 131.4 / 133.6 | 132.2 / 135.1 | 206.9 / 182.7 | | all 44 | default | 131.0 | 126.9 | 198.2 | | all 44 | `STRATA_LOOKAHEAD=0` | 123.9 | 125.0 | 203.7 | With 16 CPUs, turning the look-ahead off gives +27% short, +13% at 30K and +25% copy (tok/s). With all CPUs there is no difference beyond run noise (about 6% here). The start-up log shows the difference between the two cases: - 16 CPUs: `15 pool workers on logical processors 1-15, the host thread on 0` and `aux cpus: ... none spare` - all CPUs: `18 pool workers on logical processors 1-18, the host thread on 0` and `aux cpus: ... go to CPUs 19` So the look-ahead threads compete with the pool workers when every CPU is already taken by a worker or the host. That is the situation on the 6-core i5 above, and on any box where the engine is pinned to a few cores. In our case it also happens while some experts are still file-backed. A gate on "nothing can be read from disk" alone would therefore miss it; a gate on "no spare aux CPU" (or both) would cover it.
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#760
No description provided.