Skip to content

Enable use_sdpa_with_kv_cache in the qwen3_5 example config - #22390

Merged
JakeStevens merged 1 commit into
pytorch:mainfrom
john-rocky:qwen3_5-sdpa-kv-cache
Sep 1, 2026
Merged

Enable use_sdpa_with_kv_cache in the qwen3_5 example config#22390
JakeStevens merged 1 commit into
pytorch:mainfrom
john-rocky:qwen3_5-sdpa-kv-cache

Conversation

@john-rocky

@john-rocky john-rocky commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Fixes #22045.

use_sdpa_with_kv_cache: False in this config costs roughly 2x decode. @JakeStevens confirmed in the issue there is no known reason to keep it off, and the lfm2 config — the same hybrid attention/conv architecture — already sets it True.

Measured on Qwen3.5-2B, XNNPACK, 8da4w + 8-bit embedding, the same checkpoint exported twice with only this line different (Mac arm64, token-by-token prefill then greedy decode, same prompt, 32 new tokens):

decode
use_sdpa_with_kv_cache: False 8.20 tok/s
use_sdpa_with_kv_cache: True 16.64 tok/s

That it is the same model rather than a faster different one: three of four prompts decode token-identically (the fourth diverges inside <think>, a near-tie either way), first-step logits corr 0.995 with the same top-1, and at 338 tokens of context corr 0.990 with the same top-1 and top-2. File size is unchanged (1483 MB both).

cc @mergennachin @iseeyuan @lucylq @helunwencser @tarun292 @kimishpatel @jackzhxng

The flag being off costs roughly 2x decode on XNNPACK (8.20 -> 16.64
tok/s on Qwen3.5-2B 8da4w, Mac arm64) while producing the same tokens;
the lfm2 config, the same hybrid attention/conv architecture, already
sets it True. Discussed in pytorch#22045.
@pytorch-bot

pytorch-bot Bot commented Sep 1, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 3 New Failures, 2 Unrelated Failures, 1 Unclassified Failure

As of commit 43a8387 with merge base f5102b8 (image):

NEW FAILURES - The following jobs have failed:

UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:

  • periodic (gh) (this job did not run on the merge base, so DrCI cannot tell whether the failure is pre-existing)

FLAKY - The following job failed but was likely due to flakiness present on trunk:

BROKEN TRUNK - The following job failed but was present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

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

@meta-cla meta-cla 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 Sep 1, 2026
@github-actions

github-actions Bot commented Sep 1, 2026

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.

@JakeStevens JakeStevens added module: extension Issues related to code under extension/ module: examples Issues related to demos under examples/ and removed module: extension Issues related to code under extension/ labels Sep 1, 2026
@JakeStevens
JakeStevens merged commit 5b829f9 into pytorch:main Sep 1, 2026
234 of 243 checks passed
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. module: examples Issues related to demos under examples/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

qwen3_5 example config leaves use_sdpa_with_kv_cache off, which costs 2x decode

3 participants