Skip to content

[Executorch][llm] Fix ring kv cache when used with quantized kv cache and sdpa#12132

Merged
facebook-github-bot merged 1 commit into
gh/kimishpatel/196/basefrom
gh/kimishpatel/196/head
Jul 1, 2025
Merged

[Executorch][llm] Fix ring kv cache when used with quantized kv cache and sdpa#12132
facebook-github-bot merged 1 commit into
gh/kimishpatel/196/basefrom
gh/kimishpatel/196/head

Conversation

@kimishpatel

@kimishpatel kimishpatel commented Jul 1, 2025

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

When using quantized kv cache and SDPA, there was two bugs:

  1. It did not reset return_float_values of QuantizedRingKVCache. Which results in QuantizedKVCache returning float values post dequant.
  2. For quantized kv cache, SDPA module stores kv_cache that is owned by attention module. When replacing kv cache in Attention we have to make sure that we change the reference in SDPA as well.

Differential Revision: D77516823

… and sdpa

When using quantized kv cache and SDPA, there was two bugs:
1. It did not reset return_float_values of QuantizedRingKVCache. Which results in QuantizedKVCache returning float values post dequant.
2. For quantized kv cache, SDPA module stores kv_cache that is owned by attention module. When replacing kv cache in Attention we have to make sure that we change the reference in SDPA as well.

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

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Jul 1, 2025

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ No Failures

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

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

kimishpatel added a commit that referenced this pull request Jul 1, 2025
… and sdpa

When using quantized kv cache and SDPA, there was two bugs:
1. It did not reset return_float_values of QuantizedRingKVCache. Which results in QuantizedKVCache returning float values post dequant.
2. For quantized kv cache, SDPA module stores kv_cache that is owned by attention module. When replacing kv cache in Attention we have to make sure that we change the reference in SDPA as well.

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

ghstack-source-id: 293661340
Pull Request resolved: #12132
@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 Jul 1, 2025
@facebook-github-bot

Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D77516823

@github-actions

github-actions Bot commented Jul 1, 2025

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@metascroy metascroy self-requested a review July 1, 2025 16:40
@facebook-github-bot facebook-github-bot merged commit 2881e7d into gh/kimishpatel/196/base Jul 1, 2025
102 of 106 checks passed
@facebook-github-bot facebook-github-bot deleted the gh/kimishpatel/196/head branch July 1, 2025 20:12
kimishpatel added a commit that referenced this pull request Jul 3, 2025
… and sdpa (#12143)

This PR was created by the merge bot to help merge the original PR into
the main branch.
ghstack PR number: #12132 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/196/base
ghstack PR head:
https://github.com/pytorch/executorch/tree/gh/kimishpatel/196/head
Merge bot PR base:
https://github.com/pytorch/executorch/tree/gh/kimishpatel/195/orig
Merge bot PR head:
https://github.com/pytorch/executorch/tree/gh/kimishpatel/196/orig
@diff-train-skip-merge

---------

Co-authored-by: Kimish Patel <kimishpatel@fb.com>
Tanish2101 pushed a commit to Tanish2101/executorch that referenced this pull request Jul 9, 2025
… and sdpa (pytorch#12143)

This PR was created by the merge bot to help merge the original PR into
the main branch.
ghstack PR number: pytorch#12132 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/196/base
ghstack PR head:
https://github.com/pytorch/executorch/tree/gh/kimishpatel/196/head
Merge bot PR base:
https://github.com/pytorch/executorch/tree/gh/kimishpatel/195/orig
Merge bot PR head:
https://github.com/pytorch/executorch/tree/gh/kimishpatel/196/orig
@diff-train-skip-merge

---------

Co-authored-by: Kimish Patel <kimishpatel@fb.com>
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. fb-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants