Skip to content

[ExecuTorch][WebGPU] Add split_with_sizes_copy op - #21281

Merged
JCNTH merged 3 commits into
gh/JCNTH/98/origfrom
gh/JCNTH/99/orig
Jul 23, 2026
Merged

[ExecuTorch][WebGPU] Add split_with_sizes_copy op#21281
JCNTH merged 3 commits into
gh/JCNTH/98/origfrom
gh/JCNTH/99/orig

Conversation

@pytorchbot

Copy link
Copy Markdown
Collaborator

This PR was created by the merge bot to help merge the original PR into the main branch.
ghstack PR number: #20995 by @JCNTH
^ 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/JCNTH/99/base
ghstack PR head: https://github.com/pytorch/executorch/tree/gh/JCNTH/99/head
Merge bot PR base: https://github.com/pytorch/executorch/tree/gh/JCNTH/98/orig
Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/JCNTH/99/orig

@diff-train-skip-merge

Pull Request resolved: #20995

**Add `aten.split_with_sizes_copy.default` to the WebGPU backend** — the split on YOLO's Detect head (separating the concatenated box / objectness / class predictions).

**Problem**: The WebGPU delegate had no `split_with_sizes_copy`, so YOLO object-detection could not fully delegate to the GPU.

**Solution**: Split `self` along `dim` into N contiguous chunks. Each chunk is a step-1 slice from the running offset, reusing the `slice.wgsl` gather kernel — one dispatch per output. Outputs arrive as a serialized ValueList. Each chunk writes its own distinct output buffer and reads only the shared input, so there is no cross-dispatch read-after-write hazard.

**Implementation**:
- `runtime/ops/split_with_sizes/SplitWithSizes.cpp` registering `aten.split_with_sizes_copy.default`; reuses `slice_wgsl.h` (no new shader). Uses `utils::make_compute_pipeline` (auto-derived bind-group layout) rather than hand-rolling the layout / pipeline / bind group.
- Mirrors the Vulkan `split_with_sizes_copy` delegate.
- CMake `WEBGPU_SRCS` entry.

**Constraints**: fp32-only; `dim` normalized + range-checked; `outputs == sizes` count enforced (fail-loud). Reuses the `slice` op's `slice_wgsl.h`, so this diff stacks above `slice` and must land after it. No change to existing ops.
ghstack-source-id: 405949786
@exported-using-ghexport

Differential Revision: [D112417284](https://our.internmc.facebook.com/intern/diff/D112417284/)
@pytorch-bot

pytorch-bot Bot commented Jul 23, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@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 23, 2026
JCNTH added 2 commits July 23, 2026 08:56
Pull Request resolved: #20996

**Op-test suite for `aten.split_with_sizes_copy.default`** (stacked on the split_with_sizes_copy op diff).

Adds `test/ops/test_split_with_sizes_copy.py` (`SplitWithSizesModule` — `torch.split` by a size list) + a `@register_op_test("split_with_sizes_copy")` suite in `test/op_tests/cases.py` (3 cases: a 3-way channel split, a dim-0 split, and a last-dim split). Multi-output: the framework compares chunk 0 (out_index 0) while each case exercises all N per-chunk dispatches. `copy` is bit-exact, so the golden is float32.
ghstack-source-id: 405949787
@exported-using-ghexport

Differential Revision: [D112417279](https://our.internmc.facebook.com/intern/diff/D112417279/)
…ipeline

Pull Request resolved: #20868

Route `add`, `mul`, `index`, `permute`, `select`, `slice`, `update_cache`, `rms_norm`, and `embedding_q4gsw` through the shared `utils::make_compute_pipeline` helper (which uses `layout:"auto"`), replacing each op's hand-written `WGPUBindGroupLayoutEntry[]` + pipeline-layout + bind-group boilerplate (~50-110 lines each) with a single helper call. The driver now derives the bind-group layout from the shader's statically-used bindings. Byte-behavior is preserved: identical binding indices/types/buffers/sizes, dispatch workgroup counts, resize hooks, and validations; override constants (`wg_size`) passed via the helper's `constants` param. Extends the Diff 1 layout:"auto" adoption to the trivial single-dispatch ops.
ghstack-source-id: 405949795
@exported-using-ghexport

Differential Revision: [D110836665](https://our.internmc.facebook.com/intern/diff/D110836665/)
@JCNTH
JCNTH merged commit 52c6277 into gh/JCNTH/98/orig Jul 23, 2026
56 of 57 checks passed
@JCNTH
JCNTH deleted the gh/JCNTH/99/orig branch July 23, 2026 15:57
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