Repository navigation
[2.15] example: deploy LeRobot's pi0.5 policy with ExecuTorch and TensorRT - #4949
Open
cehongwang wants to merge 2 commits into
Open
cehongwang wants to merge 2 commits into
cehongwang wants to merge 2 commits into
Conversation
…d TensorRT examples/torchtrt_executorch_example/export_lerobot_pi05.py wraps stock lerobot 0.6.1's PI05Policy.predict_action_chunk (lerobot/pi05_base, 3.6B parameters, bf16) as a module with tensor inputs, exports it, compiles it with torch_tensorrt.dynamo.compile into one TensorRT engine, and saves one .pte. It then runs the program with ExecuTorch's runtime, checks it against PyTorch, and times both. On an A40 with the 2.15.0 RC wheels: 195 s to compile, max difference 0.0106, 104.5 ms per chunk of 50 actions against 368.6 ms in PyTorch; peaks 24.3 GB host, 23.5 GB GPU.
use_cuda_graphs=True in save(). Each program loaded alone on an A40: 104.4 -> 101.1 ms per chunk (-3%) for 22 MiB more GPU memory, with bit-identical actions. The example runs end to end in 100.6 ms per chunk.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds an example that deploys a robot policy with Torch-TensorRT and ExecuTorch. It takes LeRobot's pi0.5 (
lerobot/pi05_base), a vision-language-action model with 3.6 billion parameters, and turns it into one.ptethat predicts a chunk of 50 actions from three camera images and a task in words. It's one script,examples/torchtrt_executorch_example/export_lerobot_pi05.py, plus one line in the deployment guide's list of examples.It builds on @shoumikhin's LeRobot export work, reduced to the smallest working setup. It uses the released
lerobot==0.6.1and its stockPI05Policy, and needs no patches and no low-memory techniques.What the script does:
predict_action_chunkin a module with tensor inputs: the stacked camera images, the prompt's tokens and mask, and the starting noise.torch.export, thentorch_tensorrt.dynamo.compile, thentorch_tensorrt.save(..., output_format="executorch", use_cuda_graphs=True). The whole chunk becomes one TensorRT engine, the 10 denoising steps unrolled, with nothing left to PyTorch. Withuse_cuda_graphs=True(feat(executorch): optional CUDA graph replay in the TensorRT delegate #4781), the delegate replays the engine's kernel launches as one CUDA graph..ptewith ExecuTorch's runtime, afterimport torch_tensorrt_executorch_runtime. It checks the actions against PyTorch, exiting with an error above 0.1, runs LeRobot's postprocessor, and times both.Measured
One A40, in a fresh virtual environment with the 2.15.0 release candidate:
CUDA graph replay, measured with each program loaded alone in a fresh process:
use_cuda_graphs=TrueThe two programs' actions are bit-identical. In five alternating rounds of 30 calls each, replay was faster every time: 100.8 to 101.5 ms, against 104.2 to 104.9 ms.
Without replay, three runs of the script gave 104.3 to 104.5 ms per chunk, against 360 to 369 ms in PyTorch, with the same 0.0106 difference each time.
Testing
torch 2.15.0+cu132,torch_tensorrt 2.15.0+cu132andtorch_tensorrt_executorch_runtime 0.2.0+cu132, all fromwhl/test/cu132;executorch 1.6.0.dev20261009+cu132(nightly) andtensorrt-cu13 11.4.0.106;lerobot 0.6.1(--no-deps) withtransformers 5.5.4.pip install --dry-runandwhl/test/cu132in place ofwhl/cu132. It picks torch 2.15.0, Torch-TensorRT 2.15.0, the delegate 0.2.0 and ExecuTorch1.6.0.dev20261009, and no other pre-releases. I chose this form over--pre "torch_tensorrt[executorch]", which also pulls in pre-releases such as tokenizers 1.0.0rc3 and protobuf 7.37.0rc1.--no-depswould otherwise drop.test_every_printed_install_instruction_names_the_nightly_channelandtest_write_pins_requires_a_separate_lock_refreshpass, and so does pre-commit.Still to check at release:
0.30.0.dev20261007,--no-deps). Once 2.15.0 and torchvision 0.30.0 are onwhl/cu132, the docstring's commands should be run as written in a fresh venv.torch_tensorrt_executorch_runtime==0.2.0, should match what 2.15.0 ships. If [2.15] Bump the ExecuTorch delegate to 0.2.1 #4909, which moves the delegate to 0.2.1, lands first, this line needs the same bump. The 2.15.0executorchextra doesn't install the delegate, since [2.15] Backport #4882: install the matching runtime companion with the executorch extra #4913 was closed, which is why the command names it.Type of change
Checklist: