Skip to content

Comments

[ET-VK][qconv] Add apply_relu support to q8ta conv operators#17575

Merged
SS-JIA merged 4 commits intogh/SS-JIA/433/origfrom
gh/SS-JIA/434/orig
Feb 20, 2026
Merged

[ET-VK][qconv] Add apply_relu support to q8ta conv operators#17575
SS-JIA merged 4 commits intogh/SS-JIA/433/origfrom
gh/SS-JIA/434/orig

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: #17506 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/434/base
ghstack PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/434/head
Merge bot PR base: https://github.com/pytorch/executorch/tree/gh/SS-JIA/433/orig
Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/434/orig
Differential Revision: D93511632
@diff-train-skip-merge

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/)
@pytorchbot pytorchbot requested a review from SS-JIA as a code owner February 20, 2026 01:13
@pytorch-bot
Copy link

pytorch-bot bot commented Feb 20, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/17575

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

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla 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 Feb 20, 2026
ssjia added 3 commits February 19, 2026 20:15
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 SS-JIA merged commit 4a9b842 into gh/SS-JIA/433/orig Feb 20, 2026
39 of 40 checks passed
@SS-JIA SS-JIA deleted the gh/SS-JIA/434/orig branch February 20, 2026 01:16
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants