mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #3168] [CLOSED] [Engine] kv: size the resident ring from the run's depth (opt-in, STRATA_KV_RING_ADAPT) #4488
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#4488
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?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/3168
Author: @xyzzing
Created: 10/19/2026
Status: ❌ Closed
Base:
main← Head:v4-kv-ring-adapt📝 Commits (1)
07bf6c1kv: size the resident ring from the run's depth (opt-in, STRATA_KV_RING_ADAPT)📊 Changes
3 files changed (+29 additions, -0 deletions)
View changed files
📝
include/strata/core/layer.hpp(+3 -0)📝
src/core/layer.cpp(+15 -0)📝
src/program/generate.cpp(+11 -0)📄 Description
Problem and result
The resident K/V ring is one global value (
--kv-resident), and because the KV pool is sized by it (the pool is the ring), a ring chosen for depth is paid by every run. A flat raise is a measured loss at shallow depth — on 0.2.0, ring 32,768 → 49,152 at 1K costs −40 % of the MTP path (acceptance 207/207 → 149–156/215) and at 32K −9.1 % with MTP against −1.7 % without: the draft path pays for a ring it cannot use, not attention.This PR sizes the ring from the run's depth, and only grows it when the ring can cover the whole context:
Opt-in (
STRATA_KV_RING_ADAPT), default behaviour unchanged. A shallow run keeps exactly today's ring; a deep one grows into the cap.Related discussion
Approach
qsa_kv_ring_adapt(g, cells_needed, cap)insrc/core/layer.cpp(+ declaration inlayer.hpp): rounds the needed cells up to a page, floors atmax(qsa_kv_resident_min(), 32768), and returns the floor unlessneeded >= cap.src/program/generate.cppruns before the session arena is sized and the graphs are captured, becauseqsa_state_bytes→kv_pool_bytessizes the pool by slots.Validation
Passed (0.2.0-beta base, same binary both arms, interleaved pairs, 256 generated tokens):
KV ring adaptive: 49152 -> 32768).Failed: none observed.
Not run:
--servepath: serve keeps one main session plus parked snapshots, so there is no per-request session to size a ring for; per-request sizing there needs per-conversation KV pools, noted as a follow-up, not this patch.Limits
generate-path only.Measurement notes
One process a cell, one-shot greedy, 256 generated tokens; the intervals are the MTP acceptance state (cells moved ±8 %), so only paired medians are used. Raw rows: 32K control 74.0/82.4/…, 128K control 70.7/64.5/…, cap arm 81.5/84.2/… — the full tables are in the campaign records; I can attach a sanitized dump if useful.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.