Skip to content

[ExecuTorch][WebGPU] Add linear_q8ta_q8csw op (et_vk.linear_q8ta_q8csw)#21213

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

[ExecuTorch][WebGPU] Add linear_q8ta_q8csw op (et_vk.linear_q8ta_q8csw)#21213
JCNTH wants to merge 1 commit into
gh/JCNTH/173/basefrom
gh/JCNTH/173/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 et_vk.linear_q8ta_q8csw — an int8-activation x int8-channelwise-weight linear with a FP32 output (the "output-not-requantized" sibling of the landed q8ta_linear, e.g. a final projection). Its kernel design was ready but it was thought unreachable; the reachability blocker is now solved.

Solution: Port et_vk.linear_q8ta_q8csw (int8 x, int8 per-channel weight, fp32 out), mirroring the landed q8ta_linear (q8ta_linear/Q8taLinear.cpp) with the output requant removed. Before/After vs q8ta_linear: same i32 GEMM Σ(x_int8 - input_zp) * w_int8 + dequant * input_scale * weight_scales[n] + bias, but q8ta_linear then requantizes to int8 (needs output_scale/zp, N%4==0 for output packing) whereas this writes fp32 directly (no output qparams in the schema, N unconstrained). Mirrors Vulkan impl/QuantizedLinear.cpp linear_q8ta_q8csw.

Implementation: linear_q8ta_q8csw/LinearQ8taQ8csw.cpp registers et_vk.linear_q8ta_q8csw -> linear_q8ta_q8csw_impl. Schema [x, input_scale, input_zp, weights, weight_sums, weight_scales, bias?, out]: x/weights int8 (bound array<u32>, unpacked in-shader), weight_sums (arg 4) folded per-element (unused, matching q8ta_linear), out=args.back(). linear_q8ta_q8csw.wgsl register-tiled (TM=TN=4) i32 GEMM, 2D-folded dispatch; the TN=4 tile guards n<N (no N%4 assumption — fp32 output has no packing constraint). Q8taQ8cswParams (32 bytes) matches the WGSL Params. Guards int8 x/weight (numel%4==0 for the u32 reads), fp32 out, scales fp32 [N], all fail-loud.

Constraints / divergences from the Vulkan reference: fp32 output only. A bias-less TERMINAL linear can mis-fuse to an int8 output the schema cannot compute (no output scale/zp) — the handler fail-louds on it (output must be fp32); the correct fp32-out form is what the fusion routes when the output is not re-quantized. i32 accumulator (inherited from q8ta_linear). Buffer-only, so no int8x4 texture layout.

Differential Revision: D112257666

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

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 9984323 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:01

@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