Skip to content

[ExecuTorch][WebGPU] Add et_vk.embedding_q4gsw (4-bit groupwise-symmetric quantized embedding)#20263

Open
JulianCloudNTH wants to merge 1 commit into
gh/JulianCloudNTH/25/basefrom
gh/JulianCloudNTH/25/head
Open

[ExecuTorch][WebGPU] Add et_vk.embedding_q4gsw (4-bit groupwise-symmetric quantized embedding)#20263
JulianCloudNTH wants to merge 1 commit into
gh/JulianCloudNTH/25/basefrom
gh/JulianCloudNTH/25/head

Conversation

@JulianCloudNTH

@JulianCloudNTH JulianCloudNTH commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Adds the WebGPU backend handler for et_vk.embedding_q4gsw.default (a 4-bit groupwise-symmetric quantized embedding gather) plus the host-side integer-input infra it requires.

The op is a single compute dispatch composed of one stage: one thread per 32-element block of each gathered row dequantizes the packed 4-bit table (q = (nibble - 8) * scale; even dim = high nibble, odd dim = low) into the fp32 output, mirroring the Vulkan embedding_q4gsw reference (flat buffer-backed weight; is_linear_weight=true is unsupported and throws). The workgroup size is a wg_size pipeline-override constant clamped to the device limit via WebGPUUtils::clamp_workgroup_size, the 1D dispatch count goes through WebGPUUtils::compute_1d_workgroup_count (validated before any GPU-object allocation), and the embedded WGSL string header is generated by gen_wgsl_headers.py.

Embedding indices arrive as int64 at the program boundary but the serialized graph stores them as int32, so the shared input path is extended with a host-side InputData view ({data, nbytes, host_is_int64}) and copy_inputs gains three branches: a byte-for-byte fast path when host and GPU sizes match, an int64->int32 narrowing copy when the buffer is int32 and the host input is twice as wide (mirrors the Vulkan kLong->kInt staging cast), and a fail-loud throw otherwise. WebGPUTensor gains elem_size/is_int to drive the narrowing decision, and update_symints_from_inputs takes the same InputData vector so execute() builds a single input list consumed by both.

Differential Revision: D108428753

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Jun 13, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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:

❌ 22 New Failures, 1 Unrelated Failure

As of commit 0d9b542 with merge base 5526971 (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.

@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.

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.

1 participant