Skip to content

[ExecuTorch][WebGPU] Add q8ta_linear op (int8 quantized linear)#21197

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

[ExecuTorch][WebGPU] Add q8ta_linear op (int8 quantized linear)#21197
JCNTH wants to merge 1 commit into
gh/JCNTH/157/basefrom
gh/JCNTH/157/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 linear — the core C2 GEMM. A plain nn.Linear through XNNPACK static PT2E lowers to a delegated quantize_per_tensor -> q8ta_linear -> dequantize_per_tensor subgraph; the quantize/dequantize are the landed C0 ops, so q8ta_linear is the one missing piece to run a quantized linear end-to-end.

Solution: Port et_vk.q8ta_linear (int8 activation x int8 per-channel weight -> int8), plus et_vk.q8ta_linear_gemv (identical schema, the M==1 case) on the same handler. Register-tiled i32 GEMM: acc = Σ_k (x_int8[m,k] - input_zero_point) * weight_int8[n,k], dequantize acc * input_scale * weight_scales[n] + bias, requantize clamp(round(v * inv_output_scale) + output_zero_point, -128, 127), packed 4 int8 per word. Mirrors Vulkan q8ta_linear.glsl + the landed q4gsw register tiling.

Implementation: Q8taLinear.cpp registers q8ta_linear.default + q8ta_linear_gemv.default, out = args.back(), guards int8 x/weight/out + N % 4 == 0 (output word alignment) + M*K/N*K % 4 == 0 (array binding), fail-loud. activation is read via a new WebGPUGraph string accessor (strings_/get_string, mirroring ints_/doubles_) and throws unless "none" — a relu-fused variant would otherwise silently emit non-relu output.

Constraints / divergences from the Vulkan reference (both numerically equivalent, byte-exact-verified): (1) the weight_sums arg is unused — the input zero-point correction is folded per-element (Σ(x-zp)·w == Σx·w - zp·Σw) instead of Vulkan's precomputed weight_sums. (2) x/weight are read row-major [M,K]/[N,K] (WebGPU's always-buffer convention; C0 quantize_per_tensor emits row-major int8 and no prepack runs), not Vulkan's 4H4W-packed/block-transposed layout — consistent with the landed q4gsw. activation scoped to "none" (the XNNPACK-static default; relu-fused is fail-loud, a follow-up).

Differential Revision: D112257601

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

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:

❌ 33 New Failures, 3 Unrelated Failures

As of commit 4a0ab21 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
@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.

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:04

@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