Repository navigation
fix(executorch): accept ExecuTorch's PyPI CUDA wheel in source builds - #4976
shoumikhin wants to merge 3 commits into
Conversation
be72649 to
af143c2
Compare
112c83b to
84784f5
Compare
micwill755
left a comment
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Done. executorch_cmake_prefix_path takes the runtime version, and both callers pass the value computed at module level.
13d8b17 to
9dbc4aa
Compare
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>
9dbc4aa to
e946cb4
Compare
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, not1.6.0+cu132. Thesetup.pyoftorch-tensorrt-executorch-runtimereads 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:Installing a prebuilt runtime wheel is not affected.
Fix. The wheel's
executorch/version.pykeeps the full version:When the metadata has no label,
setup.pynow 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, sosetup.pyrefuses that here, also when the label comes fromegg_info --tag-build. A default source build, labelled with the Git revision, builds and requiresexecutorch==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:
executorch==1.6.0. A CUDA label (set directly or through--tag-build),+cpu,+cu126, no label, a different version, and a+cpumetadata label are refused.0.3.0.dev0and0.3.0.dev0+abc1234and refuses0.3.0.dev0+cu132. Before this change it refused all three.0.2.1failed before this change and succeeded with an earlier revision of it.