[ExecuTorch][WebGPU] f16-accumulate (pwdqf16acc) steel q4gsw prefill GEMM#20800
[ExecuTorch][WebGPU] f16-accumulate (pwdqf16acc) steel q4gsw prefill GEMM#20800JCNTH wants to merge 5 commits into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20800
Note: Links to docs will display an error until the docs builds have been completed. ❌ 4 New Failures, 9 PendingAs of commit 4af5d96 with merge base f4b01a8 ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
SS-JIA
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
SS-JIA
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
Stack from ghstack (oldest at bottom):
+46-56% end-to-end prefill tok/s over the shipped f16
steelq4gsw GEMM (Apple M4 Pro / Chrome Canary), behind a new opt-in build flag; perplexity held (13.32 -> 13.37, +0.05).Problem: the f16
steelprefill GEMM (and its packed-word-dequant variantpwdq) accumulates its 4x4 register tile in f32. WebLLM/MLC accumulate in f16, which halves the accumulator footprint and raises occupancy — the largest remaining prefill gap vs MLC on Apple.Solution: an f16-accumulate variant of the
pwdqkernel — identical staging (dequant-once + hoisted scale) and 64x64/256-thread/BK=16 geometry, but the 4x4 accumulator is kept in f16 withfma()(mirrors MLC'sarray<f16,16>reduction) and cast to f32 in the epilogue for the f32 output/bias.Before (
pwdq): f16 multiply, f32 accumulate.After (
pwdqf16acc): f16 multiply, f16 accumulate, f32 epilogue.Implementation:
q4gsw_linear_gemm_steel_half_pwdqf16acc.wgsl(+ generated header) + a new CMake optionEXECUTORCH_WEBGPU_STEEL_F16ACC(default OFF, mirrorsEXECUTORCH_WEBGPU_STEEL_F16) ->WGPU_BACKEND_STEEL_F16ACC.group_size % BK == 0; else the f32-accumulatepwdq/half/ f32 kernels run (fail-closed).Constraints: LOSSY — f16 accumulation over the full K (up to 8192) is not bit-exact, so it ships on a perplexity bar, not a bit-exact gate (as MLC does): measured Llama-3.2-1B int4 perplexity 13.32 -> 13.37 (+0.05) on the real prefill path. Default-OFF keeps upstream builds on the strict f32-accumulate golden; the option is opt-in for latency-sensitive deployments.
Co-authored-with: Claude Code.
@exported-using-ghexport
Differential Revision: D111163606
Differential Revision: D111163606