[ExecuTorch][WebGPU] Add et_vk.prepack (constant-tensor packing) for E2E weight loading#20265
[ExecuTorch][WebGPU] Add et_vk.prepack (constant-tensor packing) for E2E weight loading#20265JulianCloudNTH wants to merge 4 commits into
Conversation
🔗 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 Cancelled JobAs of commit 260a038 with merge base 0378fc4 ( CANCELLED JOB - The following job was cancelled. Please retry:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
…E2E weight loading Pull Request resolved: #20265 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. ghstack-source-id: 393506814 @exported-using-ghexport Differential Revision: [D108428754](https://our.internmc.facebook.com/intern/diff/D108428754/)
|
@claude review |
|
Claude finished @JulianCloudNTH's task in 2m 23s —— View job Code Review: WebGPU
|
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
srcandoutmatch (dims,elem_size,nbytes, non-null buffers; every check throws fail-loud) and records a one-timesrc->outbuffer-to-buffer copy via the newWebGPUGraph::add_prepack_copy. The recorded copies run once in a newbuild()Phase 4 (after the op-dispatch chain is recorded), mirroring the Vulkan delegate's separateprepack()init phase (distinct from per-inferenceexecute()). Ordering is guaranteed by the WebGPU queue -- the prepack submit precedes the firstexecute()submit on the same queue, so the copied data is visible without an explicit device poll (Dawn has nowgpuDevicePoll, and the backend relies on queue ordering plus the output-map wait elsewhere).src.elem_sizeis theWebGPUTensorfield added by the embedding op lower in this stack, so prepack stacks above it.@exported-using-ghexport
Differential Revision: D108428754
Differential Revision: D108428754