Skip to content

Build PyTorch wheel via PEP 517 instead of setup.py - #21562

Merged
shoumikhin merged 5 commits into
mainfrom
fix-install-pytorch-pep517-build
Aug 7, 2026
Merged

Build PyTorch wheel via PEP 517 instead of setup.py#21562
shoumikhin merged 5 commits into
mainfrom
fix-install-pytorch-pep517-build

Conversation

@shoumikhin

Copy link
Copy Markdown
Contributor

Problem

Recent PyTorch nightlies removed python setup.py bdist_wheel. PyTorch now builds through scikit-build-core using the standard PEP 517 interface (pyproject.toml). The CI Docker image still builds PyTorch with setup.py, so bumping the pin to a newer nightly fails the image build with:

error: `python setup.py bdist_wheel` is deprecated: PyTorch is built with
scikit-build-core via the standard PEP 517 interface (pyproject.toml)...

Fix

Build the wheel with python -m build --wheel --no-isolation:

  • python -m build is the standard PEP 517 frontend and works with PyTorch's scikit-build-core backend.
  • --no-isolation makes PyTorch build against the image's numpy and toolchain (avoids a build-vs-runtime ABI mismatch) and lets the build reuse sccache.
  • With isolation off the frontend does not install the build requirements, so they are installed explicitly, kept in sync with PyTorch's [build-system].requires.

The produced wheel still lands in dist/, so the install step is unchanged.

Testing

The Docker image build in this PR exercises the new build path end to end.

Recent PyTorch nightlies removed support for "python setup.py bdist_wheel" and build through scikit-build-core (PEP 517) via pyproject.toml. The CI Docker image still built PyTorch with setup.py, so pinning to a newer nightly failed the image build.

Build the wheel with the standard frontend (python -m build) with build isolation disabled, so PyTorch builds against the image's numpy and toolchain and reuses sccache. Install the PEP 517 build requirements explicitly since the frontend does not fetch them when isolation is off.
Copilot AI lite review requested due to automatic review settings August 4, 2026 01:05
@pytorch-bot

pytorch-bot Bot commented Aug 4, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 3 New Failures, 5 Cancelled Jobs

As of commit 9f5a15c with merge base 4b4df96 (image):

NEW FAILURES - The following jobs have failed:

CANCELLED JOBS - The following jobs were cancelled. Please retry:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

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.

@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 Aug 4, 2026
With build isolation off, scikit-build-core validates PyTorch's build
requirements against the current environment and fails if setuptools,
cmake or ninja are missing or too old. Install them alongside the other
build requirements.
Copilot AI review requested due to automatic review settings August 6, 2026 02:20

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.

The unbounded cmake>=3.27 build requirement pulled cmake 4.4.2 into the conda env, which shadows the image cmake 3.31 and broke the Arm VGF runner build.
Copilot AI review requested due to automatic review settings August 6, 2026 16:38

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 review requested due to automatic review settings August 6, 2026 16:39

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 added the release notes: none Do not include this in the release notes label Aug 6, 2026
@shoumikhin

Copy link
Copy Markdown
Contributor Author

@JacobSzwejbka ping for a stamp when you get a chance.

fresh ci run finished, the first one was wiped out by the actions outage on aug 6. on head 9f5a15c: 194 green including all 5 required checks, 5 cancellations, 3 failures.

the 5 cancellations all died at "calculate docker image" while waiting on the image rebuild this pr triggers. no signal in them.

the 3 failures are test-lora-linux, test-lora-multimethod-linux and unittest-nxp-neutron. same cause for all three: each compares against a fixed expected output, and this pr changes how the torch wheel is built, so results differ in the last digits.

  • the two lora jobs assert the generated text starts with an exact string. the model still answers correctly, it just words it differently.
  • unittest-nxp-neutron runs np.allclose on int8 tensors at a very tight tolerance, so a one quantization step difference fails it.

all three pass on main. i read this as expected for a build change rather than a regression, but it is the one judgment call in this pr, so worth your eyes.

@shoumikhin
shoumikhin merged commit 7811c69 into main Aug 7, 2026
208 of 216 checks passed
@shoumikhin
shoumikhin deleted the fix-install-pytorch-pep517-build branch August 7, 2026 22:54
shoumikhin added a commit that referenced this pull request Aug 8, 2026
…ay venv

Re-land of #21562 with the leak fixed. The PEP 517 build requirements now go into a temporary virtualenv instead of the image conda environment, so scikit-build-core stops hijacking every later setuptools build in the image.
@shoumikhin

Copy link
Copy Markdown
Contributor Author

Heads up: this broke test-riscv on main, 17 of 17 jobs, on every commit since it landed.

[299/312] Generating CXX dyndep file CMakeFiles/pytorch_tokenizers_cpp.dir/CXX.dd
cc1plus: error: to generate dependencies you must specify either '-M' or '-MM'

Not the cmake shadowing this PR guards against. Installing scikit-build-core into the image is the problem: it registers a setuptools build_ext plugin, so every later pip install --no-build-isolation in that image runs its CMake configure and switches on C++20 module dependency scanning that the image's GCC cannot satisfy.

Revert: #21684. Re-land with the build requirements confined to a throwaway venv: #21685.

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