Repository navigation
Prompt cache: an opt-in rule that keeps a new state out rather than evict another conversation's (part of #2346) - #2533
Merged
Merged
Conversation
ashhart
force-pushed
the
lead/keep-others
branch
from
November 8, 2026 08:09
7b0de1f to
64cb2a9
Compare
3 of 4 tasks
ashhart
force-pushed
the
lead/keep-others
branch
from
November 8, 2026 09:28
64cb2a9 to
87ea99d
Compare
ashhart
added a commit
that referenced
this pull request
Nov 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #2346. Today, a new prompt state that fits the cache budget evicts other kept states until it fits. One large new session can push out every other conversation's state, even states that were just used. This adds the opt-in rule we described on the issue.
TENSORFOLD_PROMPT_CACHE_KEEP_OTHERS=1(exact 0/1, off by default, CUDA host prompt cache): a new state may evict only its own conversation's states. Those are kept states whose tokens begin the new prompt, that no lookup borrows, and that aren't a shared cut or a branch point. A state that fits only by evicting another conversation's isn't kept: it counts as refused, one log line gives its size and the budget, and every kept state stays. The lookup that makes room before a pass, and learned and disk states read back, follow the same rule. Memory-pressure shedding and a new stream's memory still take any state. Tokens never change, only what's cached. The switch is registered asidenticalincore/profile.zig.victimButwhen the switch is off. The first commit pins today's eviction order on main before the rule exists: a scripted drop order, and a seeded 400-turn run with its drop hash, refusals, keeps, hits and bytes. The second commit leaves those pins unchanged.--context, or edited and sent again) no longer owns its older states, so with the switch on those can keep its new states out until memory pressure sheds them.Host tests pass, and lean shows nothing new. Before anyone recommends turning it on, the decision asks for
tools/zig/bench_sessions.pynumbers, main against branch, on a GB10.