Repository navigation
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/23493
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 57c3330 with merge base bdb489e ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This was referenced Oct 6, 2026
This PR needs a
|
SS-JIA
added a commit
that referenced
this pull request
Oct 9, 2026
Pull Request resolved: #23493 ## Ulterior Motive Organize Vulkan operators by implementation family so operators with multiple routes can use clear, scalable directory layouts. ## Rationale **What**: Move the linear and matrix multiplication C++ implementations, GLSL templates, YAML variant definitions, and GEMM tile headers under `gemm/` in both `impl/` and `glsl/`, split into `linear/` (an activation times a usually prepacked weight) and `matmul/` (multiplication between live activations). Quantized linear sources are grouped by how they are quantized, and the multi-scheme `QuantizedLinear.cpp` and the shared `GemmCoopmat.cpp` are split accordingly. **Why**: Linear and matmul sources were interleaved by name in the flat directories, quantized linear variants for different schemes shared one file, and the shared GEMM tile headers were scattered across the shader root, which obscured which sources implement which operator, route, and scheme. ## Details - Layout (`impl/` and `glsl/` mirror each other) - `gemm/`: `GemmCommon.{h,cpp}` (fp weight prepack, resize helpers, and the cooperative-matrix tile constants and `is_coopmat_eligible()` shared by linear and matmul) and `coopmat_mm`, the cooperative-matrix shader shared by both. - `gemm/tile_utils/`: all GEMM tile headers (tile structs, tile load/store/compute, block packing, accumulators, and scale/sum/bias loaders), also used by convolution, SDPA, and quantize shaders. - `gemm/linear/`: `Linear.{h,cpp}` (`aten.linear`), `LinearCoopmat.{h,cpp}`, and `backward/LinearDw.cpp` (`et_vk.linear_dW`). - `gemm/linear/q8ta/`: `Q8taLinear` and `Q8taLinearGemv`; activations and weights are quantized ahead of time with static parameters (primarily statically quantized convolutional models). - `gemm/linear/qw/`: weight-only quantization, with activations kept in floating point or quantized dynamically (primarily LLMs and transformers). `QuantizedLinear.{h,cpp}` hold the shared weight prepacking, workgroup sizing, the weight-only node, and `quantized_linear_impl`; schemes live in `q4gsw/` (with `backward/` for `et_vk.linear_q4gsw_backward` and `et_vk.q4gsw_requant`), `dq8ca_q4gsw/`, `q8csw/`, and `legacy/` (`QuantizedLinearQCSNW` and the `q8ta_q8csw` implementation that runs through `quantized_linear_impl`). - `gemm/matmul/`: `MatMul.{h,cpp}` (`aten.mm`, `aten.bmm`, `aten.addmm`; renamed from `Matmul.cpp` to match its header) and `MatmulCoopmat.{h,cpp}`. - Weight packing shaders sit in `pack_weights/` subdirectories of the folder that dispatches them (`linear/`, `linear/qw/`, `linear/qw/q4gsw/`, and the shader root for `pack_int4_linear_weight_transposed_interleaved`). - Splits - `QuantizedLinear.cpp`: `q8csw/Q8cswLinear.cpp` (`et_vk.linear_q8csw`, `aten._weight_int8pack_mm`), `legacy/Q8taQ8cswLinear.{h,cpp}` (`add_linear_qa_qw_node`, `et_vk.linear_q8ta_q8csw`), and `dq8ca_q4gsw/Dq8caQ4gswLinear.{h,cpp}` (`add_linear_dqa_qw_node`, `et_vk.linear_dq8ca_q4gsw`). `can_use_q4gsw_coopmat` and the coopmat tile constants are now declared in `QuantizedLinear.h` because the shared and `dq8ca_q4gsw` files both use them. - `GemmCoopmat.cpp`: `linear/LinearCoopmat.cpp` and `matmul/MatmulCoopmat.cpp`. - Functions move unchanged. - Includes - Shaders inside `gemm/` include tile headers as `tile_utils/<header>`; shaders outside `gemm/` include them as `gemm/tile_utils/<header>`. - C++ include paths and `op_registry.py` section labels are updated. - Moved files are recorded as renames, and split files as copies of their source. - Code that moves within or between files is re-linted, so its CLANGTIDY findings are fixed: `(void)` for unused parameters, `utils::safe_downcast` for narrowing in `quantized_linear_gwg` and the coopmat size reads, bounds-checked `.at()` in place of `.back()` in `LinearCoopmat.cpp`, and removal of unused includes (`Softmax.h` in `SDPA.cpp`, `Linear.h` in `Conv1dPW.cpp`, and two utility headers in the coopmat files). Generated shader names and runtime dispatch behavior are unchanged. ghstack-source-id: 445310033 @exported-using-ghexport Differential Revision: [D123523650](https://our.internmc.facebook.com/intern/diff/D123523650/)
This was referenced Oct 9, 2026
This branch was successfully 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.
Stack from ghstack (oldest at bottom):
Ulterior Motive
Organize Vulkan operators by implementation family so operators with multiple routes can use clear, scalable directory layouts.
Rationale
What: Move the linear and matrix multiplication C++ implementations, GLSL templates, YAML variant definitions, and GEMM tile headers under
gemm/in bothimpl/andglsl/, split intolinear/(an activation times a usually prepacked weight) andmatmul/(multiplication between live activations). Quantized linear sources are grouped by how they are quantized, and the multi-schemeQuantizedLinear.cppand the sharedGemmCoopmat.cppare split accordingly.Why: Linear and matmul sources were interleaved by name in the flat directories, quantized linear variants for different schemes shared one file, and the shared GEMM tile headers were scattered across the shader root, which obscured which sources implement which operator, route, and scheme.
Details
impl/andglsl/mirror each other)gemm/:GemmCommon.{h,cpp}(fp weight prepack, resize helpers, and the cooperative-matrix tile constants andis_coopmat_eligible()shared by linear and matmul) andcoopmat_mm, the cooperative-matrix shader shared by both.gemm/tile_utils/: all GEMM tile headers (tile structs, tile load/store/compute, block packing, accumulators, and scale/sum/bias loaders), also used by convolution, SDPA, and quantize shaders.gemm/linear/:Linear.{h,cpp}(aten.linear),LinearCoopmat.{h,cpp}, andbackward/LinearDw.cpp(et_vk.linear_dW).gemm/linear/q8ta/:Q8taLinearandQ8taLinearGemv; activations and weights are quantized ahead of time with static parameters (primarily statically quantized convolutional models).gemm/linear/qw/: weight-only quantization, with activations kept in floating point or quantized dynamically (primarily LLMs and transformers).QuantizedLinear.{h,cpp}hold the shared weight prepacking, workgroup sizing, the weight-only node, andquantized_linear_impl; schemes live inq4gsw/(withbackward/foret_vk.linear_q4gsw_backwardandet_vk.q4gsw_requant),dq8ca_q4gsw/,q8csw/, andlegacy/(QuantizedLinearQCSNWand theq8ta_q8cswimplementation that runs throughquantized_linear_impl).gemm/matmul/:MatMul.{h,cpp}(aten.mm,aten.bmm,aten.addmm; renamed fromMatmul.cppto match its header) andMatmulCoopmat.{h,cpp}.pack_weights/subdirectories of the folder that dispatches them (linear/,linear/qw/,linear/qw/q4gsw/, and the shader root forpack_int4_linear_weight_transposed_interleaved).QuantizedLinear.cpp:q8csw/Q8cswLinear.cpp(et_vk.linear_q8csw,aten._weight_int8pack_mm),legacy/Q8taQ8cswLinear.{h,cpp}(add_linear_qa_qw_node,et_vk.linear_q8ta_q8csw), anddq8ca_q4gsw/Dq8caQ4gswLinear.{h,cpp}(add_linear_dqa_qw_node,et_vk.linear_dq8ca_q4gsw).can_use_q4gsw_coopmatand the coopmat tile constants are now declared inQuantizedLinear.hbecause the shared anddq8ca_q4gswfiles both use them.GemmCoopmat.cpp:linear/LinearCoopmat.cppandmatmul/MatmulCoopmat.cpp.gemm/include tile headers astile_utils/<header>; shaders outsidegemm/include them asgemm/tile_utils/<header>.op_registry.pysection labels are updated.(void)for unused parameters,utils::safe_downcastfor narrowing inquantized_linear_gwgand the coopmat size reads, bounds-checked.at()in place of.back()inLinearCoopmat.cpp, and removal of unused includes (Softmax.hinSDPA.cpp,Linear.hinConv1dPW.cpp, and two utility headers in the coopmat files).Generated shader names and runtime dispatch behavior are unchanged.
Differential Revision: D123523650