[ExecuTorch][WebGPU] Make WGSL generation rollback-safe - #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 Failures, 8 PendingAs of commit b3701c7 with merge base f4a21b8 ( 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):
Make WGSL publication rollback-safe without changing generated runtime output
Generated headers and the registry were previously written incrementally, so later validation, interruption, or write failure could leave a partial generated tree. This change stages and validates the complete output set before sequential publication, rejects path/name/C++ symbol collisions, and restores replaced outputs on failure or interruption.
The family model follows Vulkan's YAML/template generation. The WebGPU publisher adds staging, backup, rollback, and temporary-file cleanup; it does not claim filesystem-atomic multi-file replacement.
Key changes:
gen_wgsl_headers.py— stage, validate, publish, restore on failure, and clean temporary outputs.test_wgsl_codegen.py— cover collisions, orphan repair, interruption, rollback, and idempotence.All generated shader bytes and runtime registry entries remain unchanged.
Co-authored-with: Claude Code.
@exported-using-ghexport
Differential Revision: D113979658
Differential Revision: D113979658