-
Notifications
You must be signed in to change notification settings - Fork 13.7k
memory: Hybrid context shift #17009
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ggerganov
merged 5 commits into
ggml-org:master
from
gabe-l-hart:HybridContextShift-16768
Nov 10, 2025
Merged
memory: Hybrid context shift #17009
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4fb572c
feat(memory): Only fail partial erasure of recurrent tail
gabe-l-hart 24aff7f
fix(main): Check the output of seq_rm for prefix matching
gabe-l-hart 3b59021
fix(memory): Fix condition for partial erasure failure if p0 > pos
gabe-l-hart b8f9c56
style: Fix extra parens
gabe-l-hart 104d8ac
fix(main.cpp): Set n_matching_session_tokens to 0 on cache clear
gabe-l-hart File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if this will correctly trigger reevaluation of the context afterwards.
n_matching_session_tokensseems to be used mostly for cosmetic purposes except when it's equal toembd_inp.size(), so maybe it could be set to0.But I think there might be something else necessary here. (For example, should
session_tokensbe cleared?)(This is mostly relevant when reloading a saved session, and not necessarily during context shifting, though)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, yeah, I'm still a little murky on the logic going on here. I'll look more carefully and see what I can find.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry folks,
I am new to merge management of commits.
b8f9c56923ab34bf24d4fe5476efe9b02736918d
Don't know who and when presses merge button for the commit after all checks are passed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we're holding on this until I resolve the question in this thread. I'll try to get to that today!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I see what you're getting at here with the clause below that recalculates the cached logits for the final token. I think the right thing to do here is to set
n_matching_session_tokensto0since we're essentially saying there are no matching tokens anymore.