Skip to content

XNNPACK: Preserve FP16 SiLU through XNNPACK partitioning - #22604

Merged
mansnils merged 1 commit into
pytorch:mainfrom
mansnils:xnnpack_2
Sep 9, 2026
Merged

XNNPACK: Preserve FP16 SiLU through XNNPACK partitioning#22604
mansnils merged 1 commit into
pytorch:mainfrom
mansnils:xnnpack_2

Conversation

@mansnils

@mansnils mansnils commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

PyTorch's default decomposition can lower FP16 aten.silu to a float32 sigmoid and multiply surrounded by dtype copies. For SiLU-heavy models, this fragments XNNPACK delegation and adds portable conversion overhead.

Add an XNNPACK partitioner configuration that preserves aten.silu only for FP16 inputs and outputs in to_edge_transform_and_lower(). During delegate preprocessing, rewrite the preserved Edge SiLU as x * sigmoid(x), keeping computation in FP16. FP32 SiLU continues through the default decomposition.

Add an XNNPACK transform pass that recognizes this decomposition and rewrites it as x * sigmoid(x) in FP16 before partitioning. Restrict the rewrite to the exact FP16-to-FP32 pattern and support both Edge copy forms.

In an Yolo26 BundleIO benchmark, mean latency fell from about 15.6 ms to about 8.8 ms. This is approximately 7 ms faster, a 45% reduction and a 1.8x speedup.

Delegated subgraphs fell from 143 to 19 and non-delegated nodes from 425 to 86, while delegated nodes remained at 363. All runs passed BundleIO.

cc @GregoryComer @digantdesai @cbilgin @JakeStevens @freddan80 @per @zingo @oscarandersson8218 @Sebastian-Larsson @robell @rascani

PyTorch's default decomposition can lower FP16 aten.silu to a float32
sigmoid and multiply surrounded by dtype copies. For SiLU-heavy models,
this fragments XNNPACK delegation and adds portable conversion overhead.

Add an XNNPACK partitioner configuration that preserves aten.silu only
for FP16 inputs and outputs in to_edge_transform_and_lower().
During delegate preprocessing, rewrite the preserved Edge SiLU as x *
sigmoid(x), keeping computation in FP16. FP32 SiLU continues
through the default decomposition.

Add an XNNPACK transform pass that recognizes this decomposition and
rewrites it as x * sigmoid(x) in FP16 before partitioning. Restrict the
rewrite to the exact FP16-to-FP32 pattern and support both Edge copy
forms.

In an Yolo26 BundleIO benchmark, mean latency fell from
about 15.6 ms to about 8.8 ms. This is approximately 7 ms faster, a
45% reduction and a 1.8x speedup.

Delegated subgraphs fell from 143 to 19 and non-delegated nodes from
425 to 86, while delegated nodes remained at 363. All runs passed
BundleIO.

Signed-off-by: Måns Nilsson <mans.nilsson@arm.com>
Change-Id: I4594acd4ed57e9a2b882a98c88a906eb989bb821
@mansnils mansnils added module: xnnpack Issues related to xnnpack delegation and the code under backends/xnnpack/ partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm ciflow/trunk release notes: xnnpack Changes to the XNNPack backend delegate labels Sep 8, 2026
@pytorch-bot

pytorch-bot Bot commented Sep 8, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ No Failures

As of commit 29ad31a with merge base c9eee94 (image):
💚 Looks good so far! There are no failures yet. 💚

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 Sep 8, 2026
@mansnils
mansnils requested a review from JakeStevens September 8, 2026 15:04
@mansnils
mansnils merged commit fd985d5 into pytorch:main Sep 9, 2026
567 of 572 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. module: xnnpack Issues related to xnnpack delegation and the code under backends/xnnpack/ partner: arm For backend delegation, kernels, demo, etc. from the 3rd-party partner, Arm release notes: xnnpack Changes to the XNNPack backend delegate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants