Skip to content

[ET-VK] De vectorise all vectors in conv2d pw shader to improve perf. #11189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 29, 2025

Conversation

pytorchbot
Copy link
Collaborator

This PR was created by the merge bot to help merge the original PR into the main branch.
ghstack PR number: #11136 by @trivedivivek
^ 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/trivedivivek/96/base
ghstack PR head: https://github.com/pytorch/executorch/tree/gh/trivedivivek/96/head
Merge bot PR base: https://github.com/pytorch/executorch/tree/gh/trivedivivek/95/orig
Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/trivedivivek/96/orig
@diff-train-skip-merge

Pull Request resolved: #11108

This diff optimizes the performance of the `conv2d_pw` shader by de-vectorizing its implementation.

*   The original vectorized implementation of the `conv2d_pw` shader has been replaced with a de-vectorized approach to improve performance.
*   The `sum` array has been redefined to hold `float` values instead of `vec4` to accommodate the de-vectorized computation.

These changes seem to allow shader compiler to better optimize operations within the shader hence improving perf.
ghstack-source-id: 286652100
@exported-using-ghexport

Differential Revision: [D75307267](https://our.internmc.facebook.com/intern/diff/D75307267/)
Pull Request resolved: #11110

This diff removes the use of shared memory in the conv2d pw (pointwise) operation to improve performance.
ghstack-source-id: 286652103

Differential Revision: [D75316188](https://our.internmc.facebook.com/intern/diff/D75316188/)
Pull Request resolved: #11112

This diff tunes the tile size for the conv 2d pw op to improve performance. The changes include updating the `TILE_SIZE_X` and `TILE_SIZE_Y` values in the `conv2d_pw.yaml` files and modifying the `Convolution.cpp` files to adjust the image extents calculation. The `TILE_SIZE_X` value is changed from 2 to 1, and the `TILE_SIZE_Y` value is changed from 2 to 4.
ghstack-source-id: 286652109

Differential Revision: [D75317820](https://our.internmc.facebook.com/intern/diff/D75317820/)
Pull Request resolved: #11113

The diff introduces minor tuning for the Conv2d pointwise (PW) operation in the Vulkan backend to improve performance.
Conv 2d pw now issues a 2D dispatch instead of 1D, where dispatch axis y is now sized based on output texture's batch size.
ghstack-source-id: 286652099

Differential Revision: [D75251145](https://our.internmc.facebook.com/intern/diff/D75251145/)
Pull Request resolved: #11122

This improves the performance of the conv2d pw shader by de-vectorizing position storage.
The optimization involved replacing the `ivec3 pos` array with a plain `int pos` array to store the position values. The `x` and `y` coordinates are now stored in separate elements of the array instead of being stored together in an `ivec3`. This change allows for more efficient memory access and computation.
ghstack-source-id: 286652097
@exported-using-ghexport

Differential Revision: [D75335802](https://our.internmc.facebook.com/intern/diff/D75335802/)
Pull Request resolved: #11134

This diff provides a minor unroll tuning to improve the performance of the conv2d pointwise (pw) operation in the Executorch Vulkan backend.
ghstack-source-id: 286652101
@exported-using-ghexport

Differential Revision: [D75420510](https://our.internmc.facebook.com/intern/diff/D75420510/)
…ove performance.

Pull Request resolved: #11135

This diff adjusts the local workgroup size (`local_wg_size`) based on batch count (stored in  `wg_size[1]`), to improve conv2d pw performance.

* If `wg_size[1]` is a multiple of 8, `local_wg_size_y` is set to 8.
* If `wg_size[1]` is a multiple of 4, `local_wg_size_y` is set to 4.
* If `wg_size[1]` is a multiple of 2, `local_wg_size_y` is set to 2.
* Otherwise, we default to `local_wg_size_y` = 1.

The dispatch size in 2 dimensions is then calculate based on `{64 / local_wg_size_y, local_wg_size_y, 1}`.
ghstack-source-id: 286652105
@exported-using-ghexport

Differential Revision: [D75420517](https://our.internmc.facebook.com/intern/diff/D75420517/)
Pull Request resolved: #11136

This diff improves the performance of the conv2d pw shader by de-vectorizing all vectors.
ghstack-source-id: 286652098
@exported-using-ghexport

Differential Revision: [D75423245](https://our.internmc.facebook.com/intern/diff/D75423245/)
@pytorchbot pytorchbot requested a review from SS-JIA as a code owner May 28, 2025 15:53
Copy link

pytorch-bot bot commented May 28, 2025

🔗 Helpful Links

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

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

✅ No Failures

As of commit 3a5cf6e with merge base 11f8f4a (image):
💚 Looks good so far! There are no failures yet. 💚

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

@facebook-github-bot facebook-github-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 May 28, 2025
@trivedivivek trivedivivek added the release notes: vulkan Changes to the Vulkan backend delegate label May 28, 2025
Base automatically changed from gh/trivedivivek/95/orig to main May 29, 2025 03:15
@trivedivivek trivedivivek merged commit e78a944 into main May 29, 2025
96 checks passed
@trivedivivek trivedivivek deleted the gh/trivedivivek/96/orig branch May 29, 2025 04:52
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. release notes: vulkan Changes to the Vulkan backend delegate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants