Skip to content

[ET-VK][qconv] Add layout-flexible impl of quantized depthwise conv2d#17108

Open
SS-JIA wants to merge 3 commits intogh/SS-JIA/401/basefrom
gh/SS-JIA/401/head
Open

[ET-VK][qconv] Add layout-flexible impl of quantized depthwise conv2d#17108
SS-JIA wants to merge 3 commits intogh/SS-JIA/401/basefrom
gh/SS-JIA/401/head

Conversation

@SS-JIA
Copy link
Contributor

@SS-JIA SS-JIA commented Feb 2, 2026

Stack from ghstack (oldest at bottom):

Adds a new layout-agnostic quantized depthwise convolution operator
etvk.q8ta_conv2d_dw that uses BufferMetadata and layout specialization
constants to support arbitrary memory layouts (contiguous, channels-last,
4W4C block-packed, etc.).

Key changes:

  1. New shader q8ta_conv2d_dw.glsl:

    • Uses BufferMetadata for input/output tensor addressing
    • Layout-aware via inp_layout/outp_layout specialization constants
    • Processes 4 adjacent width positions × 4 channels per thread (4Wx4C tile)
    • Includes optimized paths for simple layouts (outer_block_size == 1)
  2. New indexing utilities in indexing.glslh:

    • texel_idx_to_tensor4d_idx(): converts linear texel index to 4D tensor coords
    • tensor4d_idx_to_texel_idx(): converts 4D tensor index to texel index
  3. Code refactoring:

    • Extract Conv2DParams struct and create_conv2d_params() to ConvolutionUtils.h
    • Create Q8taConv2dDW.cpp with new operator implementation
    • Add Q8taConv2d.h with public API declarations
    • Move prepack_quantized_conv2d_dw_weight() to new implementation file
  4. New workgroup size helpers:

    • pick_q8ta_conv2d_dw_global_wg_size(): computes {W4, H, C4} dispatch size
    • pick_q8ta_conv2d_dw_local_wg_size(): adaptive local size based on tensor dims
  5. Test updates:

    • Rename test to test_q8_conv2d_dw.cpp
    • Add TestQ8taConv2d.cpp with shared test utilities

Differential Revision: D92061368

Adds a new layout-agnostic quantized depthwise convolution operator
`etvk.q8ta_conv2d_dw` that uses BufferMetadata and layout specialization
constants to support arbitrary memory layouts (contiguous, channels-last,
4W4C block-packed, etc.).

Key changes:

1. New shader `q8ta_conv2d_dw.glsl`:
   - Uses BufferMetadata for input/output tensor addressing
   - Layout-aware via `inp_layout`/`outp_layout` specialization constants
   - Processes 4 adjacent width positions × 4 channels per thread (4Wx4C tile)
   - Includes optimized paths for simple layouts (outer_block_size == 1)

2. New indexing utilities in `indexing.glslh`:
   - `texel_idx_to_tensor4d_idx()`: converts linear texel index to 4D tensor coords
   - `tensor4d_idx_to_texel_idx()`: converts 4D tensor index to texel index

3. Code refactoring:
   - Extract `Conv2DParams` struct and `create_conv2d_params()` to ConvolutionUtils.h
   - Create Q8taConv2dDW.cpp with new operator implementation
   - Add Q8taConv2d.h with public API declarations
   - Move `prepack_quantized_conv2d_dw_weight()` to new implementation file

4. New workgroup size helpers:
   - `pick_q8ta_conv2d_dw_global_wg_size()`: computes {W4, H, C4} dispatch size
   - `pick_q8ta_conv2d_dw_local_wg_size()`: adaptive local size based on tensor dims

5. Test updates:
   - Rename test to `test_q8_conv2d_dw.cpp`
   - Add `TestQ8taConv2d.cpp` with shared test utilities

Differential Revision: [D92061368](https://our.internmc.facebook.com/intern/diff/D92061368/)

[ghstack-poisoned]
@pytorch-bot
Copy link

pytorch-bot bot commented Feb 2, 2026

🔗 Helpful Links

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

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

❌ 4 New Failures, 1 Pending, 1 Unrelated Failure

As of commit f77a947 with merge base 477867a (image):

NEW FAILURES - The following jobs have failed:

BROKEN TRUNK - The following job 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 pushed a commit that referenced this pull request Feb 2, 2026
Adds a new layout-agnostic quantized depthwise convolution operator
`etvk.q8ta_conv2d_dw` that uses BufferMetadata and layout specialization
constants to support arbitrary memory layouts (contiguous, channels-last,
4W4C block-packed, etc.).

Key changes:

1. New shader `q8ta_conv2d_dw.glsl`:
   - Uses BufferMetadata for input/output tensor addressing
   - Layout-aware via `inp_layout`/`outp_layout` specialization constants
   - Processes 4 adjacent width positions × 4 channels per thread (4Wx4C tile)
   - Includes optimized paths for simple layouts (outer_block_size == 1)

2. New indexing utilities in `indexing.glslh`:
   - `texel_idx_to_tensor4d_idx()`: converts linear texel index to 4D tensor coords
   - `tensor4d_idx_to_texel_idx()`: converts 4D tensor index to texel index

3. Code refactoring:
   - Extract `Conv2DParams` struct and `create_conv2d_params()` to ConvolutionUtils.h
   - Create Q8taConv2dDW.cpp with new operator implementation
   - Add Q8taConv2d.h with public API declarations
   - Move `prepack_quantized_conv2d_dw_weight()` to new implementation file

4. New workgroup size helpers:
   - `pick_q8ta_conv2d_dw_global_wg_size()`: computes {W4, H, C4} dispatch size
   - `pick_q8ta_conv2d_dw_local_wg_size()`: adaptive local size based on tensor dims

5. Test updates:
   - Rename test to `test_q8_conv2d_dw.cpp`
   - Add `TestQ8taConv2d.cpp` with shared test utilities

Differential Revision: [D92061368](https://our.internmc.facebook.com/intern/diff/D92061368/)

ghstack-source-id: 337539965
Pull Request resolved: #17108
@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 2, 2026
@github-actions
Copy link

github-actions bot commented Feb 2, 2026

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

…wise conv2d"

Adds a new layout-agnostic quantized depthwise convolution operator
`etvk.q8ta_conv2d_dw` that uses BufferMetadata and layout specialization
constants to support arbitrary memory layouts (contiguous, channels-last,
4W4C block-packed, etc.).

Key changes:

1. New shader `q8ta_conv2d_dw.glsl`:
   - Uses BufferMetadata for input/output tensor addressing
   - Layout-aware via `inp_layout`/`outp_layout` specialization constants
   - Processes 4 adjacent width positions × 4 channels per thread (4Wx4C tile)
   - Includes optimized paths for simple layouts (outer_block_size == 1)

2. New indexing utilities in `indexing.glslh`:
   - `texel_idx_to_tensor4d_idx()`: converts linear texel index to 4D tensor coords
   - `tensor4d_idx_to_texel_idx()`: converts 4D tensor index to texel index

3. Code refactoring:
   - Extract `Conv2DParams` struct and `create_conv2d_params()` to ConvolutionUtils.h
   - Create Q8taConv2dDW.cpp with new operator implementation
   - Add Q8taConv2d.h with public API declarations
   - Move `prepack_quantized_conv2d_dw_weight()` to new implementation file

4. New workgroup size helpers:
   - `pick_q8ta_conv2d_dw_global_wg_size()`: computes {W4, H, C4} dispatch size
   - `pick_q8ta_conv2d_dw_local_wg_size()`: adaptive local size based on tensor dims

5. Test updates:
   - Rename test to `test_q8_conv2d_dw.cpp`
   - Add `TestQ8taConv2d.cpp` with shared test utilities

Differential Revision: [D92061368](https://our.internmc.facebook.com/intern/diff/D92061368/)

[ghstack-poisoned]
…wise conv2d"

Adds a new layout-agnostic quantized depthwise convolution operator
`etvk.q8ta_conv2d_dw` that uses BufferMetadata and layout specialization
constants to support arbitrary memory layouts (contiguous, channels-last,
4W4C block-packed, etc.).

Key changes:

1. New shader `q8ta_conv2d_dw.glsl`:
   - Uses BufferMetadata for input/output tensor addressing
   - Layout-aware via `inp_layout`/`outp_layout` specialization constants
   - Processes 4 adjacent width positions × 4 channels per thread (4Wx4C tile)
   - Includes optimized paths for simple layouts (outer_block_size == 1)

2. New indexing utilities in `indexing.glslh`:
   - `texel_idx_to_tensor4d_idx()`: converts linear texel index to 4D tensor coords
   - `tensor4d_idx_to_texel_idx()`: converts 4D tensor index to texel index

3. Code refactoring:
   - Extract `Conv2DParams` struct and `create_conv2d_params()` to ConvolutionUtils.h
   - Create Q8taConv2dDW.cpp with new operator implementation
   - Add Q8taConv2d.h with public API declarations
   - Move `prepack_quantized_conv2d_dw_weight()` to new implementation file

4. New workgroup size helpers:
   - `pick_q8ta_conv2d_dw_global_wg_size()`: computes {W4, H, C4} dispatch size
   - `pick_q8ta_conv2d_dw_local_wg_size()`: adaptive local size based on tensor dims

5. Test updates:
   - Rename test to `test_q8_conv2d_dw.cpp`
   - Add `TestQ8taConv2d.cpp` with shared test utilities

Differential Revision: [D92061368](https://our.internmc.facebook.com/intern/diff/D92061368/)

[ghstack-poisoned]
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. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant