mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #830] Let a one-shot request skip the prompt-cache work (~45 ms per call that is never reused) #368
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#368
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 @brenoperucchi on GitHub (Oct 4, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/830
A follow-up to part 2 of #519. Your explanation there of the fixed cost of the batched read (with about 40 % of the experts outside VRAM, a short batch still has to bring in nearly all the missing ones) matches what I see on 0.1.39: over 35 warm batched reads of 212 to 558 tokens the time fits about 245 ms + 0.33 ms per token. Following your suggestion, I moved the checkpoint to the end of the fixed instruction with
--prompt-cache-root 64, which saves 20 to 40 ms per call. What is left on the cache side still costs about 45 ms per call.Setup
--expert-cache auto(14,864 slots, 24.2 GiB),--prefill auto:32768,--max-context 32768,--kv int8,--pcie-frac 0.20,--spec 4 --spec-min-p 0.70,--prompt-cache-root 256for the numbers below (production now runs 64),STRATA_IQ_MT_MIN=1max_tokens1, thinking off. Every call has a different user message, and the same server also takes interactive chats that do reuse their conversations.src/program/generate.cpp, the same prompts in every run, 12 calls per size with the first 2 skipped, client on the same PC. I can share the script.What the prompt cache costs on these calls
prompt_ms, cache onprompt_ms,--prompt-cache 0That is about 46 ms of
prompt_msand about 40 ms of wall time per call. With the cache on, the prompt is read in two parts, split at the last<|im_start|>, and a checkpoint is taken there. That checkpoint ends after the user message, which is different on every call, so nothing reuses it. WithSTRATA_TRACE=1, a 486-token prompt showsread 479 tokens (batched) in 403.5 ms,refilled 190 slots ... in 14.0 msandread 6 tokens (windows) in 14.4 msagainstprompt 486 tokens ... read in 460 ms. The trace leaves about 27 ms outside the timed reads, so the checkpoint itself costs at most that and the rest comes from the split.--prompt-cache 0removes this for the whole server, and the interactive chats lose their reuse with it.serve/server.pydoesn't readcache_prompt, so a request can't ask for it.Question
Could a request opt out of both the split at the last turn and the checkpoint when it has nothing to keep, for example by honouring
cache_prompt: false, or automatically when a one-turn prompt's only reusable part is already a root? I'd expect it to save up to what--prompt-cache 0saves on calls like these.Separately: for a short batch where most of the missing experts are needed anyway, would running the non-resident ones on the CPU, as the decode windows do with misses, ever beat streaming them? If there's a trace counter that splits the batched read into transfer and compute time, I'd run it here.
I can share the traces and the script, and run a build with a change on this machine.
@brenoperucchi commented on GitHub (Oct 5, 2026):
I wrote the per-request version and opened #861.
"strata_checkpoint": falseskips the split and the checkpoint at the last turn and keeps the root reuse. On a build of that branch, same binary and same server start, it took about 40 ms offprompt_mson these calls (38 to 47 ms across three A/B pairs), and the session state after eachfalserequest was identical whether the root was restored or read again. The PR has the numbers and the traces.@Niko1221 commented on GitHub (Oct 6, 2026):
Fixed in 0.1.40: send "strata_checkpoint": false for a one-shot request to skip the checkpoint (#861).