mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #2724] --prefill-head-alias: 3x slower cold prefill on a 16GB card, and the safety stop aborts the request at the end of prompt read #1089
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#1089
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ShaggyDragon on GitHub (Oct 16, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/2724
Environment
--serve, single GPU--expert-cache auto,--ple-io ram,--kv int8 --kv-resident 16384--prefill-head-aliasenabled (from the initial setup recommendation)1. Cold prefill is ~3x SLOWER with the flag on a 16 GB card
A/B on the same config, one flag changed, 35K-token cold prompt, same engine generation:
--prefill-head-aliasWith the flag on, the prompt path appeared forced into ~2048-token chunks that borrowed expert-cache slots (engine log slot accounting); without it, chunks went to the normal size and experts loaded once per chunk. The docs describe the flag as paying off on small (8 GB) cards — on 16 GB it looks like pure cost.
Suggestion: auto-enable only when the prompt-path buffers don't fit alongside the expert cache, rather than leaving it to users to discover the regression by A/B.
2. The safety stop aborts the whole request — always at the very end of prompt read
4 occurrences in one engine generation. The pattern is consistent: the error fires at 96–99 % of prompt read, i.e. the head layer appears to be reloaded (address moved) during prefill, and the captured verify graphs then fail at decode start:
The guard itself is right — reading freed memory would be worse — but the cost is brutal: the entire prefill (up to 48 s of work) is discarded, the client gets an error, and in our case the retries plus engine restarts wiped the adaptive tier, making every following request stone cold. That's how a "safety stop" turned into 100 s+ perceived cold starts.
Suggestion: when the moved head is detected, drop the alias for that request and decode via the non-aliased path (or re-capture the verify graphs) instead of failing the request — the prefill is already done at that point, everything else is throwaway.
Happy to run further A/Bs or capture the engine log around the reload events if useful.
@marksmeltzer commented on GitHub (Oct 19, 2026):
We ran into this while experimenting on our own rig and wanted to add a data point from the other end of the VRAM range, plus what we found in the source, which seems to confirm the ~2048-chunk hunch in the issue body. First: Flash-Next is the most capable model we've been able to run on this hardware, and this repo's CPU-offload approach is what makes it work at all on a single PC - an amazing community contribution, and we're glad to help where we can.
Our rig. Two RTX 5090 32 GB (one of which drives the display), 128 GiB system RAM, Ryzen 9 5950X, Windows; the GPUs sit on a PCIe gen4 x8 link the engine probes at ~14.5 GB/s. We've been testing Qwen3.8-Flash-Next UD-Q5_K_XL on Strata 0.1.45 (release engine, per
engine/BUILD.json) - experts all resident in system RAM,--kv int8 --kv-resident 32768 --max-context 262144,--expert-cache auto --prefill auto, MTP draft layer,--spec 4- comparing one GPU against the dual-GPU layer split (--layer-split auto) behind VS Code agent traffic. Cold prefill looked like our bottleneck - tool outputs and file reads make every turn a large fresh prompt - and sincePREFILL_HEAD_ALIAS.mddescribes the flag as unlocking bigger prompt chunks on one card, we tried consolidating to a single GPU with the flag on. (First launch hit the--short-read 0refusal - that's in the feature's exclusion list, we just found the doc line after the startup message rather than before :) - adding it started fine.)What we measured. Each arm ran a cold ~50K-token prompt (unique text,
cached_tokens: 0in every configuration, so no prompt-cache reuse in any arm), same engine, same rig, one configuration at a time:--short-read 0)The startup log explained it at a glance:
prompt chunk head alias: 2048 tokens with 22566 MiB borrowedandthe prompt path borrows 5911 CUDA0 cache slots- the cache held 5912 slots. So on a card this size the flag doesn't grow the chunk; it settles on 2048 and uses nearly the whole expert cache as buffer space, which leaves little cache warmth for the prompt read. Without the flag, the same card runsprompt chunk auto: 8192 tokens, borrows only 1350 slots (5 GiB), keeps ~21 GiB of warm cache, and prefill ran about 4.5x faster in our runs - enough to beat the dual split we had been comparing against.The mechanism (
src/program/generate.cpp, the head-alias branch): the chunk comes from a fixed candidate list{2048, 1536, 1024, 512}, so it never reaches the 8192 the plain auto path picks regardless of free VRAM, and the buffers come from essentially all cache slots (p.first = 1). On an 8 GB card, where the auto chunk genuinely can't fit beside any usable cache, that trade is clearly right - the 8 GB numbers in the doc are striking. On our 32 GB card both fit comfortably, which is likely why the flag's cost and benefit look reversed here.That points the same direction as the auto-gating suggestion in the issue body, maybe even simpler than a VRAM-size threshold: the decision condition is already computable at startup - whether
Prefill::bytes_neededfor the plain auto chunk fits alongside the expert cache the engine would otherwise size; enable the flag only when it doesn't. Our card is an example where VRAM size alone would give the wrong signal: 32 GB of VRAM, the buffers fit with room to spare, and the flag still chose 2048 and borrowed the cache. A one-line scope note near the top of PREFILL_HEAD_ALIAS.md (something like "for cards where the prompt-path buffers don't fit next to the expert cache") would have let us predict this before the A/B - and the feature itself is a really clever bit of memory scheduling when it does engage.One caveat on the table: the 283 vs 1262 pair was measured same-day, same-rig, one-flag-apart. The ~900 dual figure is our earlier dual observation rather than a fresh arm of this test, so read it as context, not as a directly A/B'd column.
Happy to run additional combinations if useful - e.g. the same A/B with an explicit
--prefill 2048to separate the chunk-size and cache-borrow effects on this rig.@ShaggyDragon commented on GitHub (Oct 19, 2026):
Adding a production data point from the 16 GB side, plus one mechanism detail that ties both regressions together.
Live config on the issue-body rig (Strata 0.1.44.1 serve, RTX 5080 16 GB, IQ3_S 79 GB pack):
/metricscurrently reportsexpert_slots: 3333, expert_cache_mib: 6532— the entire expert cache on this card is 6.5 GiB, and it is the streaming mechanism itself (experts resident in system RAM, streamed through those slots).Why the cost compounds on 16 GB. @marksmeltzer's startup log shows the head-alias branch borrowing 5911 of 5912 cache slots (
p.first = 1). On a 16 GB IQ3_S rig the whole cache is only 3333 slots — the borrow takes essentially all of it, so the prompt path pays twice: chunks capped at 2048 and experts evicted mid-prompt, forcing re-streams from RAM per chunk. Decode being unchanged in both tables is consistent with that: the cache refills after the prompt read.Workload profile. This engine serves an autonomous agent: turns are 20–130K-token prompts (tool outputs, file reads),
max_context 262144,kv_resident 20480. Cold turns are routine, so the 3.3x prefill penalty lands on real traffic, not just benchmarks — it roughly triples end-to-end turn latency on fresh chats.Flag-off stability. Since disabling
--prefill-head-aliason 2026-10-16 (the same day the four safety-stop aborts occurred), there have been zero head-alias aborts across all subsequent engine generations, including the current one. Plain auto prefill is the stable production config on this 16 GB card.On the fix: agree with the startup-computable gate rather than a VRAM-size threshold. On this rig the plain auto chunk fits alongside the 6.5 GiB expert cache, so that gate would correctly keep the flag off for 16 GB IQ3_S and 32 GB Q5_K_XL, and keep it on for the 8 GB cards where it is a genuine win.
@Niko1221 commented on GitHub (Oct 19, 2026):
Thanks for taking the time to report this.
We're resetting the tracker for 0.2.0-beta. There are more than 1,300 open issues and pull requests, too many for us to read properly, so we're closing everything that isn't being worked on right now. Closed here does not mean rejected.
To reopen it takes about two minutes:
/reopen. A check runs and either reopens the issue or lists what is still missing.The rules are in CONTRIBUTING.md.