Skip to content

[ET-VK] Prevent hardswish decomposition by adding to ops_not_to_decompose#18575

Open
SS-JIA wants to merge 1 commit intomainfrom
pr18575
Open

[ET-VK] Prevent hardswish decomposition by adding to ops_not_to_decompose#18575
SS-JIA wants to merge 1 commit intomainfrom
pr18575

Conversation

@SS-JIA
Copy link
Copy Markdown
Contributor

@SS-JIA SS-JIA commented Mar 30, 2026

Summary: Without this change, aten.hardswish.default decomposes into several
arithmetic ops (add, clamp, mul, div) which prevents the Vulkan conv2d
depthwise fusion pass from recognizing and fusing the activation. Adding
hardswish to ops_not_to_decompose keeps it as a single op so the conv2d
output tile shader can apply the clamp fusion.

Also adds the conv2d_dw_output_tile_3x3_b1x1_clamp shader variant needed
for the fused path.

Authored with Claude.

Test Plan: Exported MobileNetV3 for Vulkan and verified hardswish no longer decomposes.

Reviewers:

Subscribers:

Tasks:

Tags:


Stack created with Sapling. Best reviewed with ReviewStack.

…pose

Summary: Without this change, aten.hardswish.default decomposes into several
arithmetic ops (add, clamp, mul, div) which prevents the Vulkan conv2d
depthwise fusion pass from recognizing and fusing the activation. Adding
hardswish to ops_not_to_decompose keeps it as a single op so the conv2d
output tile shader can apply the clamp fusion.

Also adds the conv2d_dw_output_tile_3x3_b1x1_clamp shader variant needed
for the fused path.

Authored with Claude.

Test Plan: Exported MobileNetV3 for Vulkan and verified hardswish no longer decomposes.

Reviewers:

Subscribers:

Tasks:

Tags:
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Mar 30, 2026

🔗 Helpful Links

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

Note: Links to docs will display an error until the docs builds have been completed.

❌ 2 New Failures, 3 Unrelated Failures

As of commit 7adc046 with merge base fa81941 (image):

NEW FAILURES - The following jobs have failed:

BROKEN TRUNK - The following jobs 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.

@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 Mar 30, 2026
@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.

SS-JIA added a commit that referenced this pull request Mar 30, 2026
)

Summary: Previously, copy.default was unconditionally added to the
Vulkan partition as
an ephemeral op (assumed to always be a no-op removed by
RemoveRedundantOpsTransform). However, copy.default can also represent a
dtype
cast, and blindly partitioning casts to Vulkan causes runtime failures
since
the Vulkan backend has no copy implementation.

Replace the unconditional registration with a custom
are_node_inputs_supported_fn that checks both dtype and shape match
between
src and dst. Only same-dtype, same-shape copies (true no-ops) are
partitioned
to Vulkan; dtype casts remain on CPU.

Authored with Claude.

Test Plan: Exported EfficientNet for Vulkan, which contains copy.default
for dtype casts,
and confirmed it no longer errors during Vulkan compilation. No-op
copies in
other models (e.g. MobileNetV3) still partition correctly.

Reviewers:

Subscribers:

Tasks:

Tags:

---

[ET-VK] Prevent hardswish decomposition by adding to ops_not_to_decompose

Summary: Without this change, aten.hardswish.default decomposes into several
arithmetic ops (add, clamp, mul, div) which prevents the Vulkan conv2d
depthwise fusion pass from recognizing and fusing the activation. Adding
hardswish to ops_not_to_decompose keeps it as a single op so the conv2d
output tile shader can apply the clamp fusion.

Also adds the conv2d_dw_output_tile_3x3_b1x1_clamp shader variant needed
for the fused path.

Authored with Claude.

Test Plan: Exported MobileNetV3 for Vulkan and verified hardswish no longer decomposes.

Reviewers:

Subscribers:

Tasks:

Tags:

---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with
[ReviewStack](https://reviewstack.dev/pytorch/executorch/pull/18576).
* __->__ #18576
* #18575

cc @manuelcandales @digantdesai @cbilgin
rascani pushed a commit to rascani/executorch that referenced this pull request Apr 1, 2026
…orch#18576)

Summary: Previously, copy.default was unconditionally added to the
Vulkan partition as
an ephemeral op (assumed to always be a no-op removed by
RemoveRedundantOpsTransform). However, copy.default can also represent a
dtype
cast, and blindly partitioning casts to Vulkan causes runtime failures
since
the Vulkan backend has no copy implementation.

Replace the unconditional registration with a custom
are_node_inputs_supported_fn that checks both dtype and shape match
between
src and dst. Only same-dtype, same-shape copies (true no-ops) are
partitioned
to Vulkan; dtype casts remain on CPU.

Authored with Claude.

Test Plan: Exported EfficientNet for Vulkan, which contains copy.default
for dtype casts,
and confirmed it no longer errors during Vulkan compilation. No-op
copies in
other models (e.g. MobileNetV3) still partition correctly.

Reviewers:

Subscribers:

Tasks:

Tags:

---

[ET-VK] Prevent hardswish decomposition by adding to ops_not_to_decompose

Summary: Without this change, aten.hardswish.default decomposes into several
arithmetic ops (add, clamp, mul, div) which prevents the Vulkan conv2d
depthwise fusion pass from recognizing and fusing the activation. Adding
hardswish to ops_not_to_decompose keeps it as a single op so the conv2d
output tile shader can apply the clamp fusion.

Also adds the conv2d_dw_output_tile_3x3_b1x1_clamp shader variant needed
for the fused path.

Authored with Claude.

Test Plan: Exported MobileNetV3 for Vulkan and verified hardswish no longer decomposes.

Reviewers:

Subscribers:

Tasks:

Tags:

---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with
[ReviewStack](https://reviewstack.dev/pytorch/executorch/pull/18576).
* __->__ pytorch#18576
* pytorch#18575

cc @manuelcandales @digantdesai @cbilgin
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