[ExecuTorch][WebGPU] Packed-word-dequant f16 steel q4gsw prefill GEMM#20798
Open
JCNTH wants to merge 1 commit into
Open
[ExecuTorch][WebGPU] Packed-word-dequant f16 steel q4gsw prefill GEMM#20798JCNTH wants to merge 1 commit into
JCNTH wants to merge 1 commit into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20798
Note: Links to docs will display an error until the docs builds have been completed. ❌ 6 New FailuresAs of commit 42c7fe2 with merge base 4af91c3 ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This was referenced Jul 9, 2026
Open
This PR needs a
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack from ghstack (oldest at bottom):
+24-28% microbench GFLOP/s (+11-16% end-to-end prefill tok/s) on the f16
steelq4gsw prefill GEMM, Apple M4 Pro / Chrome Canary — bit-exact.Problem: the f16
steelprefill GEMM (thehalfvariant) dequantizes weights per-nibble — each of the 256 threads extracts ONE 4-bit weight from a fullu32word, so every packed word is re-loaded ~8x and the per-column scale is re-read ~16x across theBK=16tile. That redundant global traffic dominates the kernel on Apple.Solution: a packed-word-dequant staging variant, bit-exact to the
halfkernel — identicalAsstaging, compute loop, epilogue, and64x64tile / 256-thread /BK=16geometry; only the weight-dequant staging differs.Before (
half): each thread extracts 1 nibble from a re-loaded word; scale re-read per nibble.After (
pwdq): threads[0,BN)each stage one fullBK-column — load the column's twou32words ONCE, unpack all 16 nibbles, read the per-column scale ONCE.Implementation:
q4gsw_linear_gemm_steel_half_pwdq.wgsl(+ generated header); selected on theWGPU_BACKEND_STEEL_F16path when the device negotiated shader-f16 ANDgroup_size % BK == 0(the hoisted scale must be constant across theBKtile), else the per-nibblehalfkernel.steel; only the shader source differs.Constraints: requires
K % BK == 0(the steel route already guarantees it, makingK_packed = K/2a multiple of 8 so every column isu32-aligned) andgroup_size % BK == 0(all real q4 group sizes: 32/64/128). f16-multiply / f32-accumulate, so numerically identical to thehalfkernel.Co-authored-with: Claude Code.
Differential Revision: D111163510