Skip to content

Stop shipping files nothing can reach in the wheel - #22584

Open
shoumikhin wants to merge 1 commit into
mainfrom
slim-wheel-tests-thirdparty
Open

Stop shipping files nothing can reach in the wheel#22584
shoumikhin wants to merge 1 commit 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 about 1150 test modules, 188 shader templates, and
the Python sources of vendored third-party checkouts. Nothing in an installed wheel
can reach any of it.

Test cases are the largest group. pytest loads them from a path in the checkout, never
through the installed name. Shared helpers are the opposite: the suites import each other
by installed name, and one helper has 267 importers. A file name cannot tell them apart,
since test_pipeline.py and test_add.py look alike and only one can go.

What ships now

Vendored trees are found by asking git for its submodules, so a hand-edited list
cannot go stale.

A test module ships only if something can still reach it: an import from anywhere in
the tree followed through, a relative import, a literal name passed to
importlib.import_module, or a name a workflow runs as python -m. Workflow names are
listed explicitly, since a source distribution has no .github directory, and a test
re-derives the list so it cannot drift.

A yaml file ships unless it carries a shader template key, matched on content rather
than a path list. Editable installs are untouched.

A rebuild also deletes what an earlier build staged and this one does not want, limited
to Python and yaml. Without that, building twice into the same directory keeps the old
files and the wheel packages them, with no sign anything went wrong.

The removed files are Python and yaml, apart from one marker file, so the same 1651 files
leave every platform. Rebuilding each released wheel without them:

Linux CPU 19.2 -> 16.0 MB 3.2 MB smaller, 16.9%
Linux CUDA 27.1 -> 24.0 MB 3.1 MB smaller, 11.4%
macOS 18.8 -> 15.7 MB 3.1 MB smaller, 16.4%
Windows 14.1 -> 11.0 MB 3.1 MB smaller, 22.0%

Test plan

Built the macOS wheel and compared against one from the same base without the change.
Everything removed was vendored, a test module, or a shader template, nothing was
added, and the shipped headers, cmake files, schemas and libraries are unchanged in
number. The other three rows come from applying that removal list to the released
wheels, not from a build on each platform.

Installed it and ran the suites CI runs, collected from the checkout: 1, 75 and 350
tests, identical to a wheel with everything in it. Ran a model through the portable
kernels and the XNNPACK delegate against eager, and partitioned one through Vulkan
with no shader yaml present.

Added unit tests beside the existing wheel checks, each confirmed to go red when the
behaviour it covers is switched off.

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.

⏳ No Failures, 12 Pending

As of commit 3cb2a1d with merge base 7dc8641 (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 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
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.

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 aafbf6c to c88163f Compare September 8, 2026 06:05
Copilot AI review requested due to automatic review settings September 8, 2026 06:05

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.

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 3d829dc to 0760db6 Compare September 8, 2026 06:30
Copilot AI review requested due to automatic review settings September 8, 2026 06:30

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 0760db6 to 0ddda19 Compare September 8, 2026 16:14
Copilot AI review requested due to automatic review settings September 8, 2026 16:14

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.

Comment thread setup.py
Comment on lines +1947 to +1952
keep = _reachable_test_modules()
return [
entry
for entry in modules
if entry[1] == "__init__" or f"{package}.{entry[1]}" in keep
]

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.

Should we also prune the files that we don't keep from the pip-out build?

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.

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.

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.

A pip install of ExecuTorch carries about 1150 test modules, 188 shader templates, and
the Python sources of vendored third-party checkouts. Nothing in an installed wheel
can reach any of it.

Test cases are the largest group. pytest loads them from a path in the checkout, never
through the installed name. Shared helpers are the opposite: the suites import each other
by installed name, and one helper has 267 importers. A file name cannot tell them apart,
since test_pipeline.py and test_add.py look alike and only one can go.

### What ships now

Vendored trees are found by asking git for its submodules, so a hand-edited list
cannot go stale.

A test module ships only if something can still reach it: an import from anywhere in
the tree followed through, a relative import, a literal name passed to
importlib.import_module, or a name a workflow runs as `python -m`. Workflow names are
listed explicitly, since a source distribution has no .github directory, and a test
re-derives the list so it cannot drift.

A yaml file ships unless it carries a shader template key, matched on content rather
than a path list. Editable installs are untouched.

A rebuild also deletes what an earlier build staged and this one does not want, limited
to Python and yaml. Without that, building twice into the same directory keeps the old
files and the wheel packages them, with no sign anything went wrong.

The removed files are Python and yaml, apart from one marker file, so the same 1651 files
leave every platform. Rebuilding each released wheel without them:

  Linux CPU    19.2 -> 16.0 MB    3.2 MB smaller, 16.9%
  Linux CUDA   27.1 -> 24.0 MB    3.1 MB smaller, 11.4%
  macOS        18.8 -> 15.7 MB    3.1 MB smaller, 16.4%
  Windows      14.1 -> 11.0 MB    3.1 MB smaller, 22.0%

### Test plan

Built the macOS wheel and compared against one from the same base without the change.
Everything removed was vendored, a test module, or a shader template, nothing was
added, and the shipped headers, cmake files, schemas and libraries are unchanged in
number. The other three rows come from applying that removal list to the released
wheels, not from a build on each platform.

Installed it and ran the suites CI runs, collected from the checkout: 1, 75 and 350
tests, identical to a wheel with everything in it. Ran a model through the portable
kernels and the XNNPACK delegate against eager, and partitioned one through Vulkan
with no shader yaml present.

Added unit tests beside the existing wheel checks, each confirmed to go red when the
behaviour it covers is switched off.

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

Copy link
Copy Markdown
Contributor Author

Good catch, and yes. I had only stopped the copy, so a second build into a directory an earlier build had used kept everything the first one put there, and the wheel packaged it with nothing to warn about.

The build now removes the Python and yaml files it no longer wants from the build directory. Two guards on it, both of which I got wrong first and found by testing:

It only removes a file that also exists in the source tree. Otherwise it deleted the generated init file behind the flatc console script, because build_py runs before build_ext and that file is not in build_py's own list.

It refuses to run at all when the package list is empty, which is what a build started from outside the repository root used to produce.

Measured on a directory staged by a build of the base branch: it now reduces to exactly what a clean build produces, and the generated file survives.

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.

4 participants