mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #3701] [Benchmark] Compaction leaves a 154.6K-token re-read (97.8 s) after the summary - 2x V100-16GB, 420K-token agent session #1539
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#1539
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 @q738531569-tech on GitHub (Oct 22, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/3701
Area
[Benchmark] (a data point from a community box; not the standard protocol)
The short version
A 420K-token agent session on 2× Tesla V100-SXM2-16GB (sm_70) gets through compaction cheaply now — but the first request after the summary re-reads 154,601 tokens and takes 97.8 s. Everything else in the loop is covered by the prefix cache.
Box and settings
--peer-device 1, NVLink between them--mtp-hnorm stream,--spec 4 --spec-min-p 0.5--max-context 524288,--kv int8,--kv-resident 32768,--rope-scaling yarn --rope-scale 2.0v0.2.2with-DSTRATA_ENABLE_CUDA=ON -DSTRATA_EXPERIMENTAL_SM60=ON -DCMAKE_CUDA_ARCHITECTURES=70serve/server.pyfrom the 0.1.40.1 tree (the engine was swapped via the config'sexe, the server was not)--prompt-cache 64 --prompt-cache-spread,STRATA_CKPT_POOL=1The two requests
--prompt-cache 64 --prompt-cache-spreadthis same kind of call reused only 16,384 and read 156K-176K, i.e. 150-184 s.)Why the re-read happens (as I understand it)
After compaction the prompt is
system prompt + summary + the retained tail. The system prompt part is still a prefix, so it matches--prompt-cache-root(20,049 tokens here). But the summary and the retained tail now sit at different positions than any earlier request, andconv_cache.hppsays only checkpoints that are a prefix of the current prompt are usable, because "any other checkpoint's positional cells have been overwritten". So the 154,601 tokens that follow the system prompt have to be read again.The retained tail is about 155K tokens here (
retainTokenscomes out larger thanwindow × 16%), and that number is what sets the 97.8 s.The question
Does #3584 (suffix-reuse: conversation KV prefix mount, ... bound the re-read after an edit) cover this case? A compaction is a mid-history rewrite of the largest possible kind, and #3584's summary mentions bounding the re-read after an edit (16-turn edit chain 234.2 s → 162.4 s, exact replay 20 s → 0.2 s on an RTX 3090). If that also bounds the post-compaction read,
--prompt-cache 64 --prompt-cache-spreadplus #3584 would cover the whole loop and I do not need anything else.I did not test #3584: it is open, and this box is a production
.66that I can only restart between jobs. The numbers above are from its normal engine log, not a controlled benchmark — one session, one day.Longer term (not a request)
Since the retained tail is byte-identical, only its position changed, I looked at whether the KV could be kept.
reposition/rope_shift/position shifthave no hits in the tree, which matches the "positional cells" comment, so today it cannot. Work in this direction exists, in case it is ever worth it here:On this box that would be harder than usual:
--rope-scaling yarn --rope-scale 2.0is non-linear,--kv int8means dequantise-rotate-requantise with accumulated error, and the QSA indexer's block boundaries would have to be rebuilt as well. I am mentioning it only so the option is on the record, not as a feature request.@q738531569-tech commented on GitHub (Oct 25, 2026):
Short version: this is not an engine bug. The engine is doing the right thing with the information it has, but the default checkpoint layout does not line up with a compaction request, so every compaction re-reads the whole prompt. Two flags fix it. Details below.
Resolved on our side — root cause and fix
Reporting back because this turned out to be a configuration issue, not an engine bug, and the switches that fix it are off by default.
What happens, in plain terms
A compaction request does not resend the whole conversation. The client keeps the recent tail and replaces everything older with a short summary. So the prompt the engine sees is shorter than the history it has already processed — it stops at roughly 84% of where the live history currently ends.
The engine can only reuse a prefix if it has a checkpoint sitting exactly at that point. With the default
--prompt-cache 6, checkpoints are few and clustered near the end of the history. The 84% cut lands between two of them, nothing matches, and the engine falls back to the very first checkpoint —reusedpins at 16384 and everything after it is read again from scratch. That is our 154.6K-token / 97.8 s.Worth noting: a manual
/compactdoes not hit this, because that request carries the entire history and therefore matches the last checkpoint directly.Fix
--prompt-cache-spreadspreads the checkpoints across the context instead of clustering them at the end;--prompt-cache 64gives it enough slots for the spread to matter.Measured (same machine, same session shape)
Cost
--prompt-cache 64holds 64 checkpoints × ~118 MB ≈ 7.4 GB of host RAM. Fine at 125 GB, worth mentioning for smaller boxes.Suggestion
This only bites when a client truncates its compaction prompt — which any token-budgeting agent client does. So a line in
docs/DETAILS.mdnext to--prompt-cachemay be worth it, or failing that, at least mentioning that--prompt-cache-spreadexists; we only found it by readinggenerate.cpp.Hardware for reference: 2× V100-16GB, Qwen3.8-Flash-Next IQ3_S then IQ3_XXS,
--peer-device 1, 524288 context, 420K-token agent session.@Niko1221 commented on GitHub (Oct 29, 2026):
Thank you for measuring this and writing it up. We are building a Strata website with a page for community benchmarks, and results like these will be added there when it launches, so we are closing this here. If your numbers change with a new version, you are welcome to post them again.