Skip to content

[ExecuTorch][WebGPU] Replace broad QKV fusion with BK64 kernel - #21131

Merged
meta-codesync[bot] merged 11 commits into
gh/JCNTH/107/basefrom
gh/JCNTH/107/head
Aug 7, 2026
Merged

[ExecuTorch][WebGPU] Replace broad QKV fusion with BK64 kernel#21131
meta-codesync[bot] merged 11 commits into
gh/JCNTH/107/basefrom
gh/JCNTH/107/head

Conversation

@JCNTH

@JCNTH JCNTH commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

The previously landed broad QKV fusion applied too widely and did not match the
BK64 schedule now used for the ordinary projections. This corrective diff
replaces it with a capability- and geometry-qualified BK64 kernel that fuses the
exact Llama Q/K/V projection triple at live M128, M508, and M512, packing the
constant weights and scales once and scattering the result into three distinct
planner-safe outputs. Outside the accepted shapes it switches atomically back
to the ordinary Steel and bicol routes, and it deletes the obsolete broad
shader and header so only one QKV path remains. Mirrors Vulkan
xplat/executorch/backends/vulkan/runtime/graph/ops/glsl/q4gsw_linear_gemm__w_4x8.glsl
for the per-projection GEMM; the three-output fusion itself is WebGPU-specific.

Key changes:

  • Adds runtime/ops/quantized_linear/q4gsw_qkv_bk64.wgsl (+ generated header);
    removes the obsolete q4gsw_linear_gemm_qkv_fused shader and header.
  • WebGPUGraph.{cpp,h}: geometry and capability predicate, one-time constant
    packing, distinct Q/K/V outputs, and atomic fallback to Steel/bicol.
    @exported-using-ghexport

Differential Revision: D113171749

Differential Revision: D113171749

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 26 New Failures, 30 Pending

As of commit 72b6031 with merge base 28a7fac (image):

NEW FAILURES - The following jobs have failed:

  • Cadence Build & Test / cpu-test / test-aot / test-aot (gh)
    ##[error]API rate limit exceeded for installation. If you reach out to GitHub Support for help, please include the request ID E982:F0321:49FF57A:FAE1194:6A760B8E and timestamp 2026-08-07 16:45:02 UTC. For more on scraping GitHub and how it may affect your rights, please review our Terms of Service (https://docs.github.com/en/site-policy/github-terms/github-terms-of-service) - https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api#rate-limiting
  • Cadence Build & Test / cpu-test / test-ops / test-ops (gh)
    ##[error]API rate limit exceeded for installation. If you reach out to GitHub Support for help, please include the request ID C2EE:6D448:834BAAA:1B9D7A6D:6A760B5D and timestamp 2026-08-07 16:44:14 UTC. For more on scraping GitHub and how it may affect your rights, please review our Terms of Service (https://docs.github.com/en/site-policy/github-terms/github-terms-of-service) - https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api#rate-limiting
  • pull / nxp-build-test / linux-job (gh)
    ##[error]API rate limit exceeded for installation. If you reach out to GitHub Support for help, please include the request ID 983E:1638AE:3878FF3:BFF6BA8:6A760BCC and timestamp 2026-08-07 16:46:04 UTC. For more on scraping GitHub and how it may affect your rights, please review our Terms of Service (https://docs.github.com/en/site-policy/github-terms/github-terms-of-service) - https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api#rate-limiting
  • pull / test-llama_runner_eager-linux / linux-job (gh)
    ##[error]API rate limit exceeded for installation. If you reach out to GitHub Support for help, please include the request ID 989E:1677CB:8869600:1C7F2160:6A760BB8 and timestamp 2026-08-07 16:45:44 UTC. For more on scraping GitHub and how it may affect your rights, please review our Terms of Service (https://docs.github.com/en/site-policy/github-terms/github-terms-of-service) - https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api#rate-limiting
  • pull / test-lora-linux / linux-job (gh)
    ##[error]API rate limit exceeded for installation. If you reach out to GitHub Support for help, please include the request ID B50C:362BDF:38C2CBD:C12D31E:6A760BAB and timestamp 2026-08-07 16:45:31 UTC. For more on scraping GitHub and how it may affect your rights, please review our Terms of Service (https://docs.github.com/en/site-policy/github-terms/github-terms-of-service) - https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api#rate-limiting
  • pull / test-mediatek-models-linux / linux-job (gh)
    ##[error]An error occurred trying to start process '/usr/bin/bash' with working directory '/home/ec2-user/actions-runner/_work/executorch/executorch/pytorch/executorch'. No such file or directory
  • pull / test-models-linux (emformer_join, portable, linux.4xlarge.memory) / linux-job (gh)
    ##[error]API rate limit exceeded for installation. If you reach out to GitHub Support for help, please include the request ID EC2A:437B0:4B3C46D:FE80CF9:6A760B45 and timestamp 2026-08-07 16:43:49 UTC. For more on scraping GitHub and how it may affect your rights, please review our Terms of Service (https://docs.github.com/en/site-policy/github-terms/github-terms-of-service) - https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api#rate-limiting
  • pull / test-models-linux (emformer_join, xnnpack-quantization-delegation, linux.4xlarge.memory) / linux-job (gh)
    ##[error]API rate limit exceeded for installation. If you reach out to GitHub Support for help, please include the request ID EA44:2069FC:33C0722:B0618F1:6A760B4D and timestamp 2026-08-07 16:43:57 UTC. For more on scraping GitHub and how it may affect your rights, please review our Terms of Service (https://docs.github.com/en/site-policy/github-terms/github-terms-of-service) - https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api#rate-limiting
  • pull / test-models-linux (ic4, xnnpack-quantization-delegation, linux.4xlarge.memory) / linux-job (gh)
    ##[error]API rate limit exceeded for installation. If you reach out to GitHub Support for help, please include the request ID CCA6:3AEFE2:8ED27D3:1E1337B4:6A760B31 and timestamp 2026-08-07 16:43:30 UTC. For more on scraping GitHub and how it may affect your rights, please review our Terms of Service (https://docs.github.com/en/site-policy/github-terms/github-terms-of-service) - https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api#rate-limiting
  • pull / test-models-linux (llama3_2_vision_encoder, portable, linux.4xlarge.memory) / linux-job (gh)
    ##[error]API rate limit exceeded for installation. If you reach out to GitHub Support for help, please include the request ID D234:10292D:36D24AB:BA571DF:6A760B37 and timestamp 2026-08-07 16:43:35 UTC. For more on scraping GitHub and how it may affect your rights, please review our Terms of Service (https://docs.github.com/en/site-policy/github-terms/github-terms-of-service) - https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api#rate-limiting
  • pull / test-models-linux (phi_4_mini, portable, linux.4xlarge.memory) / linux-job (gh)
    ##[error]An error occurred trying to start process '/usr/bin/bash' with working directory '/home/ec2-user/actions-runner/_work/executorch/executorch/pytorch/executorch'. No such file or directory
  • pull / test-models-linux (w2l, portable, linux.4xlarge.memory) / linux-job (gh)
    ##[error]An error occurred trying to start process '/usr/bin/bash' with working directory '/home/ec2-user/actions-runner/_work/executorch/executorch/pytorch/executorch'. No such file or directory
  • pull / test-models-linux-basic (mv3, portable, buck2, linux.2xlarge, executorch-ubuntu-22.04-clang12) / linux-job (gh)
    ##[error]API rate limit exceeded for installation. If you reach out to GitHub Support for help, please include the request ID BCB6:35A344:38DFD1B:C1D662F:6A760BC3 and timestamp 2026-08-07 16:45:55 UTC. For more on scraping GitHub and how it may affect your rights, please review our Terms of Service (https://docs.github.com/en/site-policy/github-terms/github-terms-of-service) - https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api#rate-limiting
  • pull / test-models-linux-basic (mv3, portable, cmake, linux.2xlarge, executorch-ubuntu-22.04-clang12) / linux-job (gh)
    ##[error]API rate limit exceeded for installation. If you reach out to GitHub Support for help, please include the request ID CF3E:3E7121:359A4D1:B67317A:6A760BB7 and timestamp 2026-08-07 16:45:43 UTC. For more on scraping GitHub and how it may affect your rights, please review our Terms of Service (https://docs.github.com/en/site-policy/github-terms/github-terms-of-service) - https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api#rate-limiting
  • pull / test-models-linux-basic (mv3, xnnpack-quantization-delegation, cmake, linux.2xlarge, executorch-u... / linux-job (gh)
    ##[error]API rate limit exceeded for installation. If you reach out to GitHub Support for help, please include the request ID B7B4:96F6E:4CC5217:1049144D:6A760BD0 and timestamp 2026-08-07 16:46:08 UTC. For more on scraping GitHub and how it may affect your rights, please review our Terms of Service (https://docs.github.com/en/site-policy/github-terms/github-terms-of-service) - https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api#rate-limiting
  • pull / test-models-linux-basic (vit, portable, buck2, linux.2xlarge, executorch-ubuntu-22.04-clang12) / linux-job (gh)
    ##[error]An error occurred trying to start process '/usr/bin/bash' with working directory '/home/ec2-user/actions-runner/_work/executorch/executorch/pytorch/executorch'. No such file or directory
  • pull / test-models-linux-basic (vit, xnnpack-quantization-delegation, buck2, linux.2xlarge, executorch-u... / linux-job (gh)
    ##[error]API rate limit exceeded for installation. If you reach out to GitHub Support for help, please include the request ID A8C0:2FFF42:4CAC1AF:1037D3EF:6A760BD6 and timestamp 2026-08-07 16:46:14 UTC. For more on scraping GitHub and how it may affect your rights, please review our Terms of Service (https://docs.github.com/en/site-policy/github-terms/github-terms-of-service) - https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api#rate-limiting
  • pull / test-models-linux-basic (vit, xnnpack-quantization-delegation, cmake, linux.2xlarge, executorch-u... / linux-job (gh)
    ##[error]API rate limit exceeded for installation. If you reach out to GitHub Support for help, please include the request ID 9AEA:30BA9A:39BD021:C529783:6A760BC3 and timestamp 2026-08-07 16:45:55 UTC. For more on scraping GitHub and how it may affect your rights, please review our Terms of Service (https://docs.github.com/en/site-policy/github-terms/github-terms-of-service) - https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api#rate-limiting
  • pull / test-multimodal-linux (gemma3-4b) / linux-job (gh)
    ##[error]API rate limit exceeded for installation. If you reach out to GitHub Support for help, please include the request ID C7E8:7E39:8EC44B9:1E3ACAF0:6A760BCA and timestamp 2026-08-07 16:46:02 UTC. For more on scraping GitHub and how it may affect your rights, please review our Terms of Service (https://docs.github.com/en/site-policy/github-terms/github-terms-of-service) - https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api#rate-limiting
  • pull / test-qnn-direct-build-linux / linux-job (gh)
    ##[error]API rate limit exceeded for installation. If you reach out to GitHub Support for help, please include the request ID D60A:1677CB:88778F9:1C8220AC:6A760BD2 and timestamp 2026-08-07 16:46:10 UTC. For more on scraping GitHub and how it may affect your rights, please review our Terms of Service (https://docs.github.com/en/site-policy/github-terms/github-terms-of-service) - https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api#rate-limiting
  • pull / test-qnn-wheel-packages-linux (3.10) / linux-job (gh)
    ##[error]API rate limit exceeded for installation. If you reach out to GitHub Support for help, please include the request ID AD78:1780A5:36F5912:BB186F5:6A760BB2 and timestamp 2026-08-07 16:45:38 UTC. For more on scraping GitHub and how it may affect your rights, please review our Terms of Service (https://docs.github.com/en/site-policy/github-terms/github-terms-of-service) - https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api#rate-limiting
  • pull / test-qnn-wheel-packages-linux (3.11) / linux-job (gh)
    ##[error]API rate limit exceeded for installation. If you reach out to GitHub Support for help, please include the request ID 9EF8:30ED1:49B2989:F9E0B2A:6A760BC7 and timestamp 2026-08-07 16:45:59 UTC. For more on scraping GitHub and how it may affect your rights, please review our Terms of Service (https://docs.github.com/en/site-policy/github-terms/github-terms-of-service) - https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api#rate-limiting
  • pull / test-qnn-wheel-packages-linux (3.13) / linux-job (gh)
    ##[error]API rate limit exceeded for installation. If you reach out to GitHub Support for help, please include the request ID 85F8:35A344:38DE91E:C1D213A:6A760BC0 and timestamp 2026-08-07 16:45:52 UTC. For more on scraping GitHub and how it may affect your rights, please review our Terms of Service (https://docs.github.com/en/site-policy/github-terms/github-terms-of-service) - https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api#rate-limiting
  • pull / test-voxtral-realtime-xnnpack-linux / linux-job (gh)
    ##[error]API rate limit exceeded for installation. If you reach out to GitHub Support for help, please include the request ID C2C2:28EBC1:4A6EFF9:FC895E2:6A760B60 and timestamp 2026-08-07 16:44:16 UTC. For more on scraping GitHub and how it may affect your rights, please review our Terms of Service (https://docs.github.com/en/site-policy/github-terms/github-terms-of-service) - https://docs.github.com/en/rest/using-the-rest-api/getting-started-with-the-rest-api#rate-limiting
  • pull / unittest-editable / macos / macos-job (gh)
    ##[error]Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under '/Users/ec2-user/runner/_work/executorch/executorch/test-infra/.github/actions/check-disk-space'. Did you forget to run actions/checkout before running your local action?
  • pull / unittest-nxp-neutron / linux-job (gh)
    ##[error]An error occurred trying to start process '/usr/bin/bash' with working directory '/home/ec2-user/actions-runner/_work/executorch/executorch/pytorch/executorch'. No such file or directory

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

@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.

@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 Jul 22, 2026
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
  fbsource master

[ghstack-poisoned]
@meta-codesync
meta-codesync Bot merged commit a206c92 into gh/JCNTH/107/base Aug 7, 2026
156 of 183 checks passed
@meta-codesync
meta-codesync Bot deleted the gh/JCNTH/107/head branch August 7, 2026 17:20
@meta-codesync
meta-codesync Bot temporarily deployed to cherry-pick-bot August 7, 2026 17:20 Inactive
JCNTH added a commit that referenced this pull request Aug 7, 2026
Pull Request resolved: #21131

The previously landed broad QKV fusion applied too widely and did not match the
BK64 schedule now used for the ordinary projections. This corrective diff
replaces it with a capability- and geometry-qualified BK64 kernel that fuses the
exact Llama Q/K/V projection triple at live M128, M508, and M512, packing the
constant weights and scales once and scattering the result into three distinct
planner-safe outputs. Outside the accepted shapes it switches atomically back
to the ordinary Steel and bicol routes, and it deletes the obsolete broad
shader and header so only one QKV path remains. Mirrors Vulkan
xplat/executorch/backends/vulkan/runtime/graph/ops/glsl/q4gsw_linear_gemm__w_4x8.glsl
for the per-projection GEMM; the three-output fusion itself is WebGPU-specific.

Key changes:
- Adds runtime/ops/quantized_linear/q4gsw_qkv_bk64.wgsl (+ generated header);
  removes the obsolete q4gsw_linear_gemm_qkv_fused shader and header.
- WebGPUGraph.{cpp,h}: geometry and capability predicate, one-time constant
  packing, distinct Q/K/V outputs, and atomic fallback to Steel/bicol.
ghstack-source-id: 411961443
@exported-using-ghexport

Differential Revision: [D113171749](https://our.internmc.facebook.com/intern/diff/D113171749/)
JCNTH added a commit that referenced this pull request Aug 7, 2026
Pull Request resolved: #21131

The previously landed broad QKV fusion applied too widely and did not match the
BK64 schedule now used for the ordinary projections. This corrective diff
replaces it with a capability- and geometry-qualified BK64 kernel that fuses the
exact Llama Q/K/V projection triple at live M128, M508, and M512, packing the
constant weights and scales once and scattering the result into three distinct
planner-safe outputs. Outside the accepted shapes it switches atomically back
to the ordinary Steel and bicol routes, and it deletes the obsolete broad
shader and header so only one QKV path remains. Mirrors Vulkan
xplat/executorch/backends/vulkan/runtime/graph/ops/glsl/q4gsw_linear_gemm__w_4x8.glsl
for the per-projection GEMM; the three-output fusion itself is WebGPU-specific.

Key changes:
- Adds runtime/ops/quantized_linear/q4gsw_qkv_bk64.wgsl (+ generated header);
  removes the obsolete q4gsw_linear_gemm_qkv_fused shader and header.
- WebGPUGraph.{cpp,h}: geometry and capability predicate, one-time constant
  packing, distinct Q/K/V outputs, and atomic fallback to Steel/bicol.
ghstack-source-id: 411961443
@exported-using-ghexport

Differential Revision: [D113171749](https://our.internmc.facebook.com/intern/diff/D113171749/)
JCNTH added a commit that referenced this pull request Aug 7, 2026
Pull Request resolved: #21131

The previously landed broad QKV fusion applied too widely and did not match the
BK64 schedule now used for the ordinary projections. This corrective diff
replaces it with a capability- and geometry-qualified BK64 kernel that fuses the
exact Llama Q/K/V projection triple at live M128, M508, and M512, packing the
constant weights and scales once and scattering the result into three distinct
planner-safe outputs. Outside the accepted shapes it switches atomically back
to the ordinary Steel and bicol routes, and it deletes the obsolete broad
shader and header so only one QKV path remains. Mirrors Vulkan
xplat/executorch/backends/vulkan/runtime/graph/ops/glsl/q4gsw_linear_gemm__w_4x8.glsl
for the per-projection GEMM; the three-output fusion itself is WebGPU-specific.

Key changes:
- Adds runtime/ops/quantized_linear/q4gsw_qkv_bk64.wgsl (+ generated header);
  removes the obsolete q4gsw_linear_gemm_qkv_fused shader and header.
- WebGPUGraph.{cpp,h}: geometry and capability predicate, one-time constant
  packing, distinct Q/K/V outputs, and atomic fallback to Steel/bicol.
ghstack-source-id: 411961443
@exported-using-ghexport

Differential Revision: [D113171749](https://our.internmc.facebook.com/intern/diff/D113171749/)
JCNTH added a commit that referenced this pull request Aug 7, 2026
Pull Request resolved: #21131

The previously landed broad QKV fusion applied too widely and did not match the
BK64 schedule now used for the ordinary projections. This corrective diff
replaces it with a capability- and geometry-qualified BK64 kernel that fuses the
exact Llama Q/K/V projection triple at live M128, M508, and M512, packing the
constant weights and scales once and scattering the result into three distinct
planner-safe outputs. Outside the accepted shapes it switches atomically back
to the ordinary Steel and bicol routes, and it deletes the obsolete broad
shader and header so only one QKV path remains. Mirrors Vulkan
xplat/executorch/backends/vulkan/runtime/graph/ops/glsl/q4gsw_linear_gemm__w_4x8.glsl
for the per-projection GEMM; the three-output fusion itself is WebGPU-specific.

Key changes:
- Adds runtime/ops/quantized_linear/q4gsw_qkv_bk64.wgsl (+ generated header);
  removes the obsolete q4gsw_linear_gemm_qkv_fused shader and header.
- WebGPUGraph.{cpp,h}: geometry and capability predicate, one-time constant
  packing, distinct Q/K/V outputs, and atomic fallback to Steel/bicol.
ghstack-source-id: 411961443
@exported-using-ghexport

Differential Revision: [D113171749](https://our.internmc.facebook.com/intern/diff/D113171749/)
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