mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
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#4178
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/2630
Author: @MrKop-git
Created: 10/15/2026
Status: ❌ Closed
Base:
main← Head:pr/kv-evict📝 Commits (1)
152d785kv: --kv-evict clock|lrfu, the streamed page pool's victim pick (#2415)📊 Changes
7 files changed (+109 additions, -6 deletions)
View changed files
📝
docs/DETAILS.md(+14 -0)📝
include/strata/core/layer.hpp(+3 -0)📝
include/strata/kernels/kv_stream.hpp(+3 -0)📝
src/core/layer.cpp(+12 -1)📝
src/kernels/cuda/kv_stream.cu(+60 -4)📝
src/kernels/kv_stream_parity.cpp(+6 -1)📝
src/program/generate.cpp(+11 -0)📄 Description
Summary
The measurement half of #2415 asked whether the streamed page pool should evict by something other than the resolve kernel's clock sweep. This is the other half: the option itself.
When the pool is full the kernel evicts one block per miss.
--kv-evict clock(the default, the engine's own) sweeps slots from a hand and takes the first that is unreferenced.--kv-evict lrfukeeps a per-block score that survives eviction, decays a little every call (the policy bench's lambda = 0.5 per 64 calls), gains on a hit, and evicts the lowest-scoring block - with ties going to the least recently used slot. That tie rule matters: a just-loaded block scores 0 and would otherwise be the first victim, where the clock sweep's reference bit gives it the same second chance.What it changes and what it leaves alone
The pool is a cache over an authoritative RAM copy, so the output cannot change - the flag only decides which blocks are re-read from RAM. Without
--kv-evictnothing is allocated, no score is kept and the kernel takes the clock sweep exactly as before.How it was checked
kv_stream_parityPASS in both modes, all four KV formats - the invariant (streamed == resident, bitwise) holds, and the two modes show the different miss counts the two picks produce on the same selections (int8: 69,581 clock vs 101,744 lrfu over 306 batches).--kv int8 --kv-resident 32768, 64K-token prompt + 128 decode tokens, ABBA):LRFU reads no more from RAM and its hit rate is a little higher, which is the direction the offline bench predicts: on real selection traces (a 4K-token prompt and a 64K-token one)
tools/replay_kv_stream_policy.pyhas LRFU re-reading 2.6-6.0% fewer blocks than clock at pool sizes between one call's width and the working set, while on thekv_stream_paritysynthetic pattern (a sliding recent window mixed with uniform draws) clock wins and lrfu matches its own offline model.What it does not claim
No speed claim. The wall clock did not separate (27.86/31.63 vs 24.62/19.52 tok/s) and could not here: the runs' work differs (918K-1.07M lookups, drafts 74-90 accepted) and this box's run-to-run spread is ±40%. The default stays
clockper the repo's rule that a default changes only where it was measured faster - the flag is opt-in so the two can be compared on a quieter machine and on the workloads that matter.Not tested
HIP (no toolchain here) and SYCL (a separate engine tree with its own
kv_streamsources);--batchand the layer-split paths; long multi-request sessions where the scores accumulate across requests.⚠️ One build note for reviewers: this branch needs a normal
cmake --build. Themake <target>/fastshortcuts skip header-dependency checks, so afterkv_stream.hpp'sKvStreamMapgrew they left stale objects with the old layout and the engine faulted with an illegal memory access at prefill. Nothing in the PR depends on that; it cost an evening to bisect.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.