Repository navigation
prompt cache: long conversations survive 8-16 concurrent agents - #2699
Conversation
…the pre-check's room saturates From the independent review of round four: with no outside promise, a freed or spare buffer may take the state for less than a fresh buffer's bytes, so the pre-check no longer refuses it. README keeps main's text, with the prompt cache row describing the new defaults.
2baf1b9 to
c81e58a
Compare
|
Device results on this PR's head ( Qwen3.8-27B, M3 Ultra (Metal), default cache budget
With a 16 GiB cache budget (a smaller Mac): 8 agents 50.1 s → 1.38 s, 16 agents 546 s → 47.2 s, replies equal. Qwen3.8-27B, GB10 (CUDA)
16 GiB budget: 16 agents 105 s → 36.3 s, replies equal. Qwen3.8-Flash-Next, GB10 (CUDA): level with main at 1-16 agents (16 agents: 32.3 → 32.3 tok/s follow-up), replies equal. Its cache on this box holds about one conversation, so follow-ups still miss there; that's separate work. First-turn speed is unchanged everywhere (Metal 16 agents 6.0 → 8.8 tok/s, CUDA 31.4 → 31.3). |
Figures corrected to the PRs' measured ones (#2699 head runs, #2509, #2633, #2436, #2644, #2593, #2430, #2568), scope fixed (#2253, #2287, #2511, #2569, #2337, #2627, #2351, #2626), unsourced figures dropped (#2181, #2606, #2257's pricing clauses), the shipped #2176, #2565, #2548 and gfx12 silu entries and the first #2625 copy removed, and the #2568 and #2352 entries unwrapped to one line each.
…the dashboard (ashhart#2655) The branch's six commits squashed and rebased onto main after ashhart#2699. The `seen` updates move with the functions ashhart#2699 moved: a resume in `prompt_cache_lifetime.zig` (`resumedWithReason`), a re-keep and a new entry in `prompt_cache_keep.zig` (`keepBorn`); the shared-cut entry in `prompt_cache.zig` keeps its own. `used` stays the store's clock.
…the dashboard (ashhart#2655) The branch's six commits squashed and rebased onto main after ashhart#2699. The `seen` updates move with the functions ashhart#2699 moved: a resume in `prompt_cache_lifetime.zig` (`resumedWithReason`), a re-keep and a new entry in `prompt_cache_keep.zig` (`keepBorn`); the shared-cut entry in `prompt_cache.zig` keeps its own. `used` stays the store's clock.
…the dashboard (ashhart#2655) The branch's six commits squashed and rebased onto main after ashhart#2699. The `seen` updates move with the functions ashhart#2699 moved: a resume in `prompt_cache_lifetime.zig` (`resumedWithReason`), a re-keep and a new entry in `prompt_cache_keep.zig` (`keepBorn`); the shared-cut entry in `prompt_cache.zig` keeps its own. `used` stays the store's clock.
…the dashboard (#2655) The branch's six commits squashed and rebased onto main after #2699. The `seen` updates move with the functions #2699 moved: a resume in `prompt_cache_lifetime.zig` (`resumedWithReason`), a re-keep and a new entry in `prompt_cache_keep.zig` (`keepBorn`); the shared-cut entry in `prompt_cache.zig` keeps its own. `used` stays the store's clock.
Scope and figures corrected to the PRs (#2700, #2670, #2338, #2491, #2680, #2557, #2597, #2760's load time, #2753's verify-row wait, #2681's ledger row), #2831's and #2682's lines rewritten to what the code does, #2709 given its own line above #2609's, the duplicate #2404, #2576, #2597 and #2699 entries and the copy of #2609's line under 1.2.6 removed, entries spaced one blank line apart, and the released sections restored to the v1.2.6 tag's text (#1651's 1.2.2 line and six blank lines in 1.2.5 and older).
Since ashhart#2699 the victim order keeps each conversation's newest state before redundant copies. A ladder checkpoint was exempt from the superseded pick, so once the plain redundant copies were gone the oldest state went next, which could be another conversation's newest. A superseded checkpoint now goes after every other redundant copy and before any newest state. Under a reservation guard, fitting took the marks in position order, so the low ladder positions could take the room the rewind state needed. Ladder positions now fit last, after the endpoint and every other mark, in the room other passes' promises leave. Co-authored-by: javierbits <[email protected]>
Since ashhart#2699 the victim order keeps each conversation's newest state before redundant copies. A ladder checkpoint was exempt from the superseded pick, so once the plain redundant copies were gone the oldest state went next, which could be another conversation's newest. A superseded checkpoint now goes after every other redundant copy and before any newest state. Under a reservation guard, fitting took the marks in position order, so the low ladder positions could take the room the rewind state needed. Ladder positions now fit last, after the endpoint and every other mark, in the room other passes' promises leave. Co-authored-by: javierbits <[email protected]>
Since #2699 the victim order keeps each conversation's newest state before redundant copies. A ladder checkpoint was exempt from the superseded pick, so once the plain redundant copies were gone the oldest state went next, which could be another conversation's newest. A superseded checkpoint now goes after every other redundant copy and before any newest state. Under a reservation guard, fitting took the marks in position order, so the low ladder positions could take the room the rewind state needed. Ladder positions now fit last, after the endpoint and every other mark, in the room other passes' promises leave. Co-authored-by: javierbits <[email protected]>
What this changes
When 8 to 16 agents with long conversations send their follow-ups at once, the prompt cache used to evict exactly the states those follow-ups needed. Every follow-up then prefilled its whole conversation again. On Qwen3.8-27B with DFlash2, the median first token for a follow-up reached 50 s at 8 agents and 546 s at 16 on an M3 Ultra, and 114 s at 16 on a GB10. Three things caused it:
Now:
--prompt-cache-gibstill overrides it.Cache policy changes only which states are kept. Lookup and restore are unchanged, so no reply's tokens change.
Measured
A follow-up harness: N agents, each with its own ~17k-token conversation, send turn 1 together, then all follow-ups together. Temperature 0, thinking off, Qwen3.8-27B MLX 4-bit with DFlash2. Every reply in both turns matched main's token for token, at every N.
These numbers are from the change's second round. The last rounds change only refusal and accounting corners, and the runs on this exact head are in progress. They'll be posted here before it lands.
Checks
zig fmt --check, the lean check (no new problems), and source files at most 600 lines.Not covered here
The remaining wait at 16 agents is the 8 stream slots a server opens by default, so half the agents queue. That's a separate design.