Skip to content

[ExecuTorch][WebGPU] Fold remaining hardcoded 65535 dispatch-limit checks into queried_max_workgroups#20950

Open
pytorchbot wants to merge 2 commits into
mainfrom
gh/JCNTH/55/orig
Open

[ExecuTorch][WebGPU] Fold remaining hardcoded 65535 dispatch-limit checks into queried_max_workgroups#20950
pytorchbot wants to merge 2 commits into
mainfrom
gh/JCNTH/55/orig

Conversation

@pytorchbot

Copy link
Copy Markdown
Collaborator

This PR was created by the merge bot to help merge the original PR into the main branch.
ghstack PR number: #20916 by @JCNTH
^ Please use this as the source of truth for the PR details, comments, and reviews
ghstack PR base: https://github.com/pytorch/executorch/tree/gh/JCNTH/55/base
ghstack PR head: https://github.com/pytorch/executorch/tree/gh/JCNTH/55/head
Merge bot PR base: https://github.com/pytorch/executorch/tree/main
Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/JCNTH/55/orig

@diff-train-skip-merge

…ecks into queried_max_workgroups

Pull Request resolved: #20916

The backend queries the device's `maxComputeWorkgroupsPerDimension` through `utils::queried_max_workgroups` (keeping `65535` only as the documented spec-default fallback when the query fails), but a few landed dispatch-limit guards still hardcode the literal `65535u` or re-inline the same query. This folds them onto the shared helper, matching the convention already used by `Linear.cpp`/`Bmm.cpp` and the backend's "query the device limit, don't hardcode" rule.

Key changes:
- `RmsNorm.cpp` — replace both `> 65535u` guards (build path and resize hook) with `utils::queried_max_workgroups(...)`; drop the now-stale `(65535)` from the two error strings.
- `QuantizedLinear.cpp` — delete the file-local `max_workgroups_per_dim` (a near-duplicate of the util) and call `utils::queried_max_workgroups` at both sites; `steel_supported()` (a `maxComputeInvocationsPerWorkgroup` gate) is unchanged.
- `WebGPUUtils.h` — `clamp_workgroup_count` now delegates to `queried_max_workgroups` instead of re-inlining the same query + fallback.

No behavior change on compliant devices: `queried_max_workgroups` returns the reported `maxComputeWorkgroupsPerDimension` (the WebGPU spec guarantees >= 65535) or falls back to 65535 if the query fails, so each swapped `> ...` guard can only relax versus the old `> 65535u` literal — no currently-passing shape newly throws.

Co-authored-with: Claude Code.
ghstack-source-id: 402967330
@exported-using-ghexport

Differential Revision: [D111999110](https://our.internmc.facebook.com/intern/diff/D111999110/)
@pytorch-bot

pytorch-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

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

@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 14, 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 self-requested a review July 15, 2026 03:42
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