mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #4021] [Engine] Opt-in tail-only parking for late conversation branches #1733
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#1733
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?
Originally created by @fujiichi on GitHub (Oct 24, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4021
Area
[Engine]
What do you want to do?
Park only the tail of a conversation when an agent client switches to a request that shares everything except the last turn or two, instead of the whole conversation.
Re-tested on 0.2.11 (2026-11-07): unchanged. In the test below (4 branches sharing an ~18K-token prefix, 10 rounds, 2 passes), unmodified 0.2.11 parked a whole image every time: 78 of 78 parks, 1,094.9 MiB and ~370 ms per park, 94 ms per restore — the same as on 0.2.4.2 (1,094.9 MiB, 377 ms). The patch, ported to 0.2.11, cut the parked image to 233.8 MiB and the client latency by 15–16%. Details are in the comment below; the original report follows.
Strata version: v0.2.11 (
c3b3f503), built from source (Release,STRATA_ENABLE_CUDA=ON,CMAKE_CUDA_ARCHITECTURES=86, CUDA 13.1). The patch is ported to the same tag.Graphics card, memory and system: 2× NVIDIA GeForce RTX 3060 12 GB (
--layer-split auto), 96 GB RAM, Ubuntu 26.04.1 LTS (Linux 7.0.0), NVIDIA driver 595.Summary
With an agent client (Claude Code with subagents), a long conversation often alternates with a short side request that shares everything except the last turn or two. Today every switch parks the whole outgoing conversation, although the incoming request rewrites the session only from a cell near the end.
A patch parks only the tail in that case: the running state, the K/V cells from the branch point (page aligned) on, and the newest checkpoint past it. The cells below the branch point stay in the session. An optional part reuses the running-state allocations of a restored tail image for the next tail park.
On v0.2.4.2, 2× RTX 3060, with tail parking and buffer reuse on:
Both parts are opt-in (
STRATA_TAIL_PARK=1,STRATA_TAIL_PARK_REUSE=1); withoutSTRATA_TAIL_PARK=1none of the tail steps run. I can open a PR if this is wanted.Setup
dfa3f402) + the patch, Linux, CUDA 13.1,sm_86, built from source (Release,STRATA_ENABLE_CUDA=ON). The unmodified build is the same tag with the same options.--layer-split auto(layers 0-23 on GPU 0, 24-47 on GPU 1). 96 GB RAM.--kv int8 --kv-resident 32768 --max-context 524288 --rope-scaling yarn --rope-scale 2 --spec 4 --spec-min-p 0.5with the MTP draft layer,--conversation-cache-mib 16384 --conversation-cache-min-free-mib 8192 --vram-reserve-mib 1024.The change
STRATA_TAIL_PARK=1).ConversationKvandSavedConversationget afirst_cell(0 = whole image, as today).resume).STRATA_TAIL_PARK_CHECKPOINTS=Nfor more; 0 = all). Carrying all of them made the tail grow by one running-state copy (114 MiB here) per turn, until it failed the half rule after three turns.--layer-split, every stage's image is parked the same way on its own GPU.ConversationCache::limit_tails(first_dirty)drops a tail image once a later rewrite starts before its first cell (a prompt read from further back, a restore, a slot or session-file restore).STRATA_NO_TAIL_PARK=1forces whole images for A/B tests.STRATA_TAIL_PARK_REUSE=1). After a tail restore, the image's five running-state buffers (GDN, PLE, and the indexer's tails / dead / block_pos; 56.5 MiB per GPU here) are kept in the cache budget and reused by the next tail park. Every byte is still copied; only the allocations and their zero fill are saved. If the budget has no room they are released; nothing is evicted to keep them.limit_tailscalls,limit_reusebefore a restore and the running-state estimate in a capture run only withSTRATA_TAIL_PARK=1.One commit on
v0.2.4.2, 8 files (+596 −41):conversation_cache.hpp,conversation_snapshot.{hpp,cpp},conversation_state.cpp,generate.cpp, the cache and validation tests, DETAILS.md. A first version was written on the 0.1.38 line; this one was redone on 0.1.47 and ported to v0.2.4.2.Results
The measured engine was built from the patch before its last two edits, which change only comments and DETAILS.md. ctest was run again on the final tree.
A. Growing conversations, five arms
4 branches share an ~18.4K-token prefix. Each branch is a growing conversation: each turn asks for the copper, silver and amber values of two reference blocks and their sum, and the arm's own reply is appended. 10 rounds × 4 branches = 40 replies per pass. Two passes (forward, then reverse arm order),
temperature 0, thinking off,--adapt-swaps 0,max_tokens 128; every reply was 51 tokens.--conversation-cache-mib 0. It still reuses the in-session shared prefix (18,372 tokens), so it is a reference without parking, not a re-read from token 0.reused_kv_bytes.snapshot_bytesis 104 bytes larger: the new 8-bytefirst_cellin 13 K/V records (12 QSA layers + the draft layer).reused_kv_bytes. The same happened in an earlier six-round run, again only in the unmodified build's second pass.B. Fixed branches replayed (latency)
Same patched binary, tail + reuse vs
STRATA_NO_TAIL_PARK=1. Upstream's retained-K/V reuse stays active in the forced-off arm. 4 fixed branches of 18,430 tokens each (18,425 reused on return). ABBA order, 30 requests per run, the first 4 dropped: 52 requests per arm. Every reply is a fixed "OK", so this test measures time only.journalctl -k -b) has noNVRM: Xidline.Tests
ctest -E ple_parity -j1on the final tree: 84/84 passed, including the conversation cache, snapshot, validation and transfer tests.ple_parityneeds a Q2_0 shard I do not have. The host-side tests check that a tail restore writes back every cell fromfirst_cellon and all running state byte for byte, never writes belowfirst_cell, rejects malformed tails before any write, and thatlimit_tailsdrops exactly the stale tails.Related
ConversationBuffer) make each copy faster. This patch copies less.Evidence
Attached:
strata-tail-park-evidence.zip. It contains:git amonv0.2.4.2) and both test scripts with their base config;Its README says how each number above was aggregated and how to rerun the tests. The prompts are synthetic; local paths and GPU UUIDs are replaced.
Caveats
ctest -j4run on 0.1.47 had a single byte-exact snapshot failure. It has not reproduced in serial runs since, and the cause is not known.What do you do today instead?
Whole-image parking, as upstream, with a free-RAM floor so a park cannot exhaust RAM. With ~130K-token agent conversations a whole image was ~3 GB, so many parks were refused and the main branch was re-read later. Writing refused parks to an SSD instead wrote ~275 GB per hour for this pattern, so I stopped that.
strata-tail-park-evidence.zip
@Niko1221 commented on GitHub (Nov 5, 2026):
Thanks for taking the time to report this.
Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected.
To reopen it takes about two minutes:
/reopen. A check runs and either reopens the issue or lists what is still missing.The rules are in CONTRIBUTING.md.
@fujiichi commented on GitHub (Nov 7, 2026):
Re-tested on 0.2.11 as asked. The issue still applies, and the patch is ported to 0.2.11.
Unmodified 0.2.11 still parks a whole image on every switch in this workload: 78 of 78 parks, 1,094.9 MiB, ~370 ms per park.
Port. Two commits on top of
v0.2.11(local branch; I can push it or open a PR) — the port of the original patch, and a follow-up that keeps the snapshot byte counts identical to upstream when the switch is off. 0.2.11 has no equivalent of tail parking; the parking code was refactored (onepark_sourcefor the main session and batch slots, async/VRAM park options), and the patch now:take_reuse_for(ids)on the default path and the #4677 fix untouched.It also fixes a bug that the original v0.2.4.2 patch had: a borrowed prefix (
restore_prefix) could leave a tail image whose start was below the borrowed length. Now a borrow drops all tail images, andrestore_prefixrefuses a tail record.Results on 0.2.11 (same workload as the original report; 4 branches, ~18K-token shared prefix, 10 rounds × 2 passes, temperature 0, 2× RTX 3060, Qwen3.8-Flash-Next IQ2_XS):
STRATA_TAIL_PARK=1STRATA_TAIL_PARK_REUSE=1ctest -R conversation: 10 of 10 pass, including the tail tests the patch adds.Happy to open a PR against main if this is wanted.
/reopen
strata-tail-park-evidence-v0211.zip
@fujiichi commented on GitHub (Nov 7, 2026):
/reopen
@github-actions[bot] commented on GitHub (Nov 7, 2026):
Reopened, thank you. A maintainer will pick it up from here.