Skip to content

[ET-VK] Tuning local workgroup size calculation for conv2d pw to improve performance. #11188

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 10 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: #11135 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/95/base
ghstack PR head: https://github.com/pytorch/executorch/tree/gh/trivedivivek/95/head
Merge bot PR base: https://github.com/pytorch/executorch/tree/gh/trivedivivek/94/orig
Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/trivedivivek/95/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/)
@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/11188

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

⏳ No Failures, 2 Pending

As of commit 5dfcad1 with merge base 6fafe7c (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/94/orig to main May 28, 2025 22:13
@trivedivivek trivedivivek merged commit 11f8f4a into main May 29, 2025
96 checks passed
@trivedivivek trivedivivek deleted the gh/trivedivivek/95/orig branch May 29, 2025 03:15
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