server : fix checkpoints not being freed when a slot's prompt is cleared - #25647
Closed
AlejandroParedesLT wants to merge 1 commit into
Closed
server : fix checkpoints not being freed when a slot's prompt is cleared#25647AlejandroParedesLT wants to merge 1 commit into
AlejandroParedesLT wants to merge 1 commit into
Conversation
AlejandroParedesLT
requested review from
a team,
ggerganov and
pwilkin
as code owners
July 14, 2026 04:51
|
Hi @AlejandroParedesLT, thanks for your contribution! Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:
Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below. |
…token free request Fixes ggml-org#25437, used claude code to assist with codebase understanding
AlejandroParedesLT
force-pushed
the
fix-checkpoint-leak-25437
branch
from
July 14, 2026 04:57
685331e to
36dff76
Compare
Author
|
Hi @ggerganov, the failing tests: test-thread-safety, test-barrier, test-quantize-fns, test-quantize-perf are not mine. Not sure whether I have to address that, what is the best course of action in this case? |
Member
|
No worries, I'll continue this in #25649 |
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.
Overview
This pull request addresses:
server_slot::prompt_clear() cleared prompt.tokens but not prompt.checkpoints.
Fixes #25437.
Turns out checkpoints hold independent copies of KV-cache state (data_tgt/data_dft/data_spec), so they leaked every time a slot's context (prefix tokens) was cleared/reassigned. fix: added server_prompt::clear() clearing both; prompt_clear() now calls it. I have also added a regression test at tests/test-server-prompt-checkpoints.cpp. Also, the reporter's second suggested fix (excluding checkpoints from server_prompt_cache::alloc()) is already superseded by 6c487e2 upstream, so this PR only implements the smaller scoped fix of clearing the stray checkpoints.
Note that this is an edge case for sliding window attention where prefix context and sliding window need to either have the full slots context or discard the slots. For this specific attention pattern the system is forced to take a snapshot to keep the full context to restore checkpoints (needs full attention map for the corresponding layers + sliding attention context).
Additional information
Fixes #25437
Requirements