Skip to content

[ExecuTorch][WebGPU] Add et_vk.prepack (constant-tensor packing) for E2E weight loading#20265

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

[ExecuTorch][WebGPU] Add et_vk.prepack (constant-tensor packing) for E2E weight loading#20265
JulianCloudNTH wants to merge 1 commit into
gh/JulianCloudNTH/27/basefrom
gh/JulianCloudNTH/27/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.prepack.default, the node the VulkanPartitioner wraps around every constant feeding a delegated op so the constant is materialized into its dedicated GPU buffer before inference.

For the WebGPU backend's buffer-flat/fp32 model, prepack is an identity layout (same dims, dtype, and bytes), so the handler runs no compute shader: it validates that src and out match (dims, elem_size, nbytes, non-null buffers; every check throws fail-loud) and records a one-time src->out buffer-to-buffer copy via the new WebGPUGraph::add_prepack_copy. The recorded copies run once in a new build() Phase 4 (after the op-dispatch chain is recorded), mirroring the Vulkan delegate's separate prepack() init phase (distinct from per-inference execute()). Ordering is guaranteed by the WebGPU queue -- the prepack submit precedes the first execute() submit on the same queue, so the copied data is visible without an explicit device poll (Dawn has no wgpuDevicePoll, and the backend relies on queue ordering plus the output-map wait elsewhere).

src.elem_size is the WebGPUTensor field added by the embedding op lower in this stack, so prepack stacks above it.

Differential Revision: D108428754

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

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:

❌ 21 New Failures, 2 Unrelated Failures

As of commit bf5c220 with merge base 5526971 (image):

NEW FAILURES - The following jobs have failed:

FLAKY - The following job failed but was likely due to flakiness present on trunk:

BROKEN TRUNK - The following job failed but was 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