[GH-ISSUE #4930] [Engine] KVA with batch slots: interleaved piecewise reads with a global frontier #2267

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

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

Short

This is the interleaved form of KVA for batch slots: a cold long prompt stays piecewise, KVA gets a global frontier, and the other slot keeps decoding. On our 24 GB RTX 5090 Laptop, a 100K request goes from 43.6 s to 38.2 s while a concurrent 25K request stays at 16.6 s instead of 37.1 s (whole-prompt variant) or 18.35 s (KVA off).

Our system

  • Olares One: Intel Core Ultra 9 275HX (24 threads), 96 GB RAM, NVIDIA RTX 5090 Laptop 24 GB, Linux (Olares 1.12.7), CUDA 13.
  • Qwen3.8-Flash-Next IQ3_S (GSQ-RCO), 200K context, INT8 KV, parallel: 2, --prefill auto:32768, KVA split 36 / suffix 2048, MTP --spec 6, engine 0.1.55 (Strata 0.2.9).
  • One GPU, text prompts.

The solution

Follow-up to #4927. Instead of reading the whole cold prompt in one run:

  • add set_kva_total(n) to Prefill and store the full cold-part length;
  • allow KVA to accept continuation pieces of the same cold read (cold_read in KvaConfig::decline);
  • use the full part length for the frontier (kva_frontier = total - suffix);
  • keep batch_read_piece / read_windows as usual, so KVA approximates the prefix pieces and the slots decode between pieces; the last 2K stay exact;
  • keep kva_floor_ across the pieces of one cold part (reset only at pos0 == 0).

Branch: https://git.aimighty.olares.de/aimighty/strata/src/branch/kva-interleave-029
Diff: 4 files, 12 insertions, 7 deletions (kva.hpp, prefill.hpp, prefill.cpp, generate.cpp).

What it brings

  • tools/batch_test.py, 40K, greedy, --adapt-every 1000000 --pcie-frac 0: KVA approximated 32768 of 32768 for the first batch piece and 0 of 6146 for the exact remainder; long slot identical to solo. The short slot differs at token 46 in both KVA on and KVA off on this engine (existing batch/cache behavior, not KVA).
  • Concurrent 100K + 25K, direct server, 3 runs: long 38.19 s (whole-prompt 37.11; KVA off 43.62), short 16.59 s (whole-prompt 37.12; KVA off 18.35), overlap 16.59 s.
  • Net: -12.4% long request vs KVA off; short request -55% vs the whole-prompt version and -9.6% vs KVA off; long request +2.9% vs the simple version.
  • Quality: the 0.1.55 release with the simple version passed Performance/Agentic/Stability and refusal 0/48; this interleaved variant was tested at engine/direct-server level, not yet as a full app release.

Limits

  • 2.9% slower on the long request than the simple version; full app gates for this variant are pending.
  • One CUDA GPU, text only; layer splits still decline KVA; HIP/SYCL not tested. The 28K system prompt still gets 0 approximation with the 32K chunk (a separate alignment attempt showed no speed gain).
  • No PR yet; the branch is a fork.

Request

Please consider this as the preferred form of KVA+batch for parallel slots. It supersedes the whole-prompt read in #4927 for multi-request serving. I can open a PR and run the required builds/tests.

Originally created by @bayerhazard on GitHub (Nov 1, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/4930 ## Short This is the interleaved form of KVA for batch slots: a cold long prompt stays piecewise, KVA gets a global frontier, and the other slot keeps decoding. On our 24 GB RTX 5090 Laptop, a 100K request goes from 43.6 s to 38.2 s while a concurrent 25K request stays at 16.6 s instead of 37.1 s (whole-prompt variant) or 18.35 s (KVA off). ## Our system - Olares One: Intel Core Ultra 9 275HX (24 threads), 96 GB RAM, NVIDIA RTX 5090 Laptop 24 GB, Linux (Olares 1.12.7), CUDA 13. - Qwen3.8-Flash-Next IQ3_S (GSQ-RCO), 200K context, INT8 KV, `parallel: 2`, `--prefill auto:32768`, KVA split 36 / suffix 2048, MTP `--spec 6`, engine 0.1.55 (Strata 0.2.9). - One GPU, text prompts. ## The solution Follow-up to #4927. Instead of reading the whole cold prompt in one run: - add `set_kva_total(n)` to `Prefill` and store the full cold-part length; - allow KVA to accept continuation pieces of the same cold read (`cold_read` in `KvaConfig::decline`); - use the full part length for the frontier (`kva_frontier = total - suffix`); - keep `batch_read_piece` / `read_windows` as usual, so KVA approximates the prefix pieces and the slots decode between pieces; the last 2K stay exact; - keep `kva_floor_` across the pieces of one cold part (reset only at `pos0 == 0`). Branch: https://git.aimighty.olares.de/aimighty/strata/src/branch/kva-interleave-029 Diff: 4 files, 12 insertions, 7 deletions (`kva.hpp`, `prefill.hpp`, `prefill.cpp`, `generate.cpp`). ## What it brings - `tools/batch_test.py`, 40K, greedy, `--adapt-every 1000000 --pcie-frac 0`: KVA `approximated 32768 of 32768` for the first batch piece and `0 of 6146` for the exact remainder; long slot **identical** to solo. The short slot differs at token 46 in both KVA on and KVA off on this engine (existing batch/cache behavior, not KVA). - Concurrent 100K + 25K, direct server, 3 runs: long **38.19 s** (whole-prompt 37.11; KVA off 43.62), short **16.59 s** (whole-prompt 37.12; KVA off 18.35), overlap 16.59 s. - Net: -12.4% long request vs KVA off; short request -55% vs the whole-prompt version and -9.6% vs KVA off; long request +2.9% vs the simple version. - Quality: the 0.1.55 release with the simple version passed Performance/Agentic/Stability and refusal 0/48; this interleaved variant was tested at engine/direct-server level, not yet as a full app release. ## Limits - 2.9% slower on the long request than the simple version; full app gates for this variant are pending. - One CUDA GPU, text only; layer splits still decline KVA; HIP/SYCL not tested. The 28K system prompt still gets 0 approximation with the 32K chunk (a separate alignment attempt showed no speed gain). - No PR yet; the branch is a fork. ## Request Please consider this as the preferred form of KVA+batch for `parallel` slots. It supersedes the whole-prompt read in #4927 for multi-request serving. I can open a PR and run the required builds/tests.
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#2267
No description provided.