Skip to content

[Executorch][llm] Enable leveraging ring kv cache via module swap #10835

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

Open
wants to merge 4 commits into
base: gh/kimishpatel/187/orig
Choose a base branch
from

Conversation

pytorchbot
Copy link
Collaborator

This PR was created by the merge bot to help merge the original PR into the main branch.
ghstack PR number: #10611 by @kimishpatel
^ Please use this as the source of truth for the PR details, comments, and reviews
ghstack PR base: https://github.com/pytorch/executorch/tree/gh/kimishpatel/188/base
ghstack PR head: https://github.com/pytorch/executorch/tree/gh/kimishpatel/188/head
Merge bot PR base: https://github.com/pytorch/executorch/tree/gh/kimishpatel/187/orig
Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/kimishpatel/188/orig
@diff-train-skip-merge

Pull Request resolved: #10608

Introduced CachePositionManager to keep track of what is the position for each slot in ring kv cache. This is used to generate mask.
ghstack-source-id: 283404678
@exported-using-ghexport

Differential Revision: [D73891427](https://our.internmc.facebook.com/intern/diff/D73891427/)
… to MHA

Pull Request resolved: #10609

Leveraging previous work now we allow MHA to have ring buffer cache. If ring buffer cache is used
then we query the mask from kv cache and use that for sdpa instead of using precalculated mask.

In this process we had to adjsut ring buffer implementation to allow keeping the context of
full sliding window. See code for comment.
ghstack-source-id: 283404675
@exported-using-ghexport

Differential Revision: [D73891425](https://our.internmc.facebook.com/intern/diff/D73891425/)
Pull Request resolved: #10610

This allows us to use ring buffer kv cache
ghstack-source-id: 283404676
@exported-using-ghexport

Differential Revision: [D73891424](https://our.internmc.facebook.com/intern/diff/D73891424/)
Pull Request resolved: #10611

This allows us to make some of the attention modules to use sliding window kv cache. Will help enable models like gemma3.
ghstack-source-id: 283404677

Differential Revision: [D73891426](https://our.internmc.facebook.com/intern/diff/D73891426/)
Copy link

pytorch-bot bot commented May 13, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/10835

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit ed32169 with merge base bf50527 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 13, 2025
@kimishpatel kimishpatel force-pushed the gh/kimishpatel/187/orig branch from bfcaf89 to b994a1a Compare May 13, 2025 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants