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#4184
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/2640
Author: @qiuzan2001
Created: 10/15/2026
Status: ❌ Closed
Base:
main← Head:qiuzan2001/prompt-cache-policy-log📝 Commits (1)
7c57807generate: --prompt-cache-policy log keeps checkpoints on a geometric grid behind the newest point (opt-in; default lru unchanged; #2431)📊 Changes
5 files changed (+329 additions, -4 deletions)
View changed files
📝
docs/DETAILS.md(+19 -1)📝
include/strata/program/conv_cache.hpp(+81 -0)📝
src/program/conv_cache_test.cpp(+103 -1)📝
src/program/generate.cpp(+26 -2)➕
tools/checkpoint_branch_test.py(+100 -0)📄 Description
For #2431 (TwoAnts' point there that the retention should thin out with distance rather than keep only the newest points).
What it changes
A new engine argument,
--prompt-cache-policy lru|log, defaultlru.With more checkpoints than
--prompt-cache, the current rule keeps the root and the most recently used points. A 256K conversation with the defaults (--prompt-cache 6,--prompt-cache-every 16384) therefore holds the root (~30K) and 192K–256K, and a request that branches anywhere between them (an agent compacting its history, an edited early message, a sub-agent that shares the first half) reads everything after the root again.logpicks the victim against a geometric grid behind the newest point instead: targets atevery × (2^k − 1)behind it (0, 16K, 48K, 112K, …), the root pinned as before, the targets that would fall behind the root spent halving the widest remaining gap. The tail checkpoint (--prompt-cache-tail) andpin=Nprefixes are treated exactly as before. The function is pure (eviction_victim_logininclude/strata/program/conv_cache.hpp); the one call site insrc/program/generate.cpppasses the chain's lengths to it only when the flag is on.Simulated growth with the defaults (
conv_cache_test): at 256Klrukeeps 30/192/208/224/240/256K,logkeeps 30/80/128/224/240/256K; the largest gap is 96K against 162K. At 1M it is 674K against 930K.What it leaves alone
eviction_victimwith the same arguments as before; the new branch is only entered with--prompt-cache-policy logand--prompt-cache-every > 0. A chain with no more points than--prompt-cacheis the same either way.logrule falls back tolru(its scratch arrays are fixed; the help text and the docs say so).sycl/src/program/generate.cppis not changed. The header is shared and additive, so the SYCL build is unaffected, but the flag is an unknown argument there until that port is re-migrated.How it was checked
src/program/conv_cache_test.cpp: 37/37 (16 new: the simulated 128K/256K/1M growth, root/newest/pinned never the victim, the tail rule first,--prompt-cache-every 0/ no lengths / one slot / more than 64 items fall back to the plain rule, the root not the shortest, the root the longest).tools/checkpoint_branch_test.py(included): four greedy requests against the server, 4 output tokens, thinking off. Three rounds per arm, alternating order, the engine restarted for every run. Every run of an arm reused the same token counts; the prompt time below is the median.RTX 5070 Ti 16 GB, Ryzen 7 5800X3D, 76 GB RAM, Linux, CUDA 13.1; Swift 1.5 IQ3_S, 262,144 context,
--kv int8 --kv-resident 32768,--prompt-cache 6,--prompt-cache-every 16384; engine built from this branch, 0.1.44.1 otherwise.The branch request is the only one where the two differ. (In this run the root the engine kept was the periodic 16,384-token checkpoint, which lands before the ~30K system prompt ends; the gap the
logrule closes is the same either way.)Docs: one paragraph in
docs/DETAILS.md("Which checkpoints stay") with these numbers, and the flag in the engine options list.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.