Skip to content
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

llama.vim : cache results even if cursor moved #22

Merged
merged 2 commits into from
Jan 10, 2025
Merged

Conversation

ggerganov
Copy link
Member

@ggerganov ggerganov commented Jan 9, 2025

This change improves the cache utilization. Before, we discarded FIM results which were not displayed (for example, because of the cursor moving or the user entering new text). With this change, all FIM results would be cached, regardless if there have been user interactions since the last request.

For example, in the following case, typing he quickly will now reuse the cache result from the h input and the client will send only 1 request to the server (in contrast to sending 2 requests on master):

  • master:
image
  • PR:
image

@ggerganov ggerganov requested a review from VJHack January 9, 2025 08:48
@ggerganov
Copy link
Member Author

Been using this feature today and it works really well. The cache mechanism is really good. When the multiple-generation feature is ready (ggerganov/llama.cpp#11142) we can even cache multiple completions for even better cache utilization.

@VJHack
Copy link
Member

VJHack commented Jan 10, 2025

This is really nice optimization and caching seems to work really well!

Just one thing, I'm experiencing this strange behavior where when I move the cursor to the left in insert mode on a cached completion, it keeps my suggestion displayed inbetween the text I typed. Are you experiencing this as well?

print("Calculating is cached and I moved my cursor to the left a few times. The suggestion doesn't disappear. Let me know if you can reproduce.
Screen Shot 2025-01-09 at 10 48 47 PM

@ggerganov
Copy link
Member Author

Yes, I can reproduce it. It's behaving like this also on master, so it's not caused by the changes in this PR.

@ggerganov
Copy link
Member Author

Should be fixed now: cf684b4

Copy link
Member

@VJHack VJHack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Works very well and thanks for taking care of the caching bug.

@ggerganov ggerganov merged commit 3ffd252 into master Jan 10, 2025
@ggerganov ggerganov deleted the gg/cache-improve branch January 10, 2025 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants