Repository navigation
[ET-VK][ops] Consolidate binary scalar shaders behind op_type - #24777
Merged
Merged
Conversation
Pull Request resolved: #24756 ## Ulterior Motive Make buffer storage behave more like texture storage, so one shader can service both storage types. Earlier commits in this stack gave unary and binary tensor-tensor ops one shader each, selected by an `op_type` specialization constant. This commit does the same for tensor-scalar ops. ## Rationale **What**: The tensor-scalar ops (`pow.Tensor_Scalar`, `mul.Scalar`, and `eq`, `ne`, `lt`, `le`, `gt`, `ge` `.Scalar`) share one arithmetic and one comparison shader variant family. The op is selected at dispatch through an `op_type` specialization constant. **Why**: Each op had its own variant family, which multiplied the number of compiled shaders by the number of ops for no change in the code each one runs. ## Details - Shader variants - **Before**: one family per op, `{op}_scalar_{storage}_{dtype}_{scalar}`, with the op inlined through an `OPERATOR` yaml parameter: 8 ops × 2 storages × 4 dtype pairs = 64 shaders. - **After**: `binary_scalar_op` (`pow`, `mul`) and `binary_scalar_cmp` (comparisons, which write uint8): 2 × 2 × 4 = 16 shaders. A host `dev` build of `etvk_ops_bench` shrinks by 514 KiB. - Op selection - `apply_binary_scalar_op(op_type, X, Y)` in `binary_scalar.glsl` switches on the spec constant, which the compiler folds. Each op computes what its `OPERATOR` expression did, in the same promoted type. - `op_type` takes `BinaryOpType` values, which gains `kNe`. Only the tensor-scalar shader implements `kNe`. - Dispatch - `add_binary_scalar_op_node` takes a `BinaryOpType` instead of an op name and picks the comparison family for every op other than `mul` and `pow`. - `test_vulkan_shader_names.py` checks that every name the tensor-scalar dispatch can build is generated. Authored with Claude Code. ghstack-source-id: 467556317 @exported-using-ghexport Differential Revision: [D130297164](https://our.internmc.facebook.com/intern/diff/D130297164/)
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/24777
Note: Links to docs will display an error until the docs builds have been completed. ❌ 4 New Failures, 2 Unrelated FailuresAs of commit 9a1f7cd with merge base 9517b6b ( NEW FAILURES - The following jobs have failed:
BROKEN TRUNK - The following jobs failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
SS-JIA
approved these changes
Nov 7, 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: #24756 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/696/base
ghstack PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/696/head
Merge bot PR base: https://github.com/pytorch/executorch/tree/gh/SS-JIA/695/orig
Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/696/orig
Differential Revision: D130297164
@diff-train-skip-merge