[ExecuTorch][WebGPU] mul op test suite (cases.py op-test framework)#20528
Merged
Conversation
Pull Request resolved: #20359 Registers `aten.mul.Tensor` in the `cases.py` op-test framework: a `_mul_suite` of 3 configs (same-shape fast path, last-dim broadcast at LLM width, mixed-rank left-pad) that `generate_op_tests` exports via `VulkanPartitioner` and compares to an fp64 torch golden on Dawn. Also adds `test/ops/mul/test_mul.py` (`MulModule` + `CONFIGS` + an export-delegation/eager smoke test) and the `aten.mul.Tensor` partitioner-allowlist entry in `tester.py`. ghstack-source-id: 397026499 @exported-using-ghexport Differential Revision: [D108793154](https://our.internmc.facebook.com/intern/diff/D108793154/)
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20528
Note: Links to docs will display an error until the docs builds have been completed. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
Pull Request resolved: #20360 **Add `aten.view_copy.default` as a native buffer-to-buffer DMA** — a contiguous reshape on the dense row-major buffer backend is a flat copy, so it needs no shader. **Problem:** a reshape only relabels shape metadata; the bytes are unchanged. Launching a compute dispatch (shader module + pipeline + bind group + uniform) just to run `output[i] = input[i]` is wasted setup for every view/clone/squeeze/unsqueeze in the graph. **Solution:** - Before: a `view_copy.wgsl` compute kernel dispatched over `num_elements`, with its own pipeline/bind-group/uniform per copy. - After: `add_flat_copy` records a `wgpuCommandEncoderCopyBufferToBuffer` DMA in graph order — no shader, no pipeline, no uniform. **Implementation:** - `WebGPUGraph` gains a `WebGPUDispatch::Kind::Copy` command + `add_buffer_copy(src, dst, nbytes)`; `execute()` emits the encoder-level copy between compute passes (both single-shot and chunked paths), preserving the existing per-pass read-after-write ordering. - `add_flat_copy` (declared in `view_copy.h`, reused by the stacked clone/squeeze/unsqueeze) keeps the fail-loud guards (both tensors, fp32 4-byte alignment, equal `nbytes`) and treats an aliased in/out buffer as a no-op. - Tensor buffers already carry `CopySrc | CopyDst`, so no usage-flag change is needed. - Mirrors Vulkan `add_view_copy_node` (`backends/vulkan/runtime/graph/ops/impl/View.cpp`): Vulkan always dispatches `view_buffer.glsl` only to remap non-contiguous layouts, which the buffer-only WebGPU backend never produces — so the contiguous DMA is the equivalent path. ghstack-source-id: 397026498 @exported-using-ghexport Differential Revision: [D108793164](https://our.internmc.facebook.com/intern/diff/D108793164/)
…ork) Pull Request resolved: #20361 Registers `aten.view_copy.default` in the `cases.py` op-test framework: a `_view_copy_suite` of 3 configs (rank-reducing reshape `(2,3,4)->(6,4)`, flatten `->(-1,)`, rank-increasing reshape `->(1,2,3,4)`) that `generate_op_tests` exports via `VulkanPartitioner` and compares to a torch golden on Dawn. Also adds `test/ops/view_copy/test_view_copy.py` (`ViewModule` + `CONFIGS` + export-delegation/eager smoke test) and the `aten.view_copy.default` partitioner-allowlist entry in `tester.py`. ghstack-source-id: 397026501 @exported-using-ghexport Differential Revision: [D108793155](https://our.internmc.facebook.com/intern/diff/D108793155/)
Pull Request resolved: #20362 Adds `aten.select_copy.int` to the WebGPU delegate as a gather: picks a fixed index along one dim, producing an output of rank (input rank - 1). Composition (single dispatch): - `select/Select.cpp` — reads `[self, dim, index, out]` (static `Int` via `read_scalar`; throws on dynamic `SymInt`), normalizes + bounds-checks dim/index, builds 2 `TensorMeta` UBOs + a `SelectParams{dim,index}`, fp32 guard, 1D-dispatch over `numel`, releases uniforms after the bind group. - `select/select.wgsl` — seeds the input offset with `index * in.strides[dim]`, delinearizes the output index, maps each out dim to its in dim (shifted past the selected dim), relinearizes on input strides. ghstack-source-id: 397026510 @exported-using-ghexport Differential Revision: [D108793166](https://our.internmc.facebook.com/intern/diff/D108793166/)
…ework) Pull Request resolved: #20363 Registers `aten.select_copy.int` in the `cases.py` op-test framework: a `_select_suite` of 4 configs (leading/middle/last dim + negative index) that `generate_op_tests` exports and compares to a torch golden on Dawn. Also adds `test/ops/select/test_select.py` (`SelectModule` + `CONFIGS` + an export-delegation/eager smoke test) and the `aten.select_copy.int` partitioner-allowlist entry in `tester.py`. ghstack-source-id: 397026513 @exported-using-ghexport Differential Revision: [D108793161](https://our.internmc.facebook.com/intern/diff/D108793161/)
Pull Request resolved: #20390 Adds `aten.sigmoid.default` to the WebGPU delegate: element-wise `1/(1+exp(-x))` over a flat fp32 buffer. On the Llama critical path (`F.silu` -> `sigmoid` + `mul`). Composition (single dispatch): - `sigmoid/UnaryOp.cpp` — binds input (storage, read-only) + output (storage) + a `Params{num_elements}` uniform, 1D-dispatches over `num_elements` with `override wg_size` (clamped to the device limit); mirrors the `add` op (uniform mapped-at-creation, released after the bind group). - `sigmoid/sigmoid.wgsl` — guards `idx >= num_elements` and writes the logistic of each element. ghstack-source-id: 397026515 @exported-using-ghexport Differential Revision: [D108793157](https://our.internmc.facebook.com/intern/diff/D108793157/)
Pull Request resolved: #20391 Registers `aten.sigmoid.default` in the `cases.py` op-test framework: a `_sigmoid_suite` (hard-coded shapes + a saturation case over a `linspace(-12, 12)` input) that `generate_op_tests` exports and compares to an fp64 torch golden on Dawn. Also adds `test/ops/sigmoid/test_sigmoid.py` (`SigmoidModule` + `N` + `_det_input` + an export-delegation/eager smoke test) and the `aten.sigmoid.default` partitioner-allowlist entry in `tester.py`. ghstack-source-id: 397026520 @exported-using-ghexport Differential Revision: [D108793159](https://our.internmc.facebook.com/intern/diff/D108793159/)
Pull Request resolved: #20392 Adds `aten.squeeze_copy.dims` and `aten.unsqueeze_copy.default` to the WebGPU delegate. Both are numel-preserving shape ops; on a dense row-major buffer backend they are the same flat copy as `view_copy` — only the shape metadata differs (mirrors the Vulkan delegate, which routes both through `add_view_copy_node`). Composition (no new kernel): - `squeeze/Squeeze.cpp` — reads `args = [self, dims, out]`, ignores the AOT-fixed `dims`, calls `add_flat_copy(graph, in, out)` from `runtime/ops/view_copy/view_copy.h`. - `unsqueeze/Unsqueeze.cpp` — reads `args = [self, dim, out]`, ignores the AOT-fixed `dim`, calls `add_flat_copy(graph, in, out)`. ghstack-source-id: 397026523 @exported-using-ghexport Differential Revision: [D108793153](https://our.internmc.facebook.com/intern/diff/D108793153/)
….py op-test framework) Pull Request resolved: #20393 Registers `aten.squeeze_copy.dims` and `aten.unsqueeze_copy.default` in the `cases.py` op-test framework: a `_squeeze_suite` of 3 configs (squeeze leading/middle/multiple size-1 dims) and a `_unsqueeze_suite` of 3 configs (insert dim at front/middle/last) that `generate_op_tests` exports via `VulkanPartitioner` and compares to a torch golden on Dawn. Also adds `test/ops/squeeze/test_squeeze.py` (`SqueezeModule` + `CONFIGS` + `_op_delegated` smoke test), `test/ops/unsqueeze/test_unsqueeze.py` (`UnsqueezeModule` + `CONFIGS` + `_op_delegated` smoke test), and the two partitioner-allowlist entries in `tester.py`. ghstack-source-id: 397026525 @exported-using-ghexport Differential Revision: [D108793152](https://our.internmc.facebook.com/intern/diff/D108793152/)
JulianCloudNTH
approved these changes
Jun 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR was created by the merge bot to help merge the original PR into the main branch.
ghstack PR number: #20359 by @JulianCloudNTH
^ Please use this as the source of truth for the PR details, comments, and reviews
ghstack PR base: https://github.com/pytorch/executorch/tree/gh/JulianCloudNTH/34/base
ghstack PR head: https://github.com/pytorch/executorch/tree/gh/JulianCloudNTH/34/head
Merge bot PR base: https://github.com/pytorch/executorch/tree/main
Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/JulianCloudNTH/34/orig
@diff-train-skip-merge