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#3480
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/1480
Author: @routhjim
Created: 10/8/2026
Status: ❌ Closed
Base:
main← Head:disk-only-cache📝 Commits (10+)
34e2409serve: keep evicted conversations on disk across restartsd258f18serve: restore a session file without holding its K/V in RAM0d846c1Merge remote-tracking branch 'upstream/main' into conversation-spill-disk1904b8aserve: recompute the RAM conversation match after a failed disk attempt: make_room may have evicted the entry the stale index named1a9e8b9Merge remote-tracking branch 'upstream/main' into conversation-spill-disk3a5daf6Merge branch 'pr-1269' into disk-only-cachedd146f4serve: --conversation-cache-disk-only - the conversation cache on disk, no RAM budgetb189048conversation_spill_test: disk-only checks; docs: --conversation-cache-disk-only, measured on Strix Haloff30368docs: --conversation-cache-disk-only restores measured from a cold page cache2987ac4serve: disk-only cache keeps each conversation's root as a persistent prefix entry📊 Changes
17 files changed (+2221 additions, -93 deletions)
View changed files
📝
CMakeLists.txt(+4 -1)📝
docs/DETAILS.md(+78 -4)📝
include/strata/core/conversation_cache.hpp(+131 -15)📝
include/strata/core/conversation_file.hpp(+28 -0)📝
include/strata/core/conversation_snapshot.hpp(+30 -0)➕
include/strata/core/conversation_spill.hpp(+114 -0)📝
serve/server.py(+55 -2)📝
serve/test_monitor.py(+44 -0)📝
serve/web/app.js(+28 -1)📝
serve/web/index.html(+4 -0)📝
src/core/conversation_file.cpp(+227 -32)📝
src/core/conversation_file_test.cpp(+122 -0)📝
src/core/conversation_snapshot.cpp(+79 -14)➕
src/core/conversation_spill.cpp(+392 -0)➕
src/core/conversation_spill_test.cpp(+331 -0)📝
src/core/conversation_state.cpp(+17 -2)📝
src/program/generate.cpp(+537 -22)📄 Description
Stacked on #1271 (spill directory) and #1269 (streaming restore). The branch is #1271 (at
4af468f, which brings in v0.1.41) with #1269 (atd258f18) merged in. Only the last eight commits are new:dd146f4: the mode;b189048: tests and docs;ff30368: the cold-page-cache numbers in the docs;2987ac4,a040357,9eac670: persistent prefix entries (below), with tests and docs.83ad1c5,155dd84: from @ed-hch's CUDA test: a refused disk read keeps its file, and the monitor card shows the disk tier.I will rebase once those two land, or fold this into #1271 if its author prefers.
#1271 keeps the conversations the RAM cache evicts on disk. A conversation reaches disk only through a RAM eviction (
make_room), so the RAM budget still decides what is kept. On a machine where the expert cache takes nearly all memory (Strix Halo: 72 GiB of experts in 128 GB), the conversation cache needs that budget most and can afford it least.--conversation-cache-disk-only, with--conversation-cache-spill-dir, keeps the conversation cache on disk only:conversation_snapshot_sources+ the streamingsession_file_write). No host image is made.--conversation-cache-mibis not used.--conversation-cache-disk-mibis the only limit, so no conversation is refused for its size. A read or save still checks free RAM for its transient buffers (one checkpoint's running state and two 16 MiB blocks) against--conversation-cache-min-free-mib. When that refuses, the file is kept for a later turn.drop_supersededgains akeeppath, because its rule alone would drop the new copy too. A failed write loses nothing.--batchor--peer-device; otherwise the flag says so and is off.Where it helps. A coding agent run as several sessions on one local engine: Claude Code through an Anthropic-compatible proxy, or a manager such as Happier that starts sessions from a phone. Each session is a long conversation (20-120K tokens), and they alternate. With one GPU and no RAM to spare, every switch read the whole conversation again. One real Claude Code session of 121K tokens took 181 s to read and 2.0 s to restore from disk. A new session started from a 13K-token preamble that is the same every time, and read all of it.
Prefix entries. When a conversation is saved, its shared opening is also saved on its own as
strata-conv-prefix-N, once per distinct opening. The opening is the deepest"strata_prefix"checkpoint on the live path when the request pinned one. Otherwise it is the root by the engine's rule: the first turn boundary at least--prompt-cache-roottokens in. A new conversation that opens the same way resumes from it.has_prefixdedupes them.Measured with real Claude Code sessions. The client marks
"strata_prefix"after Claude Code's leading<system-reminder>blocks, so the system prompt, tools and reminders form the shared part.The rest of each first turn is the user's own message and a per-session block, so it has to be read.
Why this matters beyond the budget. With #1271 as it is, a conversation larger than the free RAM budget is neither parked nor spilled:
If its disk copy was restored a turn earlier, that copy was already removed as superseded, so the conversation is gone, and its next turn reads 15,954 tokens from the start (18.9 s, in the run below). The long conversations are the ones that gain the most from a disk tier. Disk-only mode never asks the RAM budget.
Measured on a Ryzen AI Max+ 395 (Radeon 8060S, gfx1151, 128 GB, Linux 7.2, ROCm 7.14.1, the iGPU alone).
docs/STRIX_HALO.md.--mmap-experts --expert-cache auto --spec 4 --mtp mtp/rt --lookup-chain 3 --kv int8 --max-context 65536. Spill directory on the internal NVMe./metricstotals around each request.--conversation-cache-mib 2048 --conversation-cache-slots 1--conversation-cache-disk-onlyfsync, thenposix_fadvise(DONTNEED);fincoreshowed 0 bytes resident each time). Restores took 275-361 ms (read pass 128-162 ms), and all 12 later turns resumed with the same 88-94% reuse.RssAnon, sampled every 0.1 s) peaked 0.6 GiB above a run without the cache during a switch, and ended 0.15 GiB above it. No conversation stays in RAM.Tests.
conversation_spill_test: 32 new checks, 73 pass.test_monitor: 2 new tests, 12 pass.drop_supersededspares thekeepcopy, while the rule alone would drop it.drop_superseded, evicted last, deduped, and still prefixes after a reopen.The engine paths were run end to end as above.
Not tested:
--kv-grow: the restore callskvg_ensureas the RAM restore does, but I did not run it with elastic K/V.Measured with the help of Claude (Anthropic).
🤖 Generated with Claude Code
https://claude.ai/code/session_013XBY17SSRKGmDXc2YFsrmp
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.