Skip to content

[ExecuTorch][WebGPU] Raise TensorMeta rank cap 4->8 to fix rank>4 ops (0x30)#21231

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

[ExecuTorch][WebGPU] Raise TensorMeta rank cap 4->8 to fix rank>4 ops (0x30)#21231
JCNTH wants to merge 1 commit into
gh/JCNTH/191/basefrom
gh/JCNTH/191/head

Conversation

@JCNTH

@JCNTH JCNTH commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Rank-5+ tensors threw 0x30 (DelegateInvalidCompatibility) at delegate init: the shared TensorMeta UBO capped rank at 4 (kTensorMetaMaxNdim), so fill_tensor_meta/fill_tensor_meta_broadcast hard-throw during build() and the WGSL mirror stored sizes/strides as a single vec4<u32>. This clears test_permute_different_shapes[webgpu], test_transpose_different_shapes[webgpu] (transpose lowers to permute_copy), and the rank>4 model failures (conformer, maxvit_t).

Raise the global cap to 8 and widen the uniform to two vec4<u32> blocks, keeping the C++ and WGSL layouts byte-identical:

  • C++ sizes[8]/strides[8]: sizeof(TensorMeta) 48->80, strides offset 32->48 (ndim/numel/sizes offsets unchanged).
  • WGSL sizes: array<vec4<u32>, 2> / strides: array<vec4<u32>, 2>: in the uniform address space the vec4<u32> element stride is 16, so two blocks are 32 contiguous bytes matching uint32_t[8]; component k sits at byte 16 + 4*k on both sides, so the raw memcpy stays correct. Runtime reads m.strides[d] become m.strides[d >> 2u][d & 3u].
  • 8 (not 5): a WGSL uniform array cannot pack 5 u32 tightly, so rank-5 would allocate the same two vec4s; 8 is the natural 2-vec4 boundary and covers all realistic ranks.

Key changes:

  • runtime/ops/TensorMeta.h - cap 4->8; static_assert(sizeof == 80) and offsetof(strides) == 48; throw text.
  • 15 shaders widened + reindexed (regenerated their 16 _wgsl.h): permute, flip, cat, binary_op (div/sub), binary_mul, binary_pow, binary_minimum, binary_floor_divide, where, select, slice, expand_copy, gather, index_select, repeat.
  • permute/flip also widen their per-dim Params array (perm/flip vec4<u32> -> array<vec4<u32>, 2>; sizeof(PermuteParams)/sizeof(FlipParams) 16->32).
  • Rank-guard throw messages "exceeds 4" -> "exceeds 8" (the guards themselves auto-follow the constant): div/mul/sub/where/binary/index_select/repeat.
  • Applied identically to both the xplat/ and fbcode/ mirrors (byte-identical).

Co-authored-with: Claude Code.

Differential Revision: D113319595

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

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:

❌ 31 New Failures, 3 Unrelated Failures

As of commit 139066b 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
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