mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #1331] [CLOSED] On-disk conversations and the system prompt: spill tier, prefill cache, layer-split plumbing - tested against v0.1.41 #3391
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#3391
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/1331
Author: @shahrokhzargarpour
Created: 10/7/2026
Status: ❌ Closed
Base:
main← Head:aporte/disk-mirror-y-sesiones-agnosticas📝 Commits (10+)
22fd120serve: keep evicted conversations on disk across restarts740fa33serve: restore a session file without holding its K/V in RAMeb960cclayer-split: the disk conversation tier works with a stage split, and the scan never deletes38ed3d9disk tier: --conversation-cache-spill-when-full (evict-oldest|reject) and --conversation-cache-spill-max-age-days (0 = off)34e1c5fsystem-prompt prefill cache (--system-prompt-cache*): persist the prompt-cache root as a session fileefb34desystem-prompt prefill cache works with --layer-split (one session file per stage) and with host-RAM K/V7d00c02session identity: --kv-resident no longer enters it (a file restores under any residency)9756640setup, serve: the installer and Settings expose the on-disk layer (off by default)30d1f59docs: the system-prompt cache works under a layer split toofcadcb4disk tier: --conversation-cache-spill-on park (a mirror at the park), compaction and cancellation📊 Changes
34 files changed (+5823 additions, -181 deletions)
View changed files
📝
CMakeLists.txt(+13 -1)📝
README.md(+11 -0)📝
docs/BATCHING.md(+31 -8)📝
docs/DETAILS.md(+74 -4)➕
docs/FLAGS.md(+119 -0)📝
docs/MULTI_GPU.md(+27 -2)➕
docs/SPILL_AND_PROMPT_CACHE.md(+290 -0)📝
include/strata/core/conversation_cache.hpp(+145 -15)📝
include/strata/core/conversation_file.hpp(+33 -1)➕
include/strata/core/conversation_prompt_cache.hpp(+138 -0)📝
include/strata/core/conversation_snapshot.hpp(+36 -0)➕
include/strata/core/conversation_spill.hpp(+377 -0)📝
include/strata/core/mtp.hpp(+4 -0)➕
include/strata/core/stage_plan.hpp(+159 -0)📝
serve/runconfig.py(+81 -5)📝
serve/server.py(+180 -7)📝
serve/test_monitor.py(+36 -0)📝
serve/test_parallel.py(+29 -2)📝
serve/test_runconfig.py(+37 -0)📝
setup.py(+304 -2)...and 14 more files
📄 Description
Title
On-disk conversations and the system prompt: spill tier, prefill cache, layer-split plumbing - tested against
v0.1.41Issue: Resolves #
Summary
An opt-in on-disk layer for long conversations: a disk tier that parks a conversation's K/V image when the RAM cache fills and restores it on a later request, a system-prompt prefill cache, both working across a layer split, plus
--head-devicecard placement and acceptance reporting for--batch-mtp.This is the same on-disk layer as the previous version of this PR, rebased and re-verified against upstream
v0.1.41(fb58e0d) - and, since that version, run live against it. Every statement below is about that base.What changed
v0.1.41- 17 commits, original authorship preserved, including the #1271/#1269 cherry-picks.make_roomconflict is resolved semantically, not textually: the spill hook now lives inevict_oldest(), which gained atemplate<class Spill>overload. The zero-argument overload stays, so with the layer's flags off the code is upstream's byte for byte, and the hook sees the real eviction victim (which can be evicted from the middle of the deque) instead of a fixedentries_.front().put()re-reservation hole is closed:put()re-reserves with the real post-captureimage.bytes(), which typically exceeds the estimatemake_room()balanced against - so eviction atput()is the normal path of a large insert, not an edge case.put()gained a spill-callback overload and the park path propagates it. (drop_superseded()is deliberately left without a hook, and documented as considered-and-declined.)docs/FLAGS.md(every flag, its scope, its non-claim, and a section on the upstream mechanisms this layer lives beside without fusing with -pin=N,--peer-device,STRATA_KV_GROW_HOLD),docs/SPILL_AND_PROMPT_CACHE.md(how it works, its limits, what was verified and what was not, now including the live run), a README section, and the host-only tests for the pure classes.docs/SPILL_AND_PROMPT_CACHE.mdand in Extra Notes below; the fix is the next stacked PR on this branch.Extra Notes
Evidence - static, against
v0.1.41CUDA build exit 0 - the
strata.exeverified here is sha256C1D54A4F5A405F076A0D5F1EB0384DECB5A5E422C3A109A7AD6CD7B86A26FB99; its--helplists all 17 flags of the layer; an unknown flag is fatal (unknown argument, exit 2); the host-only test battery passes 12/12 (ctestexit 0); the layer's anchor/flag verifier (39 anchors, 17 flags) exits 0.Evidence - live, against
v0.1.41That same binary served
127.0.0.1:5012on the verification machine on a clone of the production serve config (production stays on 5011 and was not touched) and reported/propsbuild_info='Strata 0.1.41',n_ctx=196608, modelqwen3.8-flash-next-unsloth-ud-iq4_xs, ready in 156.6 s in both runs. A four-test battery (smoke, streamed throughput, repeated system prompt, two conversations that spill) ran twice, with a server restart between runs and the tier's folders left in place. The second run passed all four tests (OVERALL: PASS); the first reportedOVERALL: FAILfor one reason only - its harness (v1.0.0) could not compute a throughput figure atmax_tokens=256.prompt_tokens=8016) took 29.76 s and 30.10 s in the first run (a fresh process, nothing on disk for them) and 1.98 s each in the second (a new process, both already on disk), with the engine countingrestores=4in that second run againstrestores=0in the first. The 33,409-character system-prompt test has the same shape: 30.296 s for its first call in the first run (nothing reused) against 2.298 s for the same call in the second.disk: enabled=True spills=2 bytes=2153775104 restores=4over a folder of 19 files / 2,154,484,304 bytes, andsysprompt: enabled=True variants=3 hits=1 misses=0 bytes=719323136.finish=stop) at a median TTFT of 0.452 s, at 28.11 tok/s decoding (27.39 tok/s end to end).What the live numbers are not. Both runs used the same binary with the layer on, so what is measured is cold prefill against a restore from disk after a process restart - nothing more. It is not a comparison against upstream, not a speedup ratio for the layer, and not a throughput claim about it.
restores=4andhits=1are one run each: a working signal, not a rate. Theconversations=0on that same counter line is what the engine reports and is not interpreted here. The system-prompt test of the second run (TTFT 1.096 s then 1.52 s, withreused=7920/7925already warm) is one sample of a warm prefix, not a regression - and the -92.6 % of the first run is a cold-prefill KV-reuse figure (that run readsysprompt hits=0), so it is not a property of the system-prompt cache either.What this PR does not claim
The previous version of this PR said "not tested live against
v0.1.41". That non-claim is withdrawn - the runs above happened. What is still not claimed:restores=4, onehits=1, one median TTFT, one conversation length. Both runs readtokens_saved=0, so there is no hit rate and no tokens-saved total.--head-devicecard order, a layer split,--batch-mtp, a cancelled request, the GC's age and budget levers, or the compaction path (when a rewrite happens is the harness's decision, and this delivery carries no archive tier). That the layer is inert with the flags off under load is likewise still unshown.--serveloop for those four scenarios and nothing beyond them.Known limitation: the divergence discard can name a sibling's copy
discard_diverged_impl(src/core/conversation_spill.cpp) decides which stored copy a rewritten tail belongs to from the end of the stored conversation's header -conversation_header_length, the start of its first assistant turn - and keeps a copy whose shared prefix reaches past that marker (header == 0 || common < headerskips it). Few-shot turns inside the system prompt move that marker into the root the conversations share, so a sibling conversation (same system prompt, a different first exchange) also satisfies the guard, and its copy is the one removed - discarded from disk, not archived, in this version.The fix is a property guard: only the copy sharing the longest prefix with the prompt is a rewrite candidate, a tie between copies that disagree discards nothing, and a trace line names the
conversation_keyof the copy removed. It is written and tested on a sibling branch and arrives as the next stacked PR against this branch; this delta ships without it. Being straight about the scope of the evidence: the reproducing test was written against the sibling basev0.1.40.1, not againstv0.1.41, and has not been re-run here. The live battery above does not reach that path.Collaboration
This overlaps in territory with #1529 (a disk tier for parked conversations) - it looks like the two efforts are complementary rather than competing, and I'm glad to align on naming or split the series so both can land; the
put()re-reservation fix here is made againstv0.1.41and may be useful to that effort too. It also sits beside the supersession fix in konijiwa110/Strata#1; this series does not depend on its outcome. I haven't verified either PR's contents beyond their threads, so I won't claim more than "same area, happy to coordinate" - whatever split the maintainers prefer works for me.Credits
This layer is authored and directed by Shahrokh Zargarpour. It was written and verified with the Grok TUI Build coding agent - first on DeepSeek Flash, currently on Qwen3.8 flash-next UD iq4_xs, the local inference runtime the layer was developed and verified against.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.