Skip to content

server : fix checkpoints not being freed when a slot's prompt is cleared - #25647

Closed
AlejandroParedesLT wants to merge 1 commit into
ggml-org:masterfrom
AlejandroParedesLT:fix-checkpoint-leak-25437
Closed

server : fix checkpoints not being freed when a slot's prompt is cleared#25647
AlejandroParedesLT wants to merge 1 commit into
ggml-org:masterfrom
AlejandroParedesLT:fix-checkpoint-leak-25437

Conversation

@AlejandroParedesLT

@AlejandroParedesLT AlejandroParedesLT commented Jul 14, 2026

Copy link
Copy Markdown

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

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: YES | Understand the code base

@AlejandroParedesLT
AlejandroParedesLT requested review from a team, ggerganov and pwilkin as code owners July 14, 2026 04:51
@github-actions github-actions Bot added testing Everything test related server labels Jul 14, 2026
@AlejandroParedesLT AlejandroParedesLT changed the title Prune checkpoints after request for prune prefix is sent server : fix checkpoints not being freed when a slot's prompt is cleared Jul 14, 2026
@ggml-gh-bot

ggml-gh-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

Hi @AlejandroParedesLT, thanks for your contribution!

Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:

  • PR Template not respected: Please respect the template when creating a new pull request. Make sure to fill out all required sections.

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
AlejandroParedesLT force-pushed the fix-checkpoint-leak-25437 branch from 685331e to 36dff76 Compare July 14, 2026 04:57
@ggerganov ggerganov self-assigned this Jul 14, 2026
@AlejandroParedesLT

Copy link
Copy Markdown
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?

@ggerganov

Copy link
Copy Markdown
Member

No worries, I'll continue this in #25649

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

server testing Everything test related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

prompt_clear() doesn't free checkpoints

2 participants