Skip to content

[ExecuTorch][WebGPU] Add dynamic-shape resize hook to cat (output mismatch)#21232

Open
JCNTH wants to merge 1 commit into
gh/JCNTH/192/basefrom
gh/JCNTH/192/head
Open

[ExecuTorch][WebGPU] Add dynamic-shape resize hook to cat (output mismatch)#21232
JCNTH wants to merge 1 commit into
gh/JCNTH/192/basefrom
gh/JCNTH/192/head

Conversation

@JCNTH

@JCNTH JCNTH commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Under dynamic shapes cat produced a wrong (scrambled + tail-garbage) output. cat_impl baked every shape-dependent quantity - each input in_meta (strides/numel), the shared out_meta (strides), the per-input off_k, and each dispatch's workgroup_count - from the MAX (upper-bound) build shape and registered NO resize hook, then released the UBOs. Under a smaller live shape the kernel then decoded coords with max strides, scattered with max out-strides, and looped over the max numel. This is the [dynamic] output-mismatch behind test_inception_v3, test_squeezenet1_1, test_densenet161 (all channel-cat on spatial-dynamic feature maps; the concat dim is static so off_k was already correct - the defect is the stale spatial strides/numel).

Fix (mirrors the WebGPUGraph SwiGLU/QKV resize templates and the shipped mul hook):

  • Keep the per-input in_meta/params UBOs and the shared out_meta UBO alive via own_uniform_buffer (previously released after build); collect their handles plus each add_dispatch index.
  • Register an idempotent add_tensor_resize_hook on every input id: from cur_dims recompute live out dims (set_cur_dims(out_id, ...) to cascade to consumers + fix the delegate-output shape), rebuild out_meta + each input's in_meta/params and wgpuQueueWriteBuffer them, and rewrite each dispatch's workgroup_count_x via compute_1d_workgroup_count. On a static graph cur_dims == dims, so the hook rewrites identical values (no behavior change).

Applied identically to both the xplat/ and fbcode/ mirrors (byte-identical).

Co-authored-with: Claude Code.

Differential Revision: D113319596

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/21232

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 28 New Failures, 3 Unrelated Failures

As of commit bcb2ce9 with merge base 266e0dc (image):

NEW FAILURES - The following jobs have failed:

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

  • pull / unittest / windows / windows-job (gh) (matched win rule in flaky-rules.json)
    Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under 'C:\actions-runner\_work\executorch\executorch\test-infra\.github\actions\teardown-windows'. Did you forget to run actions/checkout before running your local action?
  • pull / unittest-editable / windows / windows-job (gh) (matched win rule in flaky-rules.json)
    Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under 'C:\actions-runner\_work\executorch\executorch\test-infra\.github\actions\teardown-windows'. Did you forget to run actions/checkout before running your local action?

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

This was referenced Jul 22, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 22, 2026
@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@JCNTH
JCNTH requested a review from psiddh July 23, 2026 01:59

@psiddh psiddh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving full WebGPU stack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants