Skip to content

Prompt cache replay: agent-style traces through the real store (#3241, measurement) - #3247

Closed
ashhart wants to merge 1 commit into
mainfrom
lead/cache-agent-replay
Closed

ashhart wants to merge 1 commit into
mainfrom
lead/cache-agent-replay

Conversation

@ashhart

@ashhart ashhart commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

Refs #3241 (prompt cache eviction). Measurement first: this extends the host cache replay with agent-style traces, run through the store's real eviction paths (Store.begin, reservation, keep, lookup, restore, remove). Production eviction is unchanged.

Traces (48 rounds, seed 7) at 4, 8 and 16 GiB of charged snapshot storage:

  • agent_loops: six growing conversations on a shared 8,192-token system prefix, two unique one-offs (1,024 to 12,000 rows) after each agent turn. 864 requests.
  • interleaved_chats: two six-session cohorts with a 2,048-token shared prefix each; the cohort changes halfway. 192 requests.
  • one_off: 384 unique prompts, 256 to 16,384 rows.

Shared cuts now reach the store, so a common system prompt restores as a prefix. A test removes that forwarding and fails as expected (restores 0 instead of 8,192).

A frequency/probation selector was tried against a no-regression gate fixed before it was built. It is rejected:

Trace GiB Main rebuilt rows Trial rebuilt rows Change
agent_loops 4 11,089,888 9,736,160 -12.2%
agent_loops 8 9,705,440 8,680,928 -10.6%
agent_loops 16 9,600,992 7,416,800 -22.8%
interleaved_chats 4 594,176 705,536 +18.7%
interleaved_chats 8 87,040 551,680 +533.8%
interleaved_chats 16 87,040 517,120 +494.1%
one_off all 2,197,760 2,197,760 0

Agent loops gain, but chats lose badly, so main's policy stays. The selector stays in the replay only as a comparison arm, so the next candidate can be measured on the same frozen traces.

Checks on today's main: zig build -Dfixed-cpu compile-cache-replay-host test-cache-replay-host test-cache-agent-host cache-agent-replay exits 0 and prints the same 18 records as the original run. Lean check: 341 problems, same as main. These are host replay counts, not GPU prefill time; no device run is needed because no runtime code changes.

  • Synthena (Ash's Agent)

Six growing agent conversations on a shared 8,192-token system prefix with one-offs between turns, two cohorts of
interleaved chats, and unique one-off prompts, replayed through Store.begin/keep/lookup/restore/remove at 4, 8 and
16 GiB. Shared cuts reach the store, so a common system prompt restores as a prefix. A frequency/probation selector
runs beside main's for comparison; production eviction is unchanged. zig build cache-agent-replay prints the records.

Refs #3241
@ashhart

ashhart commented Nov 17, 2026

Copy link
Copy Markdown
Owner Author

Closing: this PR's only commit is already on main as a45c3e0.

  • Synthena

@ashhart ashhart closed this Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant