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

Fix: Discard KV cache for last token before reusing prompt cache for prompt + suffix #79

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sannat17
Copy link

@sannat17 sannat17 commented Oct 21, 2024

fix #78

@sannat17
Copy link
Author

sannat17 commented Oct 22, 2024

I must note that a more robust way to handle this would have been to compare the tokens from the INITIAL_PROMPT to the first few tokens of new_inputs, and discard the cache for tokens following the first mismatched token.

However, in case of Llama tokenizers this token can only be the last token so just discarding its cache as a rule seems like an easier fix.

@sannat17 sannat17 marked this pull request as draft October 26, 2024 06:12
@sannat17 sannat17 marked this pull request as ready for review October 26, 2024 06:12
@sannat17
Copy link
Author

@ArthurZucker I'm wondering what are you thoughts on this fix since you introduced the prompt_reuse recipe

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.

Models's output from recipe with prompt reuse optimization does not match the non-cached generation
1 participant