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

[WIP] drafting a fix - cropping the kv cache #6

Closed
wants to merge 1 commit into from

Conversation

keyboardAnt
Copy link
Owner

@keyboardAnt keyboardAnt commented Dec 6, 2024

It seems like we haven't been cropping the KV cache. This PR adds the missing functionality and hopefully addresses the issue raised in huggingface#35029 (comment)

Copy link
Collaborator

@jmamou jmamou left a comment

Choose a reason for hiding this comment

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

Contrarily to UAG, I don't think we need to set remove_from_pkv > 0 in USD (like in regular AG/SD) since draft/target tokens are aligned

@keyboardAnt
Copy link
Owner Author

Contrarily to UAG, I don't think we need to set remove_from_pkv > 0 in USD (like in regular AG/SD) since draft/target tokens are aligned

How does the KV cache get updated after rejecting draft tokens?

@jmamou
Copy link
Collaborator

jmamou commented Dec 8, 2024

Contrarily to UAG, I don't think we need to set remove_from_pkv > 0 in USD (like in regular AG/SD) since draft/target tokens are aligned

How does the KV cache get updated after rejecting draft tokens?

new_cache_size = input_ids.shape[-1] - 1
self.assistant_kwargs["past_key_values"] = _crop_past_key_values(
    self.assistant_model, self.assistant_kwargs["past_key_values"], new_cache_size - 1
)

Here, input_ids corresponds to assistant_input_ids with validated token only + additional token(s) from the target validation

@gauravjain14 gauravjain14 mentioned this pull request Dec 9, 2024
@gauravjain14
Copy link
Collaborator

@keyboardAnt - Is this change still applicable if #7 is merged?

@jmamou
Copy link
Collaborator

jmamou commented Dec 10, 2024

@keyboardAnt - Is this change still applicable if #7 is merged?

@gauravjain14 no

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.

3 participants