Ship the quantized kernels as their own library - #21642
Open
shoumikhin wants to merge 14 commits into
Open
Conversation
Contributor
Author
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/21642
Note: Links to docs will display an error until the docs builds have been completed. ❌ 3 New Failures, 2 Pending, 22 Unrelated Failures, 22 Unclassified FailuresAs of commit 85164ea with merge base 48741ac ( NEW FAILURES - The following jobs have failed:
UNCLASSIFIED FAILURES - DrCI could not classify the following jobs because the workflow did not run on the merge base. The failures may be pre-existing on trunk or introduced by this PR:
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. |
This was referenced Aug 7, 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.
The problem
The wheel now ships the runtime, the CPU kernels, the XNNPACK delegate, the thread pool and the
profiler as separate shared libraries a C++ application can link. The quantized kernels are the
one piece from that set still missing.
They exist today only inside
libquantized_ops_aot_lib.so, which sits beside the Python bindingsand is built for ahead-of-time export. A C++ application that loads a quantized
.ptehas nolibrary to link, so it fails at run time:
The change
Builds the quantized kernels as a shared library, ships it beside the others, and names it as a
component.
Named after what it provides rather than after the target that produces it, matching
libexecutorch_kernels_optimized.sonext to it.Two things this needed that were not obvious. The library is named explicitly in the wheel's
build target list, because a C++ application is its only consumer, and without naming it the
target is generated and never built. And the single-owner checks skip the ahead-of-time
libraries, which deliberately carry their own copy because export runs in a process that never
loads the runtime libraries a C++ application links. They are recognised by linking torch rather
than by name, so a rename does not silently drop the exclusion.
Before and after
Nothing changes for a Python user. The export path keeps using the ahead-of-time library.
Test plan
executorch::kernels_quantizedexports a quantized model, runs it,and matches eager PyTorch
The comparison tolerance is per model rather than one number for all: a correct int8 run differs
from eager PyTorch by about one quantization step, which for this model is 5e-3, while a float32
model matches to within rounding. Using the looser number for both would stop the float path
catching a real regression.
Ran on Linux x86_64 and aarch64 against a wheel built from source and installed into a clean
environment. The quantized model matches eager PyTorch to 4.8e-03, one quantization step.