kvstream: the ring is never carved below the shipped floor of 32 768 tokens

The raise enforced only the validation union -- the largest block union one
decode launch selects, max_seqs x (1 + n_spec) x sel_pitch -- which on the
reference model is 1026 blocks = 4104 tokens. That is the depth below which a
step cannot be served at all, not the depth below which streaming pays: the
measured curve puts the cost point at 24 576 and the shipped value at 32 768
(docs/KV-STREAMING.md 3.9). --kv-resident 1 therefore carved a 4 104-token
ring, and one 7 800-token request took 7 213 misses over 8 decoded tokens.

kStreamFloorTokens (32 768) is now a floor the carve enforces:

  * kvstream_ring_shape raises any ring under it, then kvstream_ring raises
    that to the union when the union is larger; both are clamped to the
    group's context, so a context under 32 768 tokens streams nothing (the
    ring covers it and the group keeps the base engine's path);
  * RadBuildCtx::kv_resident_blocks carries the raised number into the
    declare, because kv_resolve sizes its residency table from it -- a carve
    deeper than the declared table is refused by the kernel;
  * the startup warning says which bound applied, and KVStreamRing::floor_blocks
    keeps the two distinct.

The flag is still the operator's: --kv-resident 65536 stays 65536, and a
context that fits is untouched apart from the 32 768 floor.
This commit is contained in:
C_Tamas committed 2026-10-25 09:29:17 +07:00
1 parent 2bf1096131
commit 613bbaacfd
5 files changed
+63 -23

No files matched your search

+8 -2
View File
@@ -917,8 +917,14 @@ RadBuildCtx Engine::build_ctx(int rank, int64_t max_tok) const {
* (Scheduler::step), so a wider step is one sequence; 0 without a span. */
bc.max_mixed_tok = cfg_.prefill_span > 1 ? std::min(max_tok, prefill_shared_tok(cfg_)) : 0;
/* --kv-resident, in tokens: the ring a streamed group carves. Declared geometry states it where
* an op needs a ring depth (kv_resolve), so the report is the ring and not the context. */
bc.kv_resident_blocks = cfg_.kv_resident;
* an op needs a ring depth (kv_resolve), so the report is the ring and not the context. Raised
* to the shipped floor here, before the declare: the arch states the residency table's depth
* from this number (kv_resolve's `slots`), and a carve deeper than the declared table is
* refused by the kernel. The floor is the same one kvstream_ring_shape applies, so the two
* cannot disagree. */
bc.kv_resident_blocks = cfg_.kv_resident > 0 && cfg_.kv_resident < kStreamFloorTokens
? kStreamFloorTokens
: cfg_.kv_resident;
/* The probe's answer, so a streamed-only op is declared only for an architecture that serves
* one AND a deployment that asked (core/kvstream/bringup.cpp, kvstream_op_gated). */
bc.kv_stream_ok = arch_probe_.kv_stream_ok;