[ExecuTorch][WebGPU] Dynamic resize hooks for rms_norm, embedding, rope#20575
Open
JulianCloudNTH wants to merge 1 commit into
Open
[ExecuTorch][WebGPU] Dynamic resize hooks for rms_norm, embedding, rope#20575JulianCloudNTH wants to merge 1 commit into
JulianCloudNTH wants to merge 1 commit into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20575
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (1 Unrelated Failure)As of commit 89bce88 with merge base 55a71e6 ( FLAKY - The following job failed but was likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This was referenced Jun 28, 2026
This PR needs a
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack from ghstack (oldest at bottom):
These ops baked their dispatch count, param UBO, and output dims at
build()for the max seq-len. On a dynamic-shape graph at a smaller live S they would over-dispatch and leave the output sized at the max, so the resize engine could not actually shrink them.This adds tensor resize hooks to rms_norm, embedding_q4gsw, and apply_rotary_emb. When an input is resized, each hook recomputes the live row/token count, rewrites the param UBO, updates the dispatch
workgroup_count_x, and sets the output'scur_dims. The hook is inert until a resize happens, so static graphs are byte-identical.Implementation:
rms_norm: recomputenum_rowsfrom livecur_dims; out dims follow the input.embedding_q4gsw: recomputenum_indices/total_blocks; out dims = indices dims +[embed_dim].apply_rotary_emb:add_rope_dispatchnow returns its uniform handle; one hook rewrites both the xq and xk dispatches/UBOs for the live S and sets both outputs.own_uniform_buffer(the hook rewrites it) instead of releasing it at build.Mirrors Vulkan per-op
resize_*_node(recompute sizes + dispatch each execute). No kernel/WGSL/numerics change. Behavior-neutral on static graphs (hook only fires when live dims differ from max).quantized_linearand SDPA resize hooks land in following diffs;prepackneeds none (constants are fixed-size).Differential Revision: D109906096