Skip to content

[ExecuTorch][WebGPU] Add q8ta_pixel_shuffle op (int8 pixel_shuffle)#21195

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

[ExecuTorch][WebGPU] Add q8ta_pixel_shuffle op (int8 pixel_shuffle)#21195
JCNTH wants to merge 1 commit into
gh/JCNTH/155/basefrom
gh/JCNTH/155/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 pixel_shuffle — the last C1 q8ta elementwise/shape op on the int8 path C0 established.

Solution: Port et_vk.q8ta_pixel_shuffle (int8 [N, C*r*r, H, W] -> int8 [N, C, H*r, W*r]): gather via the pixel_shuffle inverse, then dequantize -> requantize per element. Reuses the landed fp32 pixel_shuffle gather index math + the C0/q8ta_add int8 pack/unpack + requant.

Implementation: Q8taPixelShuffle.cpp registers et_vk.q8ta_pixel_shuffle.default (out = args.back()); one thread per packed output word gathers 4 int8 elements from arbitrary input positions (c_in = c_out*r*r + (h_out%r)*r + (w_out%r), h_in = h_out/r, w_in = w_out/r), each clamp(round(input_scale*(q - input_zero_point) * output_inv_scale) + output_zero_point, -128, 127). Guards int8 in/out + equal numel + numel % 4 == 0 + in_c % (r*r) == 0, fail-loud; a resize hook (supports_resize=True) recomputes shape/numel/dispatch + rewrites the UBO. Mirrors Vulkan q8ta_pixel_shuffle.glsl.

Constraints / divergences: (1) the schema's 4th arg is output_inv_scale (already 1/output_scale) — passed straight, NOT re-inverted (unlike q8ta_relu/q8ta_add). (2) Vulkan uses a channels-packed int8x4 layout; this port uses the backend's flat NCHW buffer (always-buffer design) with a re-derived gather — logically identical for a per-tensor-quantized rearrange (byte-exact vs the eager op). (3) Vulkan's same-qparams passthrough fast-path is omitted; the general dequant->requant is byte-identical there (round((q-zp)*s*(1/s))+zp == q).

Differential Revision: D112257587

[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/21195

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:

❌ 34 New Failures, 3 Unrelated Failures

As of commit 72f40ab 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
@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:05

@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