Skip to content

[ExecuTorch][WebGPU] Dynamic resize hooks for sigmoid and select_copy#20578

Open
JulianCloudNTH wants to merge 1 commit into
gh/JulianCloudNTH/70/basefrom
gh/JulianCloudNTH/70/head
Open

[ExecuTorch][WebGPU] Dynamic resize hooks for sigmoid and select_copy#20578
JulianCloudNTH wants to merge 1 commit into
gh/JulianCloudNTH/70/basefrom
gh/JulianCloudNTH/70/head

Conversation

@JulianCloudNTH

@JulianCloudNTH JulianCloudNTH commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Make sigmoid and select_copy serve any live shape from one graph; fix select's last-token index under dynamic shapes.

Problem: Both ops baked their dispatch/params/output shape at build() for the max shape. select_copy was worse: a negative index (e.g. -1 for the last token) was normalized against the build-time MAX dim, so at a smaller live S it selected a stale/zero position past the live data — producing wrong (often zero) output.

Solution:

  • sigmoid (generic add_unary_op): a resize hook recomputes num_elements/dispatch and sets the output cur_dims (shape-preserving).
  • select_copy: KEEP the raw (possibly negative) index at build; a resize hook re-resolves it against the LIVE dim, recomputes the output dims (= input minus dim), rebuilds the out/in TensorMeta UBOs and the dispatch.
  • Both keep their uniform buffer(s) alive via own_uniform_buffer.

Implementation:

  • The select out/in meta is rebuilt from synthetic WebGPUTensor{dims} via fill_tensor_meta (reads only .dims).
  • Mirrors Vulkan per-op resize_*_node.

Constraints: Behavior-neutral on static graphs (hooks fire only when an input's live shape differs from the max). No kernel/WGSL/numerics change.

Co-authored-with: Claude Code.

Differential Revision: D109906095

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Jun 28, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 1 New Failure, 1 Unrelated Failure

As of commit 3d8d933 with merge base 55a71e6 (image):

NEW FAILURE - The following job has failed:

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.

@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.

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