[ExecuTorch][WebGPU] WGSL shader-variant codegen (vec1/vec4, fp16-ready) + rms_norm dedup#20727
[ExecuTorch][WebGPU] WGSL shader-variant codegen (vec1/vec4, fp16-ready) + rms_norm dedup#20727JCNTH wants to merge 6 commits into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20727
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 Cancelled JobAs of commit f7250fc with merge base f8c8334 ( CANCELLED JOB - The following job was cancelled. Please retry:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
|
@claude throoughly review, check for overengineering, correctness, and areaas for modularization |
|
Claude finished @JCNTH's task in 4m 24s —— View job Review: WGSL shader-variant codegen
The core idea is sound and the backward-compatible 🔴 Overengineering (the headline concern)You ported
CLAUDE.md is explicit: "When uncertain: choose simpler, more concise" and "No trivial single-use helpers." I'd trim The
🟠 Correctness1. The fp16 path is not "fp16-ready" — it would emit non-compiling WGSL. With
WGSL has no implicit f16↔f32 conversion, so both are type errors, and no 2. Inconsistent error handling in the generator. except ValueError as e:
errors.append(...)But 3. 4. 5. Byte-identical claim — I was unable to run 🟡 Modularization
This keeps the drift-gate logic readable and lets the engine be unit-tested in isolation. Given the trimming suggested above the engine shrinks a lot, so this is optional — but if the machinery stays this size, splitting it is the right call. Minor: the "apply variant keys onto SummarySolid, well-tested foundation with a genuinely backward-compatible seam. The main asks: (1) cut the unused variant-matrix features (esp. the f16/DTYPE axis, which would generate invalid WGSL today), (2) make spec-parse errors flow through Note: this is review feedback only — I haven't modified any files. I also couldn't execute the generator/tests here (Bash approval denied), so the byte-identical + drift claims are assessed statically; rely on CI's |
Stack from ghstack (oldest at bottom):
Adds a build-time template engine to the WGSL shader codegen so a single templated
.wgslplus a per-shader YAML variant spec replaces hand-copied shader variants. Mirrors the Vulkan delegate'sgen_vulkan_spv.pyapproach, adapted for WGSL with axes for scalar/vec4 packing and an fp16-ready accumulator path (widen-to-f32 for half precision).rms_norm is the first consumer: one template +
rms_norm.yamlreplaces the hand-maintainedrms_norm_vec4.wgslwhile regenerating byte-identical headers. The fp16 axis is compiled-in infrastructure with no shader consumer yet. No runtime or numeric change.@exported-using-ghexport
Differential Revision: D110659979
Differential Revision: D110659979