Skip to content

fix(executorch): accept ExecuTorch's PyPI CUDA wheel in source builds - #4976

Open
shoumikhin wants to merge 3 commits into
pytorch:mainfrom
shoumikhin:rt-pypi-label
Open

shoumikhin wants to merge 3 commits into
pytorch:mainfrom
shoumikhin:rt-pypi-label

Conversation

@shoumikhin

@shoumikhin shoumikhin commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Problem. ExecuTorch publishes its Linux CUDA build to PyPI. PyPI does not allow local version labels, so that wheel's metadata says 1.6.0, not 1.6.0+cu132. The setup.py of torch-tensorrt-executorch-runtime reads that label to check that it builds against a CUDA 13 build. So with a release pin, a source build against PyPI's ExecuTorch stops:

ExecuTorch delegate build failed: The installed ExecuTorch is 1.6.0 but dev_dep_versions.yml pins 1.6.0 and the delegate needs a CUDA build. ...

Installing a prebuilt runtime wheel is not affected.

Fix. The wheel's executorch/version.py keeps the full version:

$ python -c "import executorch.version as v; print(v.__version__)"
1.6.0+cu132

When the metadata has no label, setup.py now reads the label from that file, if the version before the + matches. A CPU or CUDA 12 build is still refused.

A runtime version with a CUDA label, such as 0.3.0+cu132, is for the PyTorch indexes, where its requirement names the labelled ExecuTorch build it links. PyPI's ExecuTorch has no label to name, so setup.py refuses that here, also when the label comes from egg_info --tag-build. A default source build, labelled with the Git revision, builds and requires executorch==1.6.0.

The wheel checker in CI now applies the same rules. Before, it never checked the ExecuTorch build.

PyPI's Windows ExecuTorch is the CPU build, so a Windows source build still needs the CUDA wheel from the PyTorch index. The README says so.

A separate commit removes the pin updater's warning that a stable pin cannot build. ExecuTorch 1.6.0 is on the PyTorch test channel as a CUDA build for every platform the delegate builds.

On main, which pins a nightly build that PyPI does not carry, the version check still refuses PyPI's ExecuTorch.

Tested:

  • Packaging tests: an unlabelled version and a Git revision label both build and require executorch==1.6.0. A CUDA label (set directly or through --tag-build), +cpu, +cu126, no label, a different version, and a +cpu metadata label are refused.
  • Wheel checker tests: a PyPI wheel built against PyPI's CUDA wheel passes. CPU, CUDA 12, unlabelled and mismatched builds are refused, and so is a labelled wheel built against an unlabelled ExecuTorch.
  • Each new check has a case that fails without it.
  • With the real ExecuTorch 1.6.0 wheel from PyPI and the pin at 1.6.0, the version check accepts 0.3.0.dev0 and 0.3.0.dev0+abc1234 and refuses 0.3.0.dev0+cu132. Before this change it refused all three.
  • On an aarch64 Jetson with CUDA 13.2, with the pin at 1.6.0 and ExecuTorch from PyPI, a full source build of version 0.2.1 failed before this change and succeeded with an earlier revision of it.

@meta-cla meta-cla Bot added the cla signed label Nov 5, 2026
@github-actions github-actions Bot added component: tests Issues re: Tests component: api [Python] Issues re: Python API labels Nov 5, 2026
@github-actions
github-actions Bot requested a review from zewenli98 November 5, 2026 02:39
@shoumikhin
shoumikhin force-pushed the rt-pypi-label branch 2 times, most recently from be72649 to af143c2 Compare November 5, 2026 05:38
@shoumikhin
shoumikhin force-pushed the rt-pypi-label branch 2 times, most recently from 112c83b to 84784f5 Compare November 18, 2026 19:23
@micwill755
micwill755 self-requested a review November 19, 2026 22:37

@micwill755 micwill755 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good. 96 passed new tests pass locally. and the new cases fail on the pre-PR code as expected.

The wheel checker should apply the same version.py fallback as setup.py, since it currently accepts an unlabelled wheel built against a CPU only ExecuTorch.

# A labelled wheel is for the PyTorch indexes, where the ExecuTorch it requires
# carries its label too. Built against PyPI's unlabelled ExecuTorch, its
# requirement cannot name the build it linked.
if version.local and not installed.local:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This covers labelled wheels, but an unlabelled wheel built against an unlabelled ExecuTorch is still accepted without checking it's a CUDA build. setup.py now resolves that from executorch/version.py. Can the checker do the same, and reject when neither the metadata nor version.py has a cu{major} label? A helper shared with setup.py would keep the two in sync.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch, thanks. The checker now finds the ExecuTorch build the same way setup.py does: the label in the metadata, or the one in executorch/version.py when the metadata has none. It rejects anything that is not a CUDA build of the pinned major. The checker never looked at the build before, so this also covers a labelled +cpu or +cu126 ExecuTorch, which it used to accept.

I kept it as separate code rather than a helper shared with setup.py. The checker is meant to re-derive everything on its own, so that a bug in setup.py can't make both agree on a wrong answer. The comments above the TensorRT and CUDA checks say the same thing. It is a small regex, and the tests pin both sides.

("requires_a_mismatched_executorch_pin", False),
# Only a PyPI wheel may be built against PyPI's unlabelled ExecuTorch.
("labelled_wheel_built_against_unlabelled_executorch", False),
("pypi_release_built_against_unlabelled_executorch", True),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could you add the counterpart: the same case with a version.py recording +cpu, expected to fail? This one currently passes with no version.py at all.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added. The PyPI case now gets a version.py recording +cu132, and a new case with +cpu is expected to fail through the new check. I also added a version.py that records a different version, and labelled +cpu and +cu126 builds. Each one fails without its check.

# A labelled runtime wheel requires the labelled ExecuTorch build it links, and a metadata
# version with no label leaves nothing to require, so only an unlabelled runtime builds here.
runtime = get_runtime_version()
if built and "+" in runtime and enforced:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

built stands in for "the metadata has no label" here. It's also empty when version.py is missing, which only works because the earlier wrong_build check already raised. not distribution.version.partition("+")[2] would say what's meant and wouldn't depend on that ordering.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed. It now keeps unlabelled = not label from the metadata and checks that, so it no longer depends on the order of the checks.

)
# A labelled runtime wheel requires the labelled ExecuTorch build it links, and a metadata
# version with no label leaves nothing to require, so only an unlabelled runtime builds here.
runtime = get_runtime_version()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this calls get_runtime_version() again after module level already computed runtime_version, which means another git rev-parse when the env var is unset. Could you pass the value in instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done. executorch_cmake_prefix_path takes the runtime version, and both callers pass the value computed at module level.

@shoumikhin
shoumikhin force-pushed the rt-pypi-label branch 3 times, most recently from 13d8b17 to 9dbc4aa Compare November 21, 2026 08:43
PyPI refuses local version labels, so the ExecuTorch CUDA wheel
published there reports a bare version, for example 1.6.0, in its
metadata. The setup.py of torch-tensorrt-executorch-runtime reads the
label from that metadata to check that it builds against a CUDA 13
build. So when the pin names an ExecuTorch release, a source build with
PyPI's ExecuTorch stops with "the delegate needs a CUDA build", even
though it is a CUDA 13.2 build, like the test channel's 1.6.0+cu132.

The wheel's executorch/version.py still records the full version it was
built as. When the metadata has no label, setup.py now reads the label
from there, if the version before the + matches the metadata. A
CPU-only build, or a wheel with no label in either place, is still
refused, and in that case the refusal shows what version.py records.

A runtime version with a CUDA label, such as 0.2.1+cu132, is for the
PyTorch indexes. Its requirement has to name the labelled ExecuTorch
build it links, and the metadata has no label to name. So setup.py
refuses it here and says how to build without one. The check reads the
final version of the wheel, so here a label added with egg_info
--tag-build is refused too. Other labels, such as the Git revision of a default
source build, mark a local build. That build requires the bare version,
the same as an unlabelled one, so it goes through.

The README and the comment in the Linux build workflow now describe
these rules. The README also says that PyPI's Windows ExecuTorch is the
CPU build, so a Windows build needs the CUDA wheel from the PyTorch
index.

Signed-off-by: Anthony Shoumikhin <anthony@shoumikh.in>
The wheel checker re-derives every requirement of the built runtime
wheel on its own, so it now applies the same rules as setup.py.

It finds the ExecuTorch build the same way: from the label in the
installed metadata, or from executorch/version.py when the metadata has
none, as with PyPI's CUDA wheel. A wheel built against anything but a
CUDA 13 build is refused. Before, the checker did not look at the
build at all, so a wheel built against a CPU-only or CUDA 12 ExecuTorch
was accepted.

A labelled runtime wheel, such as 0.2.1+cu132, built against an
ExecuTorch whose metadata has no label is refused too, because its
requirement could not name the build it links. CI labels a runtime
wheel only with its CUDA build, so this is the rule setup.py applies.
A wheel for PyPI built against PyPI's CUDA wheel is still accepted.

Signed-off-by: Anthony Shoumikhin <anthony@shoumikh.in>
The pin updater warns that a stable pin cannot build, because no stable
channel publishes a CUDA build of ExecuTorch. That is no longer true.
ExecuTorch 1.6.0 is on the PyTorch test channel as a labelled CUDA
build, for cu132 and cu134, on Linux x86_64, Linux aarch64 and Windows,
and the CI build installs a release pin from that channel. The comment
on the warning said to remove it once such a build exists.

The stable track still takes the newest release from PyPI. Unlike the
nightly track, it does not check that the test channel carries that
release for every platform. A release missing there still fails in the
build, which says why.

Signed-off-by: Anthony Shoumikhin <anthony@shoumikh.in>

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

cla signed component: api [Python] Issues re: Python API component: tests Issues re: Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants