{{ message }}
[ExecuTorch][WebGPU] Dynamic resize hook for linear_q4gsw#20576
Open
JulianCloudNTH wants to merge 6 commits into
Open
[ExecuTorch][WebGPU] Dynamic resize hook for linear_q4gsw#20576JulianCloudNTH wants to merge 6 commits into
JulianCloudNTH wants to merge 6 commits into
Conversation
This was referenced Jun 28, 2026
This PR needs a
|
Contributor
Author
|
@claude review and check for any areas or opportunities for modularization |
SS-JIA
approved these changes
Jul 2, 2026
SS-JIA
left a comment
Contributor
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
SS-JIA
approved these changes
Jul 2, 2026
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):
Make the 4-bit quantized linear serve any live M (rows) from one graph, so a dynamic prefill+decode graph computes correct-size outputs.
Problem:
linear_q4gswbaked its dispatch count,params.M, and output shape atbuild()for the max M. On a dynamic-shape graph at a smaller live M (e.g. decode M=1 vs prefill M=S) it would over-dispatch and leave the output sized at the max.Solution:
cur_dims, rewritesparams.M, updates the dispatchworkgroup_count_xfor the SAME kernel chosen at build (bicol GEMV / shmem GEMM / register-tiled), and sets the outputcur_dims(= input dims with the last dim replaced by N). Inert until the input is resized.Implementation:
compute_q4gsw_workgroup_countfor whichever of the three the build chose and rewrites the param UBO + output dims for the live M — it does not switch kernels (runtime M-switching is a separate optimization).own_uniform_bufferkeeps the param UBO alive so the hook can rewrite it.resize_q4gsw_linear_node(recompute M-derived dispatch each execute).Constraints: Behavior-neutral on static graphs (hook fires only when the input's live M differs from the max). No kernel/WGSL/numerics change. Runtime M-based kernel switching is deliberately out of scope (a later opt diff).
Co-authored-with: Claude Code.
@exported-using-ghexport
Differential Revision: D109906094
Differential Revision: D109906094