Skip to content

[ET-VK][conv2d] Use a 2x2x8 tile and tuned local sizes for pointwise convolution - #24480

Merged
SS-JIA merged 1 commit into
mainfrom
gh/SS-JIA/679/orig
Nov 3, 2026
Merged

SS-JIA merged 1 commit into
mainfrom
gh/SS-JIA/679/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: #24433 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/679/base
ghstack PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/679/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/679/orig
Differential Revision: D128786678
@diff-train-skip-merge

…convolution

Pull Request resolved: #24433

## Ulterior Motive

Closing the latency gap between ET-VK and LiteRT (TFLite GPU) on the DSR denoising model on mobile GPUs. The model's 80 1x1 convolutions were the largest per-operator gap on Mali.

## Rationale

**What**: Reworks `conv2d_pw_tiled` around a 2x2-pixel x 8-channel tile with buffer weights, branch-free bounds handling and per-GPU local sizes. The 2x1-pixel x 4-channel tile stays for small Half grids and for Float on Mali, and Float on Mali uses texture weights.

**Why**: Pointwise convolutions are load/store bound on Mali. The old tile issued 6 texel loads per 8 vec4 FMAs, read weights through a texture, and guarded every load with a bounds check. The 2x2 x 8 tile issues half as many loads per FMA.

## Details

- Tile
  - **Before**: one tile, 2 consecutive output positions x 4 output channels per invocation.
  - **After**: a 2x2 output pixel block x 8 output channels (`_4x8` variants) for Float on every GPU except Mali, and for Half when the grid has at least 4096 invocations. Smaller Half grids keep the 2x1 x 4 tile, which fills the GPU better there, and so does Float on Mali.
- Weight storage
  - **Before**: texture2d, unless the packed weights exceed texture limits.
  - **After**: buffer (`_bufw` variants) for Float on every GPU except Mali, and for Half when the device supports 16-bit storage buffers; texture2d otherwise. On a Mali-G715 in CI, Float buffer weights produced wrong results for padded and strided convolutions with either tile. The same cases passed with the parent's texture weights.
- Bounds handling
  - **Before**: every input and weight load is guarded.
  - **After**: pixels and channel tiles past the edge read the nearest in-range address and are discarded at the store, so weight loads have no branches. One redundant K check stays on the input load; without any branch in the K loop, the Adreno compiler reads the weight buffer through a much slower path.
- Local size
  - **Before**: 64-invocation square for every dispatch.
  - **After**: wide tile work groups span the channel tiles of a row of pixel tiles, with 512 threads on Mali, 128 on Adreno and 64 elsewhere, halved until they fit the device limits. The narrow tile uses 1x64 along pixel tiles on Mali when there are at least 64 of them, and the 64-invocation square otherwise.
- Tests
  - The pointwise reference supports Half. `pw_correctness` runs Half too, and adds partial-tile shapes below and above the Half tile switch.
  - New timing-only `dsr_pw_set` with the DSR model's 1x1 convolution shapes.

The tile switch and local sizes come from a sweep over 12 local sizes and both tiles on 57 shapes (see Test Plan). Float on Mali keeps the 2x1 x 4 tile: in the Mali offline compiler the 2x2 x 8 Float tile spills 88 bytes per thread while the 2x1 x 4 Float tile does not spill, and the wide Float tile was 2-31% slower in the sweep.
ghstack-source-id: 462948223
@exported-using-ghexport

Differential Revision: [D128786678](https://our.internmc.facebook.com/intern/diff/D128786678/)
@pytorchbot
pytorchbot requested a review from SS-JIA as a code owner November 3, 2026 03:44
@pytorch-bot

pytorch-bot Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 2 New Failures, 8 Pending

As of commit 19dba1e with merge base 822cb60 (image):

NEW FAILURES - The following jobs have failed:

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

github-actions Bot commented Nov 3, 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 merged commit b52e504 into main Nov 3, 2026
241 of 246 checks passed
@SS-JIA
SS-JIA deleted the gh/SS-JIA/679/orig branch November 3, 2026 04:47

This branch was previously deployed

1 inactive deployment
cadence — 19dba1ef Deployed Nov 3, 2026 by pytorchbot via hifi-op-test / hifi4 #36149
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