Skip to content

[ET-VK][runtime] Default to x-major local workgroups - #24716

Merged
SS-JIA merged 1 commit into
mainfrom
gh/SS-JIA/689/orig
Nov 6, 2026
Merged

SS-JIA merged 1 commit into
mainfrom
gh/SS-JIA/689/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: #24694 by @SS-JIA
^ 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/SS-JIA/689/base
ghstack PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/689/head
Merge bot PR base: https://github.com/pytorch/executorch/tree/main
Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/689/orig
Differential Revision: D130014624
@diff-train-skip-merge

## Ulterior Motive

Closing the latency gap between ET-VK and LiteRT GPU on the FP16 DSR
(`ImageSRDenoiseNet`) model. Unfused `y + x * scale` residuals (83 per
inference, each a `mul` then an `add`) are the largest gap category on
Galaxy S24, Galaxy S25 and Pixel 9 Pro XL. Besides the missing fusion, ET-VK's
binary op itself reached only 9–41 GB/s on S24 against LiteRT's 46–50 GB/s for the
same tensors. The cause, the local workgroup shape, applies to most texture
ops, not just binary ops.

## Rationale

**What**: `default_pick_lwg` now fills X first (up to 64 invocations), then Y,
and Z only with what X and Y cannot hold. A new `pick_balanced_lwg` keeps the
previous behaviour (`{4, 4, 4}` for 3D grids) for permute, `view_copy` and the
q8csw conv2d im2col.

**Why**: For texture-extent grids, `{4, 4, 4}` makes a work group span four
depth slices of a texture3d tensor. Each slice is a separate 2D surface, so the
group's reads scatter across surfaces. On Adreno the cost grows with the number
of slices: on S24, an FP16 add of a 256-channel 189x252 tensor ran at 13 GB/s
with `{4, 4, 4}` and 48 GB/s with `{64, 1, 1}`. Mali-G715 gains about 20%.
Most other memory-bound texture ops gain the same way on S24 (`avg_pool2d`
1.78x, `constant_pad_nd` 1.55x, `pixel_shuffle` 1.44x, `embedding_q4gsw`
1.36x). Ops whose reads and writes walk different axes lose instead (permute up
to 3.3x slower, q8csw im2col up to 1.5x slower), so they keep the balanced
shape.

## Details

- Ops that dispatch a texture-extent grid through `default_pick_lwg`, e.g.
  binary ops, split, unary ops, `clone`, `flip`, `slice_copy`, `select_copy`,
  `constant_pad_nd`, pooling, `repeat`, `expand_copy`, upsample,
  `pixel_shuffle`, `embedding_q4gsw`
  - **Before**: `{4, 4, 4}` for grids with three non-trivial axes, `{8, 8, 1}`
    for two.
  - **After**: `{64, 1, 1}` when the grid is at least 62 wide; narrower grids
    fill Y before Z (14x14x256 gets `{16, 4, 1}`, 7x7x64 gets `{8, 8, 1}`).
- Permute, `view_copy` (both its copy and dtype-convert dispatches) and the
  q8csw conv2d im2col: unchanged, via `pick_balanced_lwg`. x-major would speed
  up some of these on Pixel 8 Pro (permute up to 1.20x) but slows permute and
  q8csw on S24 by up to 3.3x and small `view_copy` on Pixel 8 Pro by 1.37x.
- Linear grids (buffer storage): unchanged; they keep their required local
  workgroup.
- Known losses kept: `max_pool2d` of 1x256x14x14 (`{8, 8, 1}`) is 1.19x slower
  on S24 and neutral on S23, against 1.17–1.27x gains on the 1x64x378x504 case.
  On Pixel 8 Pro, a few ops are 2–6% slower, e.g. `select_copy` of 1x256x14x14,
  `avg_pool2d` and small binary ops (about 1 us).
- `etvk_ops_bench` registers `pick_balanced_lwg` so raw shader cases can
  request it.

`default_pick_lwg` uses `LwgShape(6, 1, 0)` with the existing `fit_to_global`
refit, so it adapts to the grid like the other shared pickers.

Differential Revision: [D130014624](https://our.internmc.facebook.com/intern/diff/D130014624/)


ghstack-source-id: 466196984
Pull-Request: #24694
@pytorchbot
pytorchbot requested a review from SS-JIA as a code owner November 6, 2026 01:22
@pytorch-bot

pytorch-bot Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 135 New Failures, 7 Unrelated Failures, 10 Unclassified Failures

As of commit 271ff39 with merge base 728e13f (image):

NEW FAILURES - The following jobs have failed:

UNCLASSIFIED FAILURES - DrCI could not classify the following jobs because the workflow did not run on the merge base. The failures may be pre-existing on trunk or introduced by this PR:

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

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 Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026

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.

@SS-JIA
SS-JIA added this pull request to stack #24719 November 6, 2026 03:05
@SS-JIA
SS-JIA merged commit 983f363 into main Nov 6, 2026
@SS-JIA
SS-JIA deleted the gh/SS-JIA/689/orig branch November 6, 2026 03:06

This branch had an error being deployed

1 failed deployment
cadence — 271ff395 Deployed Nov 6, 2026 by pytorchbot
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