add torch-tensorrt-executorch-delegate wheel build#4398
Conversation
|
@lanluo-nvidia the new package should be in //py See: https://packaging.python.org/en/latest/guides/packaging-namespace-packages/ |
shoumikhin
left a comment
There was a problem hiding this comment.
Nice work on this. The core idea is right. You build _portable_lib from source and pull TensorRTBackend into the same module that holds the backend registry, so the two always share one copy of the ExecuTorch core. That is the correct way to fix the undefined symbol crash people hit today. I checked the linking part and it holds up: one registry, no duplicate core, and the whole-archive flag is actually needed.
| ) | ||
|
|
||
| output = pathlib.Path(self.get_ext_fullpath(ext.name)).resolve() | ||
| if output.exists(): |
There was a problem hiding this comment.
Minor: if output.exists(): return skips the build when the .so is already there. On a clean CI run that is fine, but on a local rebuild it can ship an old .so from a previous build without telling you. Consider a build stamp, or just remove the early return.
| export EXECUTORCH_SOURCE_DIR="$(dirname "${executorch_cmake_location%%:*}")" | ||
| export TensorRT_ROOT=/path/to/TensorRT | ||
|
|
||
| python -m pip install executorch==1.3.1 |
There was a problem hiding this comment.
Minor: the README says pip install executorch==1.3.1, but MODULE.bazel now targets main for the 2.14 ABI. Please make the doc match the version you actually build against.
|
One more note, on a file this PR does not change so I cannot leave it inline. In |
| requires = [ | ||
| "setuptools>=68", | ||
| "wheel>=0.40", | ||
| "torch", |
There was a problem hiding this comment.
Do we not depend on executorch for the delegate?
| build_dir = pathlib.Path(self.build_temp) / "executorch_delegate_native" | ||
| output.parent.mkdir(parents=True, exist_ok=True) | ||
| build_dir.mkdir(parents=True, exist_ok=True) | ||
| configure = [ |
There was a problem hiding this comment.
Why arent we using bazel here like the main package?
There was a problem hiding this comment.
I think it would be better to have one real preferred build system
| return runtime() | ||
|
|
||
|
|
||
| class Program: |
There was a problem hiding this comment.
Should probably be in the delegate not this package
There was a problem hiding this comment.
We can lift apis into the main package gated by import but any dependent code should be in the sub package
| return self.run(inputs, "forward") | ||
|
|
||
|
|
||
| def load(path: Union[str, Path]) -> Program: |
There was a problem hiding this comment.
Also in the delegate and not this package. we should just expose via torch_tensorrt.load
| EXECUTORCH_REQUIREMENT = "executorch>=1.3.1" | ||
| EXECUTORCH_DELEGATE_REQUIREMENT = ( | ||
| f"torch-tensorrt-executorch-delegate=={__version__}; " | ||
| "platform_system == 'Linux' and platform_machine == 'x86_64'" |
There was a problem hiding this comment.
We need to support ARM as well (Jetson Thor)
There was a problem hiding this comment.
There are some changes that do not conform to Python style guidelines:
--- /home/runner/work/TensorRT/TensorRT/py/torch-tensorrt-executorch-delegate/setup.py 2026-07-17 19:30:44.124103+00:00
+++ /home/runner/work/TensorRT/TensorRT/py/torch-tensorrt-executorch-delegate/setup.py 2026-07-17 19:31:08.985550+00:00
@@ -14,10 +14,11 @@
from setuptools import Extension, find_packages, setup
from setuptools.command.build_ext import build_ext
HERE = pathlib.Path(__file__).resolve().parent
REPO_ROOT = HERE.parents[1]
+
def torchtrt_version() -> str:
if value := os.getenv("TORCH_TENSORRT_EXECUTORCH_DELEGATE_VERSION"):
return value
version_py = REPO_ROOT / "py/torch_tensorrt/_version.py"
Description
export EXECUTORCH_SOURCE_DIR=/home/lanl/git/executorch
export EXECUTORCH_ROOT=/home/lanl/git/executorch
build the torch-tensorrt-executorch-delegate.whl
python -m pip wheel
--no-build-isolation
--no-deps
--wheel-dir dist
packaging/executorch_delegate
install the wheel
python -m pip install --no-deps --force-reinstall
dist/torch_tensorrt_executorch_delegate-*.whl
export the pte
python /home/lanl/git/py312/TensorRT/examples/torchtrt_executorch_example/export_static_shape.py
load the pte
python examples/executorch_reference_runner/load_model.py
--model_path=/path/to/model.pte
Fixes # (issue)
Type of change
Please delete options that are not relevant and/or add your own.
Checklist: