Single-Kernel Fusion for Autoregressive Transformer Decoding via WebGPU Compute Shaders

Read full text Summarise with VIRAT
Authors: Ahmet Baris Gunaydin
Cited by: 0

Summary

No summary yet. VIRAT can read this paper and write a plain-language summary of its aim, methods, key findings and limitations.

Summarise with VIRAT Free to try with your Science Catalogs account.

Abstract

Fusing the entire autoregressive decoding loop into a single WebGPU compute shader dispatch eliminates per-dispatch overhead that dominates browser-based LLM inference. On an Apple M2 Pro (N=30), the fused kernel achieves 6.6-13.5x over unfused dispatch, up to 31.3x over PyTorch MPS, and 34.1x at sequence length 256. Numerical correctness validated against f64 CPU reference (max error 3.019e-6). Includes parameterized WGSL shader generator, PyTorch baselines, torch.compile comparison, and 60/60 paper arithmetic verification tests. Code: https://github.com/abgnydn/webgpu-transformer-fusion vnext changes: v2: cite Maczan (arXiv:2604.02344) and zero-tvm; add §4.8 cross-vendor crowdsourced validation across 7 GPU vendors / 92 unique devices; new §6.2 'Compiler-Mediated vs Hand-Fused Mega-Kernels' (compares to Maczan's p>0.38 negative result); soften §6.1 production extrapolation; correct §4.5 prose typos (29.9→31.3, 2.0→2.2, 0.63→0.69) and abstract f16 range (1.7→2.0); replace cherry-picked '44× over PyTorch' with full 7.5–161× range; arithmetic suite extended to 88 checks. v3: erratum — a harness audit found the v1/v2 unfused baseline computed a different function than the fused kernels (broken buffer wiring: FFN consumed the attention output, LN2/FFN outputs discarded, residuals missing, shared weights across layers) and the parallel kernel corrupted the first DF floats of its output (FFN scratch aliasing); v1 correctness validation covered only the single-threaded fused kernel. The harness is fixed and all variants are now cross-checked for numerical equivalence on shared weights before timing (max|Δ| ≤ 2.3e-5). Re-measured on M2 Max: published ratios reproduce within noise, BUT a new fair single-submit unfused baseline (equal arithmetic, one command buffer) shows fused-1T is 2.5–5.0x slower than it; the parallel kernel retains a genuine 2.2–12.7x (growing with D, losing at SEQ=256); the 66–458x figures correctly read as worst-case per-token-submit decoding vs full fusion, not fusion's intrinsic advantage. With PyTorch 2.12 MPS the parallel kernel's edge is 0.8–14.8x. Full Erratum section in the paper; raw data in benchmarks/results/2026-07-27_m2max_fixed/.

Fields of Study & Subjects

Parallel Computing and Optimization Techniques Computer Graphics and Visualization Techniques Advanced Neural Network Applications

Publication details

Journal / source
Zenodo (CERN European Organization for Nuclear Research)
Publication date
31 March 2026
Language
EN
Document type
Preprint