Skip to content

[ExecuTorch][WebGPU] Broadcast add.Tensor (mirror mul) + un-skip 6 models#21233

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

[ExecuTorch][WebGPU] Broadcast add.Tensor (mirror mul) + un-skip 6 models#21233
JCNTH wants to merge 1 commit into
gh/JCNTH/193/basefrom
gh/JCNTH/193/head

Conversation

@JCNTH

@JCNTH JCNTH commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

add.Tensor was elementwise-only: binary_add.wgsl computed output[idx] = input1[idx] + alpha * input2[idx] over a single flat index up to the output numel, so on a broadcast it read the smaller operand out of bounds (WebGPU robustness clamps/zeros -> silently wrong, not 0x30). This is the failure mode behind the models the WebGPU flow skips (resnet50, vit_b_16, swin_v2_t, convnext_small, mobilenet_v3_small, shufflenet_v2_x1_0) and the bcast_first/bcast_second op cases.

Give add.Tensor NumPy broadcasting by mirroring the shipped mul:

  • binary_add.wgsl - copy binary_mul's kernel (rank-8 TensorMeta layout from the rank-cap fix below it in the stack): keep the identical-shape elementwise fast path (common case stays bit-for-bit input1[idx] + alpha * input2[idx]), else relinearize out idx -> per-input coords (clamp size-1 dims) and add. alpha is a second pipeline-override constant (read once at build, never rewritten on resize), so no extra UBO.
  • add/BinaryOp.cpp - port mul_impl: 3 TensorMeta UBOs via fill_tensor_meta_broadcast, rank + fp32 guards, 6-entry bind group, constantCount = 2 ({wg_size, alpha}), 2D dispatch, and mul's resize hook verbatim (rebuild the 3 metas from cur_dims, set_cur_dims, rewrite UBOs + dispatch); own_uniform_buffer the 3 metas. Drops the old flat AddParams path.
  • flows/webgpu.py - un-skip the 6 broadcast-add models + the bcast_first/bcast_second op cases (kept the float16/float64 dtype skips and hardswish/lstm_batch_sizes/upsample_nearest2d).

This sits above the rank-cap fix, so the shader uses the rank-8 array<vec4<u32>, 2> TensorMeta layout. Applied identically to both xplat/ and fbcode/ mirrors (byte-identical).

Co-authored-with: Claude Code.

Differential Revision: D113319599

[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/21233

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:

❌ 27 New Failures, 4 Unrelated Failures

As of commit 4d87cce 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:

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
This was referenced 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