[ExecuTorch][WebGPU] Make WGSL generation transactional - #21448
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/21448
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit b9d03d9 with merge base 8200b9e ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
|
@claude Double check for need of changes, modulariziation opportunity, etc |
|
Claude finished @JCNTH's task in 3m 27s —— View job Review: transactional WGSL generation
Verdict: The transactional logic is correct and unusually well-tested — I found no correctness bugs. Below are observations on design/modularization and a few minor polish items. (Note: I couldn't execute Correctness — looks soundI traced the stage → publish → rollback paths against the tests and they hold up:
Behavior change worth calling outOrphan headers now block normal generation, not just Modularization opportunity (the main one)The entire transaction layer — Options, in order of how much I'd lean toward them:
I'd only do (2) if reuse is likely; otherwise the inline form is fine. Extract this → Minor polish (all optional)
Test coverageExcellent — collisions (path/name/symbol), staging interrupt, replace failure with restore, multi-error rollback, orphan reporting, idempotent second run with no IO, and interrupt-then-repair are all covered. The Nothing here is blocking. My one substantive ask is confirming the orphan-blocks-generation behavior is intended (and documenting it); the rest is optional cleanup. |
Stack from ghstack (oldest at bottom):
Publish WGSL generation transactionally without changing runtime output
Generated headers and the registry were previously written incrementally, so a later validation, interruption, or write failure could leave a partial generated tree. This stages and validates the complete output set before publication, rejects path/name/C++ symbol collisions, and rolls back both reported failures and asynchronous interruptions.
Uses Vulkan’s YAML/template family model (
backends/vulkan/runtime/gen_vulkan_spv.py) while adding WebGPU-specific transactional publication and rollback.Key changes:
gen_wgsl_headers.py— stage, validate, publish, roll back, and clean temporary outputs.test_wgsl_codegen.py— lock collisions, orphan repair, staging/publish interruption, rollback, and idempotence.All generated shader bytes and runtime registry entries remain unchanged.
Co-authored-with: Claude Code.
Differential Revision: D113979658