Skip to content

Fix the fused QKV resize check for dual-route projections - #24033

Open
psiddh wants to merge 1 commit into
pytorch:mainfrom
psiddh:export-D126153972
Open

psiddh wants to merge 1 commit into
pytorch:mainfrom
psiddh:export-D126153972

Conversation

@psiddh

@psiddh psiddh commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Summary:
On GPUs with shader-f16, Llama 3.2 1B's Q/K/V projections are fused by QkvBk64. When the live M doesn't use the fused kernel (any M other than 128, 508 or 512, including decode), the fusion's resize hook checks that the separate projections restored their dispatches. It required every dispatch in each member's range to be live. With a dynamic M each linear_q4gsw member records a decode and a prefill route, and select_dispatch_route keeps the inactive route at a zero grid, so the check threw on every unfused call: "linear_q4gsw_bk64_qkv(resize): separate projection dispatch was not restored before the QKV resize hook ran".

This breaks Llama 3.2 1B chat in the ExecuTorch WebGPU Playground on executorch.ai on Apple GPUs (reported on Metal 3). The check now requires one live dispatch per member, which still catches a member whose hook didn't run.

CI runs on SwiftShader, which has no shader-f16, so the fused path and DynamicShape.QkvBk64LiveRoutesProfile (M = 128, 1, 128) don't run there.

Differential Revision: D126153972

Summary:
On GPUs with `shader-f16`, Llama 3.2 1B's Q/K/V projections are fused by `QkvBk64`. When the live M doesn't use the fused kernel (any M other than 128, 508 or 512, including decode), the fusion's resize hook checks that the separate projections restored their dispatches. It required every dispatch in each member's range to be live. With a dynamic M each `linear_q4gsw` member records a decode and a prefill route, and `select_dispatch_route` keeps the inactive route at a zero grid, so the check threw on every unfused call: "linear_q4gsw_bk64_qkv(resize): separate projection dispatch was not restored before the QKV resize hook ran".

This breaks Llama 3.2 1B chat in the ExecuTorch WebGPU Playground on executorch.ai on Apple GPUs (reported on Metal 3). The check now requires one live dispatch per member, which still catches a member whose hook didn't run.

CI runs on SwiftShader, which has no `shader-f16`, so the fused path and `DynamicShape.QkvBk64LiveRoutesProfile` (M = 128, 1, 128) don't run there.

Differential Revision: D126153972
Copilot AI balanced review requested due to automatic review settings October 21, 2026 05:15
@pytorch-bot

pytorch-bot Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ No Failures

As of commit 5ae9624 with merge base 20675ac (image):
💚 Looks good so far! There are no failures yet. 💚

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 Oct 21, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@meta-codesync

meta-codesync Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

@psiddh has exported this pull request. If you are a Meta employee, you can view the originating Diff in D126153972.

@github-actions

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.

@psiddh
psiddh requested review from SS-JIA and digantdesai October 21, 2026 05:16

This branch has not been deployed

No deployments
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. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants