Skip to content

Apply hybrid/recurrent checkpoint fix - #1

Merged
tomny-dev merged 2 commits into
masterfrom
tmp-pr25592
Aug 16, 2026
Merged

Apply hybrid/recurrent checkpoint fix#1
tomny-dev merged 2 commits into
masterfrom
tmp-pr25592

Conversation

@tomny-dev

Copy link
Copy Markdown
Collaborator

Ports upstream llama.cpp PR ggml-org#25592 onto this fork so Qwen hybrid/recurrent models restore context checkpoints only at valid exact positions and avoid unnecessary full prompt reprocessing in agentic workloads.

krim added 2 commits July 14, 2026 18:21
…g#24055)

The recurrent state is only valid at the exact position it was saved at,
but checkpoints claimed the whole [pos_min, pos_max] range reported by the
memory module, and restoring relied on that by accident. Record the actual
position instead and only restore a checkpoint when that position is still
inside the common prefix of the new prompt. Also erase checkpoints that
overlap edited history - once the new tokens are decoded they would look
valid again while holding state from content that no longer exists.

While at it, make the cache actually useful for agentic clients that strip
reasoning from previous turns: always checkpoint near the end of the prompt
(that is where the next request diverges), evict the checkpoint closest to
its neighbor instead of the oldest one so early anchors survive compaction,
try the bounded n_rs_seq rollback before searching checkpoints, and log
checkpoint activity at INFO so you can see what the cache is doing without
-lv.
…ckpoints

The n_rs_seq rollback snapshots are only guaranteed valid for tokens
decoded in the last ubatch, so rolling back across decode boundaries
could silently restore a stale state - always go through the checkpoint
path instead. Adopt a restored checkpoint into the current task so the
min-step eviction does not erase it, compare the stale bound in position
space (mtmd positions differ from token counts), and keep range (SWA)
checkpoints at the exact divergence position since resuming overwrites
that entry anyway.
@tomny-dev tomny-dev closed this Aug 16, 2026
@tomny-dev tomny-dev reopened this Aug 16, 2026
@tomny-dev
tomny-dev merged commit d29a9ec into master Aug 16, 2026
2 of 44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant