Skip to content

[ExecuTorch][WebGPU] Add q8ta_conv2d_transposed op (int8 transposed conv)#21205

Open
JCNTH wants to merge 1 commit into
gh/JCNTH/165/basefrom
gh/JCNTH/165/head
Open

[ExecuTorch][WebGPU] Add q8ta_conv2d_transposed op (int8 transposed conv)#21205
JCNTH wants to merge 1 commit into
gh/JCNTH/165/basefrom
gh/JCNTH/165/head

Conversation

@JCNTH

@JCNTH JCNTH commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Problem: The WebGPU delegate has no quantized transposed convolution (deconvolution). An nn.ConvTranspose2d through XNNPACK static PT2E lowers to a delegated quantize_per_tensor -> q8ta_conv2d_transposed -> dequantize_per_tensor subgraph; the quantize/dequantize are the landed C0 ops, so q8ta_conv2d_transposed is the one missing piece to run a quantized deconv end-to-end. This completes the int8 conv2d family (pointwise, depthwise, general, transposed).

Solution: Port et_vk.q8ta_conv2d_transposed (int8 activation x int8 per-channel weight -> int8) as a direct gather. Per output element: acc = Σ_{ic,kh,kw} (x_int8[n,ic,ih,iw] - input_zero_point) * weight_int8[oc, (kh*Kw+kw)*IC + ic] where ih = (oh + pad_h - kh*dil_h) / stride_h is taken only when the numerator is non-negative and divisible by stride_h and ih < H_in (iw analogously); dequantize acc * input_scale * weight_scales[oc] + bias, requantize clamp(round(v * inv_output_scale) + output_zero_point, -128, 127), packed 4 int8 per word. Mirrors Vulkan q8ta_conv2d_transposed (Q8taConv2dTransposed.cpp + q8ta_conv2d_transposed.glsl); reuses the general q8ta_conv2d int8 scaffold + [OC, Kh*Kw*IC] weight layout, changing only the index relation to the transposed gather.

Implementation: Q8taConv2dTransposed.cpp registers q8ta_conv2d_transposed.default, out = args.back(), one thread per output word = 4 consecutive W_out positions of a fixed (n, oc, oh) (W_out % 4 == 0), 2D dispatch fold. The transposed schema inserts output_padding at arg 12, so dilation is read from arg 13 and groups from arg 14 (output_padding itself is unused — the output H/W come from the serialized output dims). The weight row stride is read from weight.dims[1] to tolerate align-width padding of Kh*Kw*IC; scales/bias are read as >= [OC] (the AOT pads OC to a multiple of 4; the shader reads only [0, OC)). Guards [N,IC,H_in,W_in] / [OC,Kh*Kw*IC] / [N,OC,H_out,W_out] ranks, int8 dtypes, groups == 1, dilation == 1, stride >= 1, and activation == "none" (all fail-loud). Q8taConvTParams is a 96-byte (16-aligned) uniform.

Constraints / divergences from the Vulkan reference (numerically equivalent, golden-verified): (1) the weight_sums arg is unused — the input zero-point correction is folded per-element (Σ(x-zp)·w == Σx·w - zp·Σw), matching Vulkan's weight_sums compensation exactly (Vulkan fills out-of-bounds taps with the zero-point, which contribute (zp-zp)·w = 0 = the skipped taps here). (2) weight arrives raw [OC, Kh*Kw*IC] int8 (the AOT reshape maps weight[oc,(kh*Kw+kw)*IC+ic] = original[ic,oc,kh,kw]; the WebGPU prepack is a passthrough), not Vulkan's int8x4-block layout. dilation != 1 (matching Vulkan's own restriction), groups > 1, and activation != "none" are fail-loud follow-ups.

Differential Revision: D112257642

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 46 New Failures, 3 Unrelated Failures

As of commit 75b891d with merge base 266e0dc (image):

NEW FAILURES - The following jobs have failed:

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

  • pull / unittest / windows / windows-job (gh) (matched win rule in flaky-rules.json)
    Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under 'C:\actions-runner\_work\executorch\executorch\test-infra\.github\actions\teardown-windows'. Did you forget to run actions/checkout before running your local action?
  • pull / unittest-editable / windows / windows-job (gh) (matched win rule in flaky-rules.json)
    Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under 'C:\actions-runner\_work\executorch\executorch\test-infra\.github\actions\teardown-windows'. Did you forget to run actions/checkout before running your local action?

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.

This was referenced Jul 22, 2026
This was referenced Jul 22, 2026
@github-actions

Copy link
Copy Markdown

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.

@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 Jul 22, 2026
@JCNTH
JCNTH requested a review from psiddh July 23, 2026 02:02

@psiddh psiddh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving full WebGPU stack

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