[PR #11611] kvcache: Enable SWA to retain additional entries #13593

Closed
opened 2026-04-13 00:30:50 -05:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/ollama/ollama/pull/11611

State: closed
Merged: Yes


Models that use sliding window attention can only resume a sequence from the cache if it falls within the saved windows. This works well if the next message picks up where the old one left off. However, it generally prevents a partial prefix match unless the entire conversation falls within the sliding window.

This can be a problem with reasoning models where the traces are supposed to be removed from future messages, forcing the entire history to be re-evaluated.

This change allows models to specify that a larger amount of the history be retained in memory, to allow more partial resumption. It still respects the window that the model was trained on for token generation.

**Original Pull Request:** https://github.com/ollama/ollama/pull/11611 **State:** closed **Merged:** Yes --- Models that use sliding window attention can only resume a sequence from the cache if it falls within the saved windows. This works well if the next message picks up where the old one left off. However, it generally prevents a partial prefix match unless the entire conversation falls within the sliding window. This can be a problem with reasoning models where the traces are supposed to be removed from future messages, forcing the entire history to be re-evaluated. This change allows models to specify that a larger amount of the history be retained in memory, to allow more partial resumption. It still respects the window that the model was trained on for token generation.
GiteaMirror added the pull-request label 2026-04-13 00:30:50 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#13593