[GH-ISSUE #4929] [Engine] STRATA_PREFILL_HELPER_SOURCE is gated on o.batch <= 0, so it never engages with --parallel N; it halves prompt TTFT when it does #2268

Open
opened 2026-11-04 01:58:02 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @aebconsulting on GitHub (Nov 1, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4929

Area

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

Desktop app, Terminal or source?

Terminal (the strata command)

What happened

Every prompt on this four-card box pays about 7.4 s before the first token, regardless of prompt length: 524 tokens read in 7.4 s (70 tok/s), 8,012 tokens in 22.4 s (357 tok/s), 34,300 tokens in 110 s. Decode is fine (55-60 tok/s on short outputs, 100% expert-cache hit rate). The engine log says why: the prompt path borrows 1,277 CUDA0 expert slots per 8192-token chunk and refills them from the GGUF on the SSD, and the streamed experts come from the SSD too, although the three helper caches hold every expert:

strata serve: the prompt path borrows 1277 CUDA0 cache slots (3.73 GiB)
strata generate: WARNING: a prompt chunk of 8192 tokens lends 1277 cache slots to the prompt path, but only 0 of their experts fit in RAM: the others are read from the SSD on every chunk, and prompts can read ~3x slower than with --prefill auto (#669). A larger --resident-budget-gib (the lend region comes after the ranked experts), or a smaller --prefill, keeps them all in RAM
strata: prefill plan: chunk 8192, ring 96 kept: file set 63.2 GiB does not fit the page cache 0.0 GiB -> about 271.2 GB read from the drive per 32768-token prompt (4 chunks); no option does better (the set cannot fit: fewest passes win)
FileExpertSource: --resident-budget-gib 36.00 exceeds available RAM (16.45 GiB minus 4 GiB headroom and a 0.25 GiB margin): 9.63 GiB

The engine has an opt-in that fixes most of this, STRATA_PREFILL_HELPER_SOURCE, but its gate in src/program/generate.cpp (0.1.54, lines 9288-9289; unchanged at v0.2.9) requires o.batch <= 0:

if (const char* hv = std::getenv("STRATA_PREFILL_HELPER_SOURCE"); hv != nullptr && std::atoi(hv) != 0 &&
    srcp != nullptr && !multi_gpu && stages.empty() && o.batch <= 0 && !prefill_helpers.empty()) {

serve/server.py turns --parallel N (N > 1) into --batch N, so with any concurrency the switch is silently off: no log line, no change. I expected either the switch to work under --batch, or a log line saying why it did not.

A/B on the same server, one change per relaunch (GuideLLM 0.8.1, synchronous, unique synthetic prompts, 256/128-token outputs, reasoning_effort none; the client's TTFT agrees with the engine's own prompt N tokens ... read in X ms lines on every run):

launch 524-token prompt TTFT 8K prompt read 8K prefill tok/s decode, 128-token output
--batch 4, switch unset 7.5 s 28 s / 10.4K tokens 366 57 tok/s
--batch 4, STRATA_PREFILL_HELPER_SOURCE=1 (gate fails, no log line) 7.4 s 57 tok/s
no batch, switch unset 7.4 s 22.4 s 357 57 tok/s
no batch, STRATA_PREFILL_HELPER_SOURCE=1 3.6 s 16.0 s 495 ~100 tok/s

With the switch on the engine prints strata serve: the prompt path reads the experts a helper cache holds from that cache (STRATA_PREFILL_HELPER_SOURCE) at start and, per 8K request, strata serve: prefill helper source: 20241 blobs / 60502.0 MiB taken from a helper's cache in this request.

Requests / questions:

  1. Could the o.batch <= 0 term be relaxed for the helper-cache case? Reading the serve scheduler, prompt chunks and decode windows alternate and a helper's compute has finished before its rows are returned, so the "helpers are idle while a prompt is read" assumption in the comment above the gate seems to hold under --batch too. If a fence is wanted, a cudaStreamSynchronize(stream_) or an event wait before the copies in RemoteExperts::copy_cached_blobs would be the conservative version. Happy to test a build on this box.
  2. The switch does not cover the lent CUDA0 slots (the helper lookup skips primary-cache entries and the restore reads the file source), which is the ~3.5 s that remains on short prompts. Is sourcing the lent experts from a helper cache planned?
  3. Could STRATA_PREFILL_HELPER_SOURCE be documented (SECOND_GPU.md / MULTI_GPU.md)? I found it only as a string in the binary.

Smallest steps or command that reproduce it

  1. Four NVIDIA cards, helper caches: strata launch ... --parallel 4 --gpu 0 --set CUDA_DEVICE_ORDER=PCI_BUS_ID --set CUDA_VISIBLE_DEVICES=0,1,2,3 --set expert-cache-device1=7200 --set expert-cache-device2=7200 --set expert-cache-device3=7200 --set remote-expert-opt=on --set STRATA_PREFILL_HELPER_SOURCE=1 (plus the model/context flags below).
  2. Read the engine log: no the prompt path reads the experts a helper cache holds line; time a 500-token prompt: ~7.4 s to first token.
  3. Relaunch identical except --parallel 1: the line prints, the same prompt reads in ~3.6 s.

Reproduction status

Reproduced locally

Strata version

Strata 0.2.8 · Terminal/Control 0.1.54 · engine 0.1.54-windows-x86_64-cuda-cuda13 (the gate is unchanged in the v0.2.9 source)

Graphics card, memory and system

RTX 5090 32 GB (CUDA0, PCIe Gen5 x8) + three RTX 3090 24 GB on OCuLink docks (PCIe Gen4 x4, CUDA1..3) · 64 GB RAM · Windows 11 Pro · model files on NVMe

Model, size and settings

Qwen3.8-Flash-Next UD-Q4_K_XL (Unsloth) · 256K context (--context 256k, --kv int8, --kv-resident 32768) · pictures on · engine args: --prefill auto --spec 4 --spec-min-p 0.5 --mtp ... --resident-budget-gib 36 --expert-cache 3400 --expert-cache-device1 7200 --expert-cache-device2 7200 --expert-cache-device3 7200 --remote-expert-opt --vram-reserve-mib 2048 · env STRATA_ROUTE_PRIOR=0 STRATA_ROUTE_TAIL_SKIP=0 STRATA_KVA=0 · expert layout: CUDA0 4,335 slots, each 3090 6,747 experts, all 24,576 pairs GPU-resident

Logs

Engine lines quoted above; full per-request lines available on request (the 524-token and 8K rows for every configuration in the table).

Originally created by @aebconsulting on GitHub (Nov 1, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/4929 ### Area [Engine] (speed, kernels, models, the server and API) ### Desktop app, Terminal or source? Terminal (the `strata` command) ### What happened Every prompt on this four-card box pays about 7.4 s before the first token, regardless of prompt length: 524 tokens read in 7.4 s (70 tok/s), 8,012 tokens in 22.4 s (357 tok/s), 34,300 tokens in 110 s. Decode is fine (55-60 tok/s on short outputs, 100% expert-cache hit rate). The engine log says why: the prompt path borrows 1,277 CUDA0 expert slots per 8192-token chunk and refills them from the GGUF on the SSD, and the streamed experts come from the SSD too, although the three helper caches hold every expert: ``` strata serve: the prompt path borrows 1277 CUDA0 cache slots (3.73 GiB) strata generate: WARNING: a prompt chunk of 8192 tokens lends 1277 cache slots to the prompt path, but only 0 of their experts fit in RAM: the others are read from the SSD on every chunk, and prompts can read ~3x slower than with --prefill auto (#669). A larger --resident-budget-gib (the lend region comes after the ranked experts), or a smaller --prefill, keeps them all in RAM strata: prefill plan: chunk 8192, ring 96 kept: file set 63.2 GiB does not fit the page cache 0.0 GiB -> about 271.2 GB read from the drive per 32768-token prompt (4 chunks); no option does better (the set cannot fit: fewest passes win) FileExpertSource: --resident-budget-gib 36.00 exceeds available RAM (16.45 GiB minus 4 GiB headroom and a 0.25 GiB margin): 9.63 GiB ``` The engine has an opt-in that fixes most of this, `STRATA_PREFILL_HELPER_SOURCE`, but its gate in `src/program/generate.cpp` (0.1.54, lines 9288-9289; unchanged at v0.2.9) requires `o.batch <= 0`: ```cpp if (const char* hv = std::getenv("STRATA_PREFILL_HELPER_SOURCE"); hv != nullptr && std::atoi(hv) != 0 && srcp != nullptr && !multi_gpu && stages.empty() && o.batch <= 0 && !prefill_helpers.empty()) { ``` `serve/server.py` turns `--parallel N` (N > 1) into `--batch N`, so with any concurrency the switch is silently off: no log line, no change. I expected either the switch to work under `--batch`, or a log line saying why it did not. A/B on the same server, one change per relaunch (GuideLLM 0.8.1, synchronous, unique synthetic prompts, 256/128-token outputs, `reasoning_effort none`; the client's TTFT agrees with the engine's own `prompt N tokens ... read in X ms` lines on every run): | launch | 524-token prompt TTFT | 8K prompt read | 8K prefill tok/s | decode, 128-token output | |---|---:|---:|---:|---:| | `--batch 4`, switch unset | 7.5 s | 28 s / 10.4K tokens | 366 | 57 tok/s | | `--batch 4`, `STRATA_PREFILL_HELPER_SOURCE=1` (gate fails, no log line) | 7.4 s | | | 57 tok/s | | no batch, switch unset | 7.4 s | 22.4 s | 357 | 57 tok/s | | no batch, `STRATA_PREFILL_HELPER_SOURCE=1` | **3.6 s** | **16.0 s** | **495** | **~100 tok/s** | With the switch on the engine prints `strata serve: the prompt path reads the experts a helper cache holds from that cache (STRATA_PREFILL_HELPER_SOURCE)` at start and, per 8K request, `strata serve: prefill helper source: 20241 blobs / 60502.0 MiB taken from a helper's cache in this request`. Requests / questions: 1. Could the `o.batch <= 0` term be relaxed for the helper-cache case? Reading the serve scheduler, prompt chunks and decode windows alternate and a helper's compute has finished before its rows are returned, so the "helpers are idle while a prompt is read" assumption in the comment above the gate seems to hold under `--batch` too. If a fence is wanted, a `cudaStreamSynchronize(stream_)` or an event wait before the copies in `RemoteExperts::copy_cached_blobs` would be the conservative version. Happy to test a build on this box. 2. The switch does not cover the lent CUDA0 slots (the helper lookup skips primary-cache entries and the restore reads the file source), which is the ~3.5 s that remains on short prompts. Is sourcing the lent experts from a helper cache planned? 3. Could `STRATA_PREFILL_HELPER_SOURCE` be documented (SECOND_GPU.md / MULTI_GPU.md)? I found it only as a string in the binary. ### Smallest steps or command that reproduce it 1. Four NVIDIA cards, helper caches: `strata launch ... --parallel 4 --gpu 0 --set CUDA_DEVICE_ORDER=PCI_BUS_ID --set CUDA_VISIBLE_DEVICES=0,1,2,3 --set expert-cache-device1=7200 --set expert-cache-device2=7200 --set expert-cache-device3=7200 --set remote-expert-opt=on --set STRATA_PREFILL_HELPER_SOURCE=1` (plus the model/context flags below). 2. Read the engine log: no `the prompt path reads the experts a helper cache holds` line; time a 500-token prompt: ~7.4 s to first token. 3. Relaunch identical except `--parallel 1`: the line prints, the same prompt reads in ~3.6 s. ### Reproduction status Reproduced locally ### Strata version Strata 0.2.8 · Terminal/Control 0.1.54 · engine 0.1.54-windows-x86_64-cuda-cuda13 (the gate is unchanged in the v0.2.9 source) ### Graphics card, memory and system RTX 5090 32 GB (CUDA0, PCIe Gen5 x8) + three RTX 3090 24 GB on OCuLink docks (PCIe Gen4 x4, CUDA1..3) · 64 GB RAM · Windows 11 Pro · model files on NVMe ### Model, size and settings Qwen3.8-Flash-Next UD-Q4_K_XL (Unsloth) · 256K context (`--context 256k`, `--kv int8`, `--kv-resident 32768`) · pictures on · engine args: `--prefill auto --spec 4 --spec-min-p 0.5 --mtp ... --resident-budget-gib 36 --expert-cache 3400 --expert-cache-device1 7200 --expert-cache-device2 7200 --expert-cache-device3 7200 --remote-expert-opt --vram-reserve-mib 2048` · env `STRATA_ROUTE_PRIOR=0 STRATA_ROUTE_TAIL_SKIP=0 STRATA_KVA=0` · expert layout: CUDA0 4,335 slots, each 3090 6,747 experts, all 24,576 pairs GPU-resident ### Logs Engine lines quoted above; full per-request lines available on request (the 524-token and 8K rows for every configuration in the table).
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#2268
No description provided.