Repository navigation
[ET-VK][runtime] Write one vec4 texel per thread in buffer permute and view - #25326
Merged
Merged
Conversation
…d view Pull Request resolved: #25305 ## Ulterior Motive Buffer tensors pad the packed dim to a multiple of four. This commit recovers the latency that padding costs a model with decomposed pixel shuffles, while keeping the padding. ## Rationale **What**: `permute` and `view_copy` get vec4 shader variants for buffer outputs whose packed dim has stride 1. Each thread writes one texel of four packed-dim elements. **Why**: Exporting with decompositions turns `pixel_shuffle` into `view -> permute -> view`. The permute output's packed dim has size 2, so padding doubles the buffer and half of its elements are padding. The scalar shaders spend one thread on each of those elements, and the following view loses its same-physical-order fast path. ## Details - Dispatch - **Before**: `permute_buffer` and `view_buffer` launch one thread per padded output element and do scalar writes. - **After**: if `is_packed_dim_vec4_contiguous(out)` holds, `permute_vec4_buffer` / `view_vec4_buffer` launch one thread per texel (`default_pick_vec4_gwg`) and write a vec4. All other outputs keep the scalar shaders. - `is_packed_dim_vec4_contiguous` (`TensorUtils`) returns true for a buffer tensor that meets all of these: - elements of at most 4 bytes; - packed block size 1; - packed dim aligned to 4; - packed dim innermost in the dim order. - Both shaders select the vec4 path with a `VEC4_OUTPUT` macro and `#ifdef` inside `main()`. Only the output binding declaration differs per variant. - `permute_vec4_buffer`: - It computes the tensor index once per texel. - Lane `i` reads `inp_bufi + i * stride`, where `stride` is the input stride of the permuted packed dim. - Padding lanes are written as zero. - `view_vec4_buffer`: - If input and output have the same physical element order, it copies four consecutive elements. - Otherwise, lane 0 maps through the contiguous index. Later lanes either advance the input index by one contiguous step, when every dim below the packed dim has size 1, or recompute it. - `cases.py` changes: - New pixel-shuffle-shaped 6D cases for buffer `permute` (float and int32, all layouts, zero-padding checks) and for `view_copy`. - The `view_copy` highdim suite now also runs int32 and checks zero padding. Authored with Claude Code. Differential Revision: [D133233612](https://our.internmc.facebook.com/intern/diff/D133233612/) **NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D133233612/)! ghstack-source-id: 478906400
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/25326
Note: Links to docs will display an error until the docs builds have been completed. ⏳ 73 Pending, 1 Unrelated FailureAs of commit 7ee6c46 with merge base c29858d ( FLAKY - The following job failed but was likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
SS-JIA
approved these changes
Nov 20, 2026
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR was created by the merge bot to help merge the original PR into the main branch.
ghstack PR number: #25305 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/739/base
ghstack PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/739/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/739/orig
Differential Revision: D133233612
@diff-train-skip-merge