[GH-ISSUE #4815] [Engine] --kv-resident N is 13-20% slower than --kv-grow at a 44-token context #2209

Open
opened 2026-11-04 01:57:31 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @baiqvesse on GitHub (Oct 31, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4815

Engine: 0.1.54 (commit 8c1aea4b, strata-engine-0.1.54-windows-x86_64-cuda-cuda13)
Model: Qwen3.8-Flash-Next, GSQ-RCO IQ3_S (2 shards), --mtp, --vision (CPU)
PC: Windows 11, RTX 5080 16 GB (sm_120, driver 617.42), Ryzen 9 9950X, 61.6 GB RAM, one card
Two configs that differ in exactly one flag: --kv-grow versus --kv-resident 32768
Everything else identical: --kv k8v4 --max-context 524288 --rope-scaling linear --rope-scale 2 --vram-reserve-mib 1600 --prefill 8192 --spec 4 --spec-min-p 0.5 --adapt-every 1 --adapt-swaps 160 --adapt-decay 0.97 --expert-cache auto, env STRATA_PF_FUSED=1 STRATA_PREFILL_CPU_SHARE=auto.

What the docs say

strata.exe --help, --kv-resident N:

KV streaming: keep N cells of each QSA layer in VRAM (min 20480) and the whole K/V in pinned RAM;
the freed VRAM goes to expert slots. 0 (default): all of it in VRAM.
A context of N cells or fewer is not streamed

So with a 44-token prompt and --kv-resident 32768, the streaming path should not be active at all,
and the two configs should measure the same.

What I measure

4 arms, mirrored (elastic → stream → stream → elastic), a fresh engine per arm, 30 s between arms,
five distinct cold 400-token prompts per arm (no prompt is repeated inside an engine) plus one
60K-token cold read. Decode tok/s is the engine's own 400 generated in ... (X tok/s) line.
GPU: 52–59 °C, 2872 MHz, no throttle reason active, in every arm.

arm mode expert slots decode median five readings 60K read
1 --kv-grow 2912 99.1 99.1 / 116.7 / 89.3 / 114.1 / 94.1 3202
2 --kv-resident 32768 2918 93.9 84.8 / 98.5 / 82.5 / 101.4 / 93.9 2687
3 --kv-resident 32768 2789 90.4 82.1 / 93.9 / 83.2 / 90.4 2774
4 --kv-grow 2965 112.8 112.8 / 120.5 / 97.0 / 118.4 / 105.0 3386
  • mirrored means: elastic 105.95, streaming 92.15 → decode −13.0%
  • 60K read: elastic 3294 → streaming 2730 → −17.1%
  • taking only the late (fully warm) arms: 112.8 vs 90.4 → −19.9%
  • restarting each config and repeating the same workload later gives the same steady state
    (85–93 tok/s for --kv-resident 32768, 110–127 for --kv-grow), so this is not a one-off

The prefill is slower too (−17%), which suggests the difference is not only in the decode loop.

--kv-resident itself is not the problem I'm reporting

I scanned it to make sure the value was not simply badly chosen (same workload, same mirrored design):

--kv-resident slots decode median (2 arms)
20480 (the minimum) 2925 / 2984 92.35
24576 2951 / 2963 91.75
32768 2923 / 2923 93.10
65536 2769 / 2753 89.70

20480–32768 is flat (the K/V takes 0.21–0.33 GiB); 65536 costs 160 slots and 3.7%. So 32768 is the
right value; the gap to --kv-grow is not a question of tuning N.

Why I need streaming at all

With --kv-grow, a 350K–400K-token session makes the K/V grow past the cache's borrowing room and
the engine then allocates new VRAM for it ("…gave 0 slots for it … and new VRAM"), which eats the
1600 MiB reserve. I hit 15.5 / 16.0 GB with 90 MiB free and a request failed. --kv-resident 32768
keeps the VRAM flat (14.2 GiB used, 1.4 GiB free) and the K/V block reads still hit VRAM 97.5–99.96%
of the time, so streaming works — it is just consistently slower, at every context length.

Questions

  1. Is "A context of N cells or fewer is not streamed" meant literally? If yes, the 13–20% at 44 tokens
    looks like a bug (or an undocumented cost of the mode).
  2. If it is an undocumented cost, could it be reduced or documented? A 13–20% decode and 17% prefill
    cost is significant for anyone who needs the long-context safety.

Happy to run more measurements on this PC (RTX 5080 / sm_120 / Windows) if a specific check helps.
Raw data: the two CSVs are reproducible with the same two configs; I can paste the engines' log lines
for every arm on request.

Originally created by @baiqvesse on GitHub (Oct 31, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/4815 **Engine:** 0.1.54 (commit `8c1aea4b`, `strata-engine-0.1.54-windows-x86_64-cuda-cuda13`) **Model:** Qwen3.8-Flash-Next, GSQ-RCO IQ3_S (2 shards), `--mtp`, `--vision` (CPU) **PC:** Windows 11, RTX 5080 16 GB (sm_120, driver 617.42), Ryzen 9 9950X, 61.6 GB RAM, one card **Two configs that differ in exactly one flag:** `--kv-grow` versus `--kv-resident 32768` Everything else identical: `--kv k8v4 --max-context 524288 --rope-scaling linear --rope-scale 2 --vram-reserve-mib 1600 --prefill 8192 --spec 4 --spec-min-p 0.5 --adapt-every 1 --adapt-swaps 160 --adapt-decay 0.97 --expert-cache auto`, `env STRATA_PF_FUSED=1 STRATA_PREFILL_CPU_SHARE=auto`. ## What the docs say `strata.exe --help`, `--kv-resident N`: > KV streaming: keep N cells of each QSA layer in VRAM (min 20480) and the whole K/V in pinned RAM; > the freed VRAM goes to expert slots. 0 (default): all of it in VRAM. > **A context of N cells or fewer is not streamed** So with a 44-token prompt and `--kv-resident 32768`, the streaming path should not be active at all, and the two configs should measure the same. ## What I measure 4 arms, mirrored (elastic → stream → stream → elastic), a fresh engine per arm, 30 s between arms, five **distinct** cold 400-token prompts per arm (no prompt is repeated inside an engine) plus one 60K-token cold read. Decode tok/s is the engine's own `400 generated in ... (X tok/s)` line. GPU: 52–59 °C, 2872 MHz, no throttle reason active, in every arm. | arm | mode | expert slots | decode median | five readings | 60K read | |---|---|---|---|---|---| | 1 | `--kv-grow` | 2912 | 99.1 | 99.1 / 116.7 / 89.3 / 114.1 / 94.1 | 3202 | | 2 | `--kv-resident 32768` | 2918 | **93.9** | 84.8 / 98.5 / 82.5 / 101.4 / 93.9 | **2687** | | 3 | `--kv-resident 32768` | 2789 | **90.4** | 82.1 / 93.9 / 83.2 / 90.4 | **2774** | | 4 | `--kv-grow` | 2965 | 112.8 | 112.8 / 120.5 / 97.0 / 118.4 / 105.0 | 3386 | - mirrored means: elastic **105.95**, streaming **92.15** → **decode −13.0%** - 60K read: elastic 3294 → streaming 2730 → **−17.1%** - taking only the late (fully warm) arms: 112.8 vs 90.4 → **−19.9%** - restarting each config and repeating the same workload later gives the same steady state (85–93 tok/s for `--kv-resident 32768`, 110–127 for `--kv-grow`), so this is not a one-off The prefill is slower too (−17%), which suggests the difference is not only in the decode loop. ## `--kv-resident` itself is not the problem I'm reporting I scanned it to make sure the value was not simply badly chosen (same workload, same mirrored design): | `--kv-resident` | slots | decode median (2 arms) | |---|---|---| | 20480 (the minimum) | 2925 / 2984 | 92.35 | | 24576 | 2951 / 2963 | 91.75 | | **32768** | 2923 / 2923 | **93.10** | | 65536 | 2769 / 2753 | 89.70 | 20480–32768 is flat (the K/V takes 0.21–0.33 GiB); 65536 costs 160 slots and 3.7%. So 32768 is the right value; the gap to `--kv-grow` is not a question of tuning N. ## Why I need streaming at all With `--kv-grow`, a 350K–400K-token session makes the K/V grow past the cache's borrowing room and the engine then allocates **new** VRAM for it ("…gave 0 slots for it … and new VRAM"), which eats the 1600 MiB reserve. I hit 15.5 / 16.0 GB with 90 MiB free and a request failed. `--kv-resident 32768` keeps the VRAM flat (14.2 GiB used, 1.4 GiB free) and the K/V block reads still hit VRAM 97.5–99.96% of the time, so streaming works — it is just consistently slower, at every context length. ## Questions 1. Is "A context of N cells or fewer is not streamed" meant literally? If yes, the 13–20% at 44 tokens looks like a bug (or an undocumented cost of the mode). 2. If it is an undocumented cost, could it be reduced or documented? A 13–20% decode and 17% prefill cost is significant for anyone who needs the long-context safety. Happy to run more measurements on this PC (RTX 5080 / sm_120 / Windows) if a specific check helps. Raw data: the two CSVs are reproducible with the same two configs; I can paste the engines' log lines for every arm on request.
Author
Owner

@github-actions[bot] commented on GitHub (Oct 31, 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:6545195550 --> @github-actions[bot] commented on GitHub (Oct 31, 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)
Author
Owner

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

Thanks, this follows the format now.

<!-- gh-comment-id:6605216857 --> @github-actions[bot] commented on GitHub (Nov 3, 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#2209
No description provided.