Skip to content

pi0.5 export to ExecuTorch with TensorRT: how to reproduce from source #25235

Open

Description

@shoumikhin

pi0.5, the open vision-language-action model from Physical Intelligence, compiled with TensorRT through Torch-TensorRT and ExecuTorch (PyTorch's solution for deploying models on devices), runs faster than openpi, Physical Intelligence's reference implementation, on an H100. It uses less GPU memory, its action error stays small (between openpi's own PyTorch and JAX paths), and it runs without loading PyTorch. It needs only the released packages and a LeRobot branch. Below are the numbers, measured the same way for each path, and how to reproduce them.

Results

One H100, batch 1, openpi's pi05_libero weights in bfloat16, 10 denoising steps, 10 actions per chunk:

Path Time per chunk Time saved by ExecuTorch + TensorRT GPU memory Max / mean error vs float32
ExecuTorch + TensorRT 20.5 ms 5.7 GiB 0.0058 / 0.0007
openpi PyTorch, torch.compile 28.1 ms 27% 8.0 GiB 0.0036 / 0.0004
openpi JAX 36.0 ms 43% 8.6 GiB 0.0063 / 0.0008

How it was measured: every path ran on the same GPU, with the same 16 real LIBERO frames, the same prompt, the same starting noise and the same work per chunk (two cameras and a 73-token prompt). For openpi the timer covers the model call, with the inputs already on the GPU. For ExecuTorch it also covers copying the frame to the GPU and the actions back. Every timer waits for the GPU. Each run is a fresh process that times 30 chunks after warm-up, and the runs of the three paths were interleaved. Each time is the median of 3 or more runs. GPU memory is what nvidia-smi reports for the card after the timed chunks, with only that process on it. The error is against openpi's PyTorch model in float32 on the same frames and noise.

Notes:

  • openpi is at commit 215abfb, run with two cameras and max_token_len=73, so that it does the same work as the exported program. As it ships, openpi also fills a third camera with zeros and pads its prompt to 200 tokens, which is more work per chunk.
  • LeRobot's pi0.5 writes the robot state into its prompt and openpi's pi05_libero does not. So the exported program is compared with a float32 reference that has the state in its prompt, and openpi with one that does not.
  • openpi's own infer_ms field does not wait for the GPU, so it reads lower than the real time, most of all for JAX. The timer here waits on every path.
  • A100 and DGX Spark will follow here, measured on the same branch.

Jetson Orin Nano 8 GB (this branch)

LeRobot's public lerobot/pi05_libero_finetuned_v044 checkpoint in bfloat16, 50 actions per chunk, the default chain (--one_program=true does not fit in 8 GB at export). Timed with lerobot-rollout --bundle.path, which does not load PyTorch: 3 warm-up chunks, then 3 runs of 32, median of the run medians.

Path Time per chunk Memory (CPU and GPU together)
ExecuTorch + TensorRT, default chain 423 ms 5.4 GiB
Plain PyTorch does not fit

The export took 12 minutes on the board, with a peak of 5.7 GB of host memory.

Jetson AGX Thor (this branch)

LeRobot's public lerobot/pi05_libero_finetuned_v044 checkpoint in bfloat16, 50 actions per chunk. Timed with lerobot-rollout: the ExecuTorch rows with --bundle.path, which does not load PyTorch, and plain PyTorch with --policy.path. 3 warm-up chunks, then 3 runs of about 32 chunks, median of the run medians. The two ExecuTorch rows alternated, and the PyTorch runs followed in the same session.

Path Time per chunk Time saved by ExecuTorch + TensorRT GPU memory Memory (CPU and GPU together)
ExecuTorch + TensorRT, --one_program=true 80.5 ms 5.2 GiB 5.6 GiB
ExecuTorch + TensorRT, default chain 80.8 ms 5.3 GiB 5.6 GiB
Plain PyTorch 236.0 ms 66% 9.4 GiB 11.3 GiB

GPU memory is what nvidia-smi reports for the process. The last column is how much the board's used memory grew during the run, since Thor's CPU and GPU share one memory. Both bundles pass the export's own check against the PyTorch policy (largest difference 0.017, tolerance 0.075).

A second session on the same board later that night, with the same bundle settings, gave 77.5 ms for --one_program=true, so times on this board move by a few percent from session to session. The table keeps the first session, where all three paths ran together.

The exports took 7.5 minutes (default chain) and 10 minutes (--one_program=true) on the board, with a peak of 10.6 and 12.1 GiB of host memory.

What it needs on top of the releases

Nothing in ExecuTorch or Torch-TensorRT: the released ExecuTorch 1.6.0 and Torch-TensorRT 2.15.0 are enough.

LeRobot. The lerobot-export command and the pi0.5 recipe, on branch pi05-repro of github.com/shoumikhin/lerobot. Two changes there make pi0.5 faster on the H100 and the DGX Spark:

  • The action expert's attention reuses one key/value head across many query heads. The recipe now tells TensorRT so on the H100 and the DGX Spark too, which lets it pick a faster kernel.
  • --one_program=true compiles pi0.5 as the fewest programs: one for the images and the prompt, one for the whole language model, one that runs all ten denoising steps, and small ones for the starting noise and the actions. Without it, the export keeps a chain of small programs that builds on an 8 GB board.

The branch pins these and the changes it builds on as they were when it was built. They will go upstream as pull requests.

How to reproduce

Project Branch Commit
LeRobot pi05-repro 434dfad796

1. Install, with Python 3.12. The export also needs nvcc from CUDA 12.8 or newer on PATH:

pip install "torch_tensorrt[executorch]"
pip install "lerobot[pi,export] @ git+https://github.com/shoumikhin/lerobot@434dfad796dd2563899d5cdb813a590f727026f5"

2. Get the weights and frames. Follow benchmarks/pi05_compare/README.md on the branch: it downloads openpi's pi05_libero checkpoint, converts it to PyTorch with openpi's own converter, picks the 16 LIBERO frames, and makes a LeRobot policy folder pi05_openpi_libero with openpi's weights.

3. Export and run:

lerobot-export --policy.path=pi05_openpi_libero --backend.type=executorch_tensorrt \
  --policy.dtype=bfloat16 --one_program=true --output_dir=bundles/one \
  --task="pick up the book and place it in the back compartment of the caddy"

# on a robot, the bundle runs without PyTorch:
lerobot-rollout --bundle.path=<bundle> --robot.type=<your robot>

The export takes about 8 minutes on an H100 and up to about 13 GiB of host memory.

4. Time it against openpi, from benchmarks/pi05_compare (the README there sets up openpi and the variables):

bash run_ab.sh 0 out 1 ref_state ref                # float32 references
bash run_ab.sh 0 out 3 jax585 pt585 bundle:one      # 3 rounds on GPU 0, the order rotates each round
python compare.py out/ref_state.npz out/one_r1.npz     # ExecuTorch error
python compare.py out/ref.npz out/pt585_r1.npz         # openpi PyTorch error (jax585_r1.npz for JAX)

Questions, and results on other GPUs, are welcome here.

cc @simpleton

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions