[PR #2719] [CLOSED] --prompt-cache-spread (opt-in): the first checkpoint in every --prompt-cache-every tokens of the conversation stays, so a request that departs far back reads at most that much again #4228

Closed
opened 2026-11-07 15:34:10 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/2719
Author: @bulhenvaster
Created: 10/16/2026
Status: ❌ Closed

Base: main ← Head: pr/prompt-cache-spread


📝 Commits (1)

  • dd9a924 --prompt-cache-spread (opt-in): the first checkpoint in every --prompt-cache-every tokens of the conversation stays, so a request that departs far back reads at most that much again

📊 Changes

4 files changed (+141 additions, -2 deletions)

View changed files

📝 docs/DETAILS.md (+11 -0)
📝 include/strata/program/conv_cache.hpp (+50 -0)
📝 src/program/conv_cache_test.cpp (+53 -0)
📝 src/program/generate.cpp (+27 -2)

📄 Description

An agent session grows by short turns and every request saves a checkpoint at its new turn, so least recent use keeps the root and the last few turns - all at the conversation's end. A request that departs further back (the client's summarization call over the older part, an old tool result rewritten) then falls to the root and reads everything after it again. With the option, eviction_victim_spread (conv_cache.hpp) keeps the first checkpoint in every --prompt-cache-every tokens as a milestone; the rest rotate by least recent use, the two most recently used always stay, and when only milestones are left the one whose neighbours are closest goes. Without the option, with fewer than 4 checkpoints or --prompt-cache-every 0 the policy is the plain one. conv_cache_test covers the new policy.

RTX 5060 Ti (PCIe 3.0 x8) + RTX 3060, --peer-device, IQ3_XXS, --prompt-cache 14: a conversation of 80 turns to 121K tokens, then a request with its first 55 turns and a new instruction (86,182 tokens): without the option 5,023 reused + 81,159 read in 60.3 s, with it 83,387 reused + 2,795 read in 4.1 s. A day of real agent use (31 automatic compactions): the summarization call read a median 8,062 tokens in 7.2 s instead of ~72K in ~55 s. The answers can differ in wording (a restored checkpoint and a batched re-read round differently). Not measured: the RAM of 14 checkpoints at its peak; HIP, SYCL and Metal (the change is host code shared by all of them).

How it was checked. Built on its own on top of main (296b59d2): CUDA 13.3, sm_86 + sm_120, Linux (Ubuntu), the strata target. conv_cache_test (header-only) compiled with g++ and passes, including the two new spread cases. The option has run in daily agent use on the rig above since 2026-10-13. HIP, SYCL and Metal were not built: I have only the NVIDIA rig.

One change per PR; nothing else from my fork is in it.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/2719 **Author:** [@bulhenvaster](https://github.com/bulhenvaster) **Created:** 10/16/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/prompt-cache-spread` --- ### 📝 Commits (1) - [`dd9a924`](https://github.com/Niko1221/Strata/commit/dd9a9242bcf0508e0386bd49dd6e19e4c3aa1f00) --prompt-cache-spread (opt-in): the first checkpoint in every --prompt-cache-every tokens of the conversation stays, so a request that departs far back reads at most that much again ### 📊 Changes **4 files changed** (+141 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `docs/DETAILS.md` (+11 -0) 📝 `include/strata/program/conv_cache.hpp` (+50 -0) 📝 `src/program/conv_cache_test.cpp` (+53 -0) 📝 `src/program/generate.cpp` (+27 -2) </details> ### 📄 Description An agent session grows by short turns and every request saves a checkpoint at its new turn, so least recent use keeps the root and the last few turns - all at the conversation's end. A request that departs further back (the client's summarization call over the older part, an old tool result rewritten) then falls to the root and reads everything after it again. With the option, eviction_victim_spread (conv_cache.hpp) keeps the first checkpoint in every --prompt-cache-every tokens as a milestone; the rest rotate by least recent use, the two most recently used always stay, and when only milestones are left the one whose neighbours are closest goes. Without the option, with fewer than 4 checkpoints or --prompt-cache-every 0 the policy is the plain one. conv_cache_test covers the new policy. RTX 5060 Ti (PCIe 3.0 x8) + RTX 3060, --peer-device, IQ3_XXS, --prompt-cache 14: a conversation of 80 turns to 121K tokens, then a request with its first 55 turns and a new instruction (86,182 tokens): without the option 5,023 reused + 81,159 read in 60.3 s, with it 83,387 reused + 2,795 read in 4.1 s. A day of real agent use (31 automatic compactions): the summarization call read a median 8,062 tokens in 7.2 s instead of ~72K in ~55 s. The answers can differ in wording (a restored checkpoint and a batched re-read round differently). Not measured: the RAM of 14 checkpoints at its peak; HIP, SYCL and Metal (the change is host code shared by all of them). **How it was checked.** Built on its own on top of `main` (296b59d2): CUDA 13.3, sm_86 + sm_120, Linux (Ubuntu), the `strata` target. `conv_cache_test` (header-only) compiled with g++ and passes, including the two new spread cases. The option has run in daily agent use on the rig above since 2026-10-13. HIP, SYCL and Metal were not built: I have only the NVIDIA rig. One change per PR; nothing else from my fork is in it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:34:10 +07:00
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#4228
No description provided.