Skip to content

XNNPACK: fold constant subgraphs before ATen decomposition - #23154

Open
mansnils wants to merge 4 commits into
pytorch:mainfrom
mansnils:ops
Open

mansnils wants to merge 4 commits into
pytorch:mainfrom
mansnils:ops

Conversation

@mansnils

@mansnils mansnils commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

Fold constant subgraphs, including cat/split chains, before ATen decomposition so linear and addmm biases remain eligible for delegation. Skip folding when a mutable operator could write into a folded constant.

Serialize only the bytes belonging to each prepared tensor rather than its backing storage.
Prepared XNNPACK constants may be views, so using storage pointers and sizes ignored storage offsets and included unrelated bytes. Reading from data_ptr() for numel() * element_size() bytes gives split views, parameter views, and quantization scales the correct payload, size, and named-data hash.

For the static Roblox Voice Safety V2 model, median execution latency improves from about 16 s to about 0.5 s: roughly 35x faster.

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

Fold constant subgraphs, including cat/split chains, before ATen
decomposition so linear and addmm biases remain eligible for
delegation. Skip folding when a mutable operator could write into a
folded constant.

Serialize only the bytes belonging to each prepared tensor
rather than its backing storage.
Prepared XNNPACK constants may be views, so using storage
pointers and sizes ignored storage offsets and included unrelated
bytes. Reading from data_ptr() for numel() * element_size() bytes
gives split views, parameter views, and quantization scales the
correct payload, size, and named-data hash.

For the static Roblox Voice Safety V2 model, median execution latency
improves from about 16 s to about 0.5 s: roughly 35x faster.

Signed-off-by: Måns Nilsson <mans.nilsson@arm.com>
Change-Id: I988ec6f77d3d7686ffc8a2ad09e5675948a6d4be
@mansnils mansnils added the module: xnnpack Issues related to xnnpack delegation and the code under backends/xnnpack/ label Sep 25, 2026
@mansnils mansnils added 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 25, 2026
@pytorch-bot

pytorch-bot Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 1 New Failure

As of commit fdcbee1 with merge base 7586c16 (image):

NEW FAILURE - The following job has failed:

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 25, 2026
@JakeStevens

Copy link
Copy Markdown
Contributor

@mansnils does #22391 cover your usecase?

The Python binding borrows the PTE bytes. Retain each buffer until
execution finishes so XNNPACK can read named constants reliably.

Signed-off-by: Måns Nilsson <mans.nilsson@arm.com>
Change-Id: I91b173ac511ff62f5d93b6faf19c42b0956e5e42
@mansnils

Copy link
Copy Markdown
Collaborator Author

@mansnils does #22391 cover your usecase?

It gives the same uplift yes.

This branch has not been deployed

No deployments
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.

2 participants