Skip to content

Stop shipping vendored third-party sources in the wheel - #22584

Open
shoumikhin wants to merge 2 commits into
mainfrom
slim-wheel-tests-thirdparty
Open

Stop shipping vendored third-party sources in the wheel#22584
shoumikhin wants to merge 2 commits into
mainfrom
slim-wheel-tests-thirdparty

Conversation

@shoumikhin

@shoumikhin shoumikhin commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

A pip install of ExecuTorch carries 348 files copied out of the vendored third-party checkouts: most of the MLX Python source tree, the XNNPACK codegen scripts and their operator yaml, the Vulkan header registry. Those exist to build the C++ targets. Nothing in an installed wheel imports them.

The cause is one missing setting. setup.py passes a packages list only for the minimal build. The full build has no list, so setuptools discovers packages by itself and picks up everything under src/executorch.

First commit: move the NXP op alias table out of the test package

The NXP backend keeps a table of short names for edge operators in its test package, and three shipped modules read it at import time. Two dozen production files import those modules, so the backend cannot load without a test package.

The table has no test logic in it, so it moves next to the code that reads it, the way backends/arm/constants.py already does. The calibration dataset classes move too. No behavior changes.

Second commit: stop shipping vendored third-party sources

This adds the packages list for the full build, excluding the vendored directories, and filters the data-file manifest with the same list. The manifest is built from the source tree, not from that list, so a *.yaml pattern still matched 60 files inside them. One list feeds both, so they cannot drift apart.

Test packages deliberately stay. The suites here import each other through the installed name, for example from executorch.backends.arm.test import common, about 1800 times. Dropping them stops a non-editable install from collecting most tests. An editable install still works, because it exposes the whole source tree. Pruning the test packages needs that cross-import removed first, so it is not done here. The note in pyproject.toml now says why.

Result: 348 files per wheel. The macOS wheel goes from 18.8 MB to 17.9 MB, and unpacked from 65.9 MB to 59.4 MB.

Test plan

Built wheels for macOS arm64, Linux x86_64, and Linux x86_64 with CUDA. Confirmed no vendored directory remains, the test packages are still there, and the shipped headers, cmake files and schemas are unchanged.

Installed into a clean environment and, from outside the checkout, exported, loaded and ran a model through the portable kernels and the XNNPACK delegate, checking outputs against eager. Added a unit test beside the existing wheel checks, and confirmed it fails when the package list stops excluding the vendored directories.

Copilot AI lite review requested due to automatic review settings September 5, 2026 23:03
@shoumikhin shoumikhin added the release notes: none Do not include this in the release notes label Sep 5, 2026
@pytorch-bot

pytorch-bot Bot commented Sep 5, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

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 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@shoumikhin
shoumikhin force-pushed the slim-wheel-tests-thirdparty branch from 360f24a to 4711a4e Compare September 6, 2026 01:24
Copilot AI review requested due to automatic review settings September 6, 2026 01:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@shoumikhin shoumikhin changed the title Strip tests and vendored third-party sources from the wheel Stop shipping tests and vendored sources in the wheel Sep 6, 2026
@shoumikhin
shoumikhin force-pushed the slim-wheel-tests-thirdparty branch from 4711a4e to ab12a82 Compare September 6, 2026 07:33
Copilot AI review requested due to automatic review settings September 6, 2026 07:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@shoumikhin shoumikhin changed the title Stop shipping tests and vendored sources in the wheel Stop shipping vendored third-party sources in the wheel Sep 6, 2026
The NXP backend keeps a table of short names for edge operators, for example
`AddTensor = exir_ops.edge.aten.add.Tensor`. It lives in the backend's test
package, but three modules that ship in the wheel read it at import time:

  backend/edge_helper.py
  backend/node_format_inference.py
  edge_passes/move_auxiliary_operator_into_separate_qdq_cluster_pass.py

Two dozen production files import those modules, so the backend cannot load at
all without a test package. The dependency points the wrong way: the tests
should depend on the backend, not the backend on the tests.

The table has no test logic in it, so this moves it to
backend/ops_aliases.py, next to the code that reads it. That follows the shape
the Arm backend already uses for shared operator constants in
backends/arm/constants.py.

No behavior changes. The names, values, and every importer stay the same,
including the roughly fifty tests that use the table. The Buck target that
published the table from the test package is removed, since the backend
library already globs the directory it moves into.

Test plan: imported the moved module and every updated importer from an
installed wheel, and confirmed the table exposes the same names from the same
values. Checked that every NXP test target can still reach the table through
the backend package. Ran the formatter and linter over the changed files.
A pip install of ExecuTorch carries files copied out of the vendored
third-party checkouts: most of the MLX Python source tree, the XNNPACK codegen
scripts and their operator yaml, the Vulkan header registry, and two git
submodules checked out under ordinary names. Those exist to build the C++
targets. Once the libraries are built nothing in an installed wheel imports
them, and the nested submodule copies cannot satisfy the imports the code does
use: the Cadence helper imports facto.specdb from the top level, and the
tokenizers are already declared as pytorch-tokenizers.

The cause is one missing setting. setup.py passes a `packages` list only for
the minimal build, so the full build falls back to setuptools auto discovery
and picks up everything under src/executorch.

This adds the list for the full build and closes the two ways those files
arrive:

  - `packages` excludes directories named third-party or third_party, plus the
    submodule paths read from .gitmodules. A submodule under an ordinary name
    cannot be recognized by its name, so it is read from the file that defines
    it rather than hardcoded here.
  - The data-file manifest is filtered with the same rule. A directory left out
    of `packages` is not simply skipped: setuptools walks up to the nearest
    listed package and records the file as that package's data, so a vendored
    yaml still arrives under its parent without this.

One rule feeds both, so they cannot drift apart.

Test packages deliberately stay. The suites here import each other through the
installed name, for example `from executorch.backends.arm.test import common`,
so dropping them stops a non-editable install from collecting most tests.
Pruning them needs that cross-import removed first, and the note in
pyproject.toml now says so.

Test plan: built wheels for macOS arm64, Linux x86_64, and Linux x86_64 with
CUDA. Confirmed no vendored directory or submodule remains, the test packages
are still present, and the shipped headers, cmake files and flatbuffer schemas
are unchanged in number. Installed into a clean environment and, from outside
the checkout, exported, loaded and ran a model through the portable kernels and
the XNNPACK delegate, checking outputs against eager.

Added a unit test beside the existing wheel checks. It fails when the package
list stops excluding the vendored directories, when the submodule rule is
broken, and when the line that hands the list to setuptools is removed, each
checked by deleting that piece and watching the suite go red.
Copilot AI review requested due to automatic review settings September 6, 2026 21:33
@shoumikhin
shoumikhin force-pushed the slim-wheel-tests-thirdparty branch from ab12a82 to a358865 Compare September 6, 2026 21:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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. release notes: none Do not include this in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants