Skip to content

Fix prompt cache leak between conversations#1039

Open
kernelpool wants to merge 2 commits intoml-explore:mainfrom
kernelpool:fix-prompt-cache-leak
Open

Fix prompt cache leak between conversations#1039
kernelpool wants to merge 2 commits intoml-explore:mainfrom
kernelpool:fix-prompt-cache-leak

Conversation

@kernelpool
Copy link
Copy Markdown
Contributor

@kernelpool kernelpool commented Mar 22, 2026

I ran into an issue where KV caches leak data into new conversations (using GLM-5), and believe this addresses it.

After the checkpoint save, the remaining prompt tokens were fed through the model twice (once for prefill, then all of them again through _step). This inflated the KV cache offset, so trimming it for a new conversation would leave stale tokens from the previous one.

Example:

Screenshot 2026-03-24 at 1 13 35 pm

@angeloskath
Copy link
Copy Markdown
Member

Thanks for flagging this. I am working on revamping the batch generation in general to support multiple checkpoints and ensure the cache key always contains all the processed tokens etc.

@angeloskath
Copy link
Copy Markdown
Member

Should be fixed in #1072 . Feel free to test it and close it is fine on my testing at least.

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.

2 participants