[ET-VK][qconv] Fix depthwise weight_sums sum dimension#17573
Merged
Conversation
Pull Request resolved: #17504 The weight_sums tensor stores per-output-channel sums of quantized weight values, used to apply activation zero point correction during integer accumulation. For depthwise convolutions, the weight tensor is reshaped to (H, W, OC), but the sum was unconditionally computed along dim=1 (the W dimension). This produced a tensor of shape (H, OC) instead of (OC,), causing incorrect zero point correction and corrupted depthwise conv output. Fix by branching on is_depthwise_conv to sum over dims (0, 1) for the (H, W, OC) layout. ghstack-source-id: 342806069 @exported-using-ghexport Differential Revision: [D93511635](https://our.internmc.facebook.com/intern/diff/D93511635/)
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/17573
Note: Links to docs will display an error until the docs builds have been completed. ⏳ No Failures, 125 PendingAs of commit 6730837 with merge base 7b843e4 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
added 5 commits
February 19, 2026 20:17
Pull Request resolved: #17505 The q8ta convolution shaders read weight_sums via ivec4 loads (4 int32 values at once), requiring the buffer to have at least align_up_4(OC) elements. The weight tensor, weight_scales, and bias are all padded via align_width_and_update_state_dict, but weight_sums was created as a 1D tensor of shape (OC,) without any padding. For OC values that are not a multiple of 4 (e.g. OC=1 in the final pointwise conv of MetaNet GreenScreen), this results in out-of-bounds GPU buffer reads. On host testing with ASAN, this manifests as a heap-buffer-overflow. Fix by padding sum_per_output_channel to align_up_4(OC) before creating the constant placeholder. Also fix the C++ test utility compute_weight_sums() which was incorrectly shrinking a pre-allocated aligned buffer. ghstack-source-id: 342806075 @exported-using-ghexport Differential Revision: [D93511633](https://our.internmc.facebook.com/intern/diff/D93511633/)
Pull Request resolved: #17506 The quantized convolution pattern detector correctly identifies ReLU nodes between conv output and the output quantize node, but the pattern replacement did not pass this information to the fused q8ta operator. When the pattern replaced `dequant → conv → relu → quant` with `q8ta_conv2d`, the relu node was removed from the graph but its effect was not preserved. This silently removed all conv-relu non-linearity from int8 quantized models. Add an `apply_relu` parameter throughout the full pipeline: - Custom op schemas and reference implementations (custom_ops_lib.py) - Pattern replacement (quantized_convolution.py) - C++ dispatch logic extracts apply_relu and passes it as a spec constant (Q8taConv2d.cpp, Q8taConv2dDW.cpp, Q8taConv2dPW.cpp, Q8taConv2dIm2Col.cpp) - GLSL shaders apply conditional max(value, 0) after dequantization and before requantization (q8ta_conv2d.glsl, q8ta_conv2d_dw.glsl, q8ta_conv2d_pw.glsl) - Test operator wrappers updated with proper legacy path handling (TestQ8taConv2d.cpp) ghstack-source-id: 342806070 @exported-using-ghexport Differential Revision: [D93511632](https://our.internmc.facebook.com/intern/diff/D93511632/)
Pull Request resolved: #17507 This adds a fused quantized unary operator (ReLU) that operates directly on int8x4 packed buffer tensors, avoiding the overhead of separate dequantize-relu-requantize dispatches. The implementation follows the same pattern as q8ta_binary: a single GLSL compute shader dequantizes int8x4 blocks to float, applies the unary operation, and requantizes back to int8x4 in one dispatch. The shader uses the OPERATOR macro for parameterization so additional unary ops can be added as YAML variants without new shader code. Components added: - GLSL shader (q8ta_unary.glsl) and YAML config with relu variant - C++ operator implementation (Q8taUnary.cpp/h) registering et_vk.q8ta_relu.default - Export graph fusion pattern (quantized_unary.py) that detects dequant->relu->quant sequences and replaces them with the fused op - Custom op definition (q8ta_relu in custom_ops_lib.py) for the export pipeline - Test harness (TestQ8taUnary.cpp, test_q8ta_unary.cpp) with reference implementation and coverage across multiple shapes and quantized layouts This diff was authored with Claude. ghstack-source-id: 342806073 @exported-using-ghexport Differential Revision: [D93511629](https://our.internmc.facebook.com/intern/diff/D93511629/)
Pull Request resolved: #17508 The batch norm operator registration had a check_batch_norm_node guard that restricted partitioning to 4D input tensors only. Since batch norm is always fused with adjacent operations during graph compilation, this restriction is unnecessary and prevents valid models from being partitioned to the Vulkan backend. Remove the guard so batch norm is always eligible for Vulkan partitioning regardless of input dimensionality. ghstack-source-id: 342806074 @exported-using-ghexport Differential Revision: [D93511630](https://our.internmc.facebook.com/intern/diff/D93511630/)
Previously, the q8ta_binary operator required both inputs to use the same memory layout. This was enforced by using a single `in_layout` specialization constant for both input buffers. However, some models may have inputs with different layouts (e.g., 4W4C and 4C1W) that share the same packed dimension and block size, which should be compatible for binary operations. This change introduces a separate `other_layout` specialization constant for the second input, allowing the shader to correctly load from input_b using its actual layout while input_a continues to use `in_layout`. The C++ side now passes both layout hashes as separate specialization constants to the shader. Differential Revision: [D93768638](https://our.internmc.facebook.com/intern/diff/D93768638/) ghstack-source-id: 342806076 Pull Request resolved: #17563
SS-JIA
approved these changes
Feb 20, 2026
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: #17504 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/432/base
ghstack PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/432/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/432/orig
Differential Revision: D93511635
@diff-train-skip-merge