Featured projects With Torch-TensorRT 2.15 and ExecuTorch 1.6 you can compile a PyTorch model with TensorRT, save it as an ExecuTorch program, and run it from C++ or Python without loading torch. You stay in PyTorch the whole way, and whatever TensorRT can’t handle can still run on the GPU. On an NVIDIA Jetson Orin Nano it comes within 4% of the fastest TensorRT setup we measured, in both speed and memory. A 3.6-billion-parameter policy fits on the 8 GB board, where PyTorch eager mode runs out of memory. You compile with one pip install "torch_tensorrt[executorch]". To run, the robot needs only ExecuTorch and a small TensorRT backend, not PyTorch. We talked about this work at PyTorch Conference 2026: Deploying Robot Policies Across Many Targets with ExecuTorch. GR00T 1.7 (3B) on a Jetson Orin Nano 8GB: about 200 ms per action chunk. Why is it hard to run a PyTorch model with TensorRT on a robot? A robot runs its models on its own computer, like NVIDIA Jetson AGX Thor or a custom board, and they have to finish on time. A policy, the model that decides what the robot does next, returns a short plan at a time, called an action chunk, say 50 actions. If the next chunk isn’t ready when the robot finishes the current one, the robot stops and waits. And everything shares the same memory: the CPU, the GPU, the cameras and every model. Offloading to a server adds a network round trip, which can easily take 100 ms, over a link the robot can’t always count on. On NVIDIA hardware the fastest way to run a model is TensorRT, NVIDIA’s inference compiler. Until now, getting a PyTorch model into TensorRT meant one of four things: Go through ONNX. We call this ONNX-TensorRT in the tables. Export the model to an ONNX file and build a TensorRT engine from it. It’s fast and well proven, but your model has to get through two converters you don’t own: PyTorch’s ONNX exporter and TensorRT’s ONNX parser. If either one doesn’t know an op, the build fails, and the usual way out is writing a TensorRT plugin in C++. Write it by hand. Rebuild the model layer by layer with TensorRT’s network definition API. tensorrtx does this for many popular models, and early TensorRT-LLM did it for language models. You get full control, but every new model is new work, and checking the result against PyTorch is on you. Use TensorRT Model Connect. NVIDIA’s TensorRT Model Connect, in public preview, builds TensorRT engines straight from supported Hugging Face checkpoints, with no ONNX step, and runs them from C++ without PyTorch. It covers the models on its supported list. Use Torch-TensorRT inside PyTorch. Torch-TensorRT converts PyTorch ops to TensorRT directly, no ONNX file involved. But what it normally produces, an ExportedProgram or an AOTInductor .pt2 package, needs libtorch to run. That’s more than 1 GB of libraries, and a process that loads it holds hundreds of MB that inference never uses. The ONNX route and the ExecuTorch route. Today we’re adding a new way: Torch-TensorRT 2.15 compiles the model with TensorRT and saves it as an ExecuTorch 1.6 program that runs without libtorch. It skips ONNX and captures the model with PyTorch’s own torch.export. If TensorRT can’t convert part of the model, preprocessing included, you can send that part to ExecuTorch’s CUDA backend, which runs it on the GPU in the same program on the same CUDA stream instead of failing the build. The TensorRT parts are ordinary TensorRT engines, so the model runs about as fast as it does when you call TensorRT directly. How it works ExecuTorch is PyTorch’s solution for running models on edge devices. You compile a model ahead of time into a program, and a small runtime runs it without libtorch, from C++ or Python. Hardware support comes from backends: besides TensorRT there are CUDA, Intel OpenVINO, Qualcomm QNN, Apple Core ML and MLX, Arm, Vulkan, and XNNPACK for CPUs. Torch-TensorRT could already save ExecuTorch programs with output_format="executorch". What’s new in Torch-TensorRT 2.15 and ExecuTorch 1.6 is that the workflow is production ready: one install, prebuilt C++ libraries, a Python runtime that doesn’t need PyTorch, and a few features for small boards. We call it ExecuTorch-TensorRT. Take a toy model that needs two backends: class Toy(torch.nn.Module): def forward(self, x): return torch.cos(torch.erfinv(torch.tanh(x))) The toy model, split across two backends. Capture and split. torch.export turns the model into a graph of PyTorch ops. TensorRT claims every part it can convert. It has no converter for erfinv, so the ExecuTorch CUDA backend takes that part instead. The compiler tells you which ops didn’t go to TensorRT, and why. Compile and pack. TensorRT builds an engine for each part it claimed, and the CUDA backend compiles its part with AOTInductor. The engines go into a .pte file, and the CUDA backend’s weights go into a .ptd data file next to it. Load and run. On the robot, the ExecuTorch runtime hands each part to its backend. Inputs, outputs and the tensors passed between the two backends can stay on the GPU, with no round trip through the CPU. If you set use_cuda_graphs=True, each engine’s GPU work is recorded once as a CUDA graph and replayed with a single launch, which makes every call cheaper. If your model has a custom op that neither TensorRT nor the CUDA backend can compile, you still don’t need a TensorRT plugin in C++. Write the op as a Triton kernel and register it with torch.library.triton_op. The CUDA backend compiles it into the program like any other part of the model, and the robot runs it without Triton or PyTorch installed. ExecuTorch’s own CUDA kernels for attention, mixture-of-experts layers and 4-bit matmuls are written this way. Getting started pip install "torch_tensorrt[executorch]" That gets you PyTorch, Torch-TensorRT, ExecuTorch and a small TensorRT backend for ExecuTorch. You need PyTorch only to compile. The compiled program runs without it; see Run, in Python, without torch for the smaller install for the robot. The wheels are built for CUDA 13.2 on Linux, x86-64 and Arm64, which on an NVIDIA Jetson means JetPack 7.2 or newer. On Arm64 the first install also pulls about 2.6 GB of TensorRT libraries from NVIDIA, so give it a few minutes. It can’t reuse the TensorRT that ships with NVIDIA JetPack, because Torch-TensorRT 2.15 needs TensorRT 11.4 and JetPack 7.2 comes with TensorRT 10. Export, in Python import torch import torch_tensorrt from executorch.backends.cuda.cuda_backend import CudaBackend from executorch.backends.cuda.cuda_partitioner import CudaPartitioner with torch.no_grad(): model = MyPolicy().eval().cuda() example = (torch.randn(1, 3, 224, 224, device="cuda"),) exported = torch.export.export(model, example) trt_model = torch_tensorrt.dynamo.compile( exported, arg_inputs=example, min_block_size=1, truncate_double=True ) torch_tensorrt.save( trt_model, "policy.pte", output_format="executorch", # Everything TensorRT does not take goes to the CUDA backend. partitioners=[CudaPartitioner([CudaBackend.generate_method_name_compile_spec("forward")])], ) The CUDA backend needs a CUDA toolkit (nvcc) at export time, and it writes aoti_cuda_blob.ptd next to the .pte. Give each export its own folder and ship both files. If your model has several parts, say a vision encoder and an action head, you can put them all in one program, one method per part, with torch_tensorrt.executorch.export(). It gives you back a program you can still edit before saving. Run, in Python, without torch In ExecuTorch 1.6 the Python runtime no longer needs the torch library. NumPy arrays in, NumPy arrays out: import numpy as np import torch_tensorrt_executorch_runtime # registers the TensorRT backend from executorch.runtime import Runtime program = Runtime.get().load_program("policy.pte", data_path="aoti_cuda_blob.ptd") policy = program.load_method("forward") actions = np.asarray(policy.execute([np.zeros((1, 3, 224, 224), np.float32)])[0]) This matters on a small board. On the Orin Nano, just importing PyTorch takes about 2.2 s and 550 MB. For a robot that only runs models, this installs just the runtime, the TensorRT backend, and the TensorRT and CUDA libraries they need, about 4.6 GB instead of 11 GB for the full install: pip install --no-deps executorch==1.6.0 torch-tensorrt-executorch-runtime==0.2.1 \ nvidia-cuda-runtime==13.2.86 tensorrt-cu13-libs==11.4.0.106 numpy Run, in C++ #include #include using namespace executorch::aten; using namespace executorch::extension; Module policy("policy.pte", "aoti_cuda_blob.ptd"); std::vector pixels(1 * 3 * 224 * 224); // filled from the camera auto observation = make_tensor_ptr({1, 3, 224, 224}, pixels); auto actions = policy.forward(observation); To build the app, link the CMake packages that come with the pip install. The Torch-TensorRT ExecuTorch guide has a complete CMakeLists.txt. If the input is already on the GPU, a camera frame for example, you can skip the copies to and from the CPU. Export with device inputs and outputs (see the CUDA backend docs) and pass the GPU pointer directly: // A camera pipeline already wrote the image to GPU memory. float* gpu_pixels = camera.gpu_frame(); // The policy writes its actions to GPU memory that you own. float* gpu_actions = nullptr; cudaMalloc(&gpu_actions, 50 * 6 * sizeof(float)); // 50 actions, 6 joints each auto actions = from_blob(gpu_actions, {1, 50, 6}, ScalarType::Float, DeviceType::CUDA); policy.set_output(*actions); policy.forward(from_blob(gpu_pixels, {1, 3, 224, 224}, ScalarType::Float, DeviceType::CUDA)); Performance We took four robot policies from LeRobot, Hugging Face’s robot-learning library: ACT, SmolVLA, pi0.5 and GR00T 1.7. Each one ran five ways on a Jetson Orin Nano Super (8 GB, about $250), with the same trained weights, the same inputs, and nothing quantized. Time per action chunk on the Orin Nano, milliseconds, lower is better: Memory on the Orin Nano: what the policy’s process holds while it runs, CPU and GPU together, MiB, lower is better: Time: median of three runs of 100 chunks, after 20 warm-up chunks. Memory: median of three runs, over the last 30 s of 120 s; files the process only reads, such as the program files, are not counted, and a range means the runs differed by more than 5%. The TensorRT columns and torch.compile replay CUDA graphs. Maximum power, GPU clock locked. Bold is best in the row. Differences of a few milliseconds are within run-to-run noise. Measured with the released Torch-TensorRT 2.15.0 and ExecuTorch 1.6.0. Benchmark method and full tables. A few things stand out: On the Orin Nano, ExecuTorch-TensorRT is within 4% of ONNX-TensorRT on every policy, and up to 6.4x faster than PyTorch eager mode. Memory is about the same as ONNX-TensorRT, and lower on the two small policies. The Torch-TensorRT column runs the same TensorRT engines inside PyTorch. That costs 0.7 to 1.4 GB more, and pi0.5 doesn’t fit at all. pi0.5, with 3.6 billion parameters, makes a chunk of 50 actions in about half a second on the 8 GB Orin Nano, where PyTorch eager mode runs out of memory. On an NVIDIA Jetson AGX Thor developer kit, the high-end robot board, resource limits are less of an issue, but memory efficiency still lets more workloads fit on the device. Again, the compiled paths end up with similar performance. Time per action chunk on Thor, milliseconds, lower is better: Memory on Thor, MiB, lower is better: Same method as on the Orin Nano. It isn’t limited to robot policies. We ran the same split on a 26-billion-parameter Gemma 4 language model with 4-bit weights on an A100. TensorRT took some parts, the CUDA backend took the rest, and the output tokens were exactly the same as with the CUDA backend alone. Big policies on a small board For best performance, a TensorRT engine is built for one kind of GPU, so you build it on the same kind of board it runs on. Building needs the whole model in memory, and on the 8 GB Orin Nano there isn’t room to build a 3.6-billion-parameter policy in one piece. So we split pi0.5 and GR00T into a chain of smaller programs. Each one is built in its own process from only its own weights, so the full checkpoint is never in memory at once. Both policies make actions by repeating one “denoising” step, so that step is a single program that runs ten times for pi0.5 and four times for GR00T. The programs hand tensors to each other on the GPU. At run time the TensorRT backend loads its engines through ExecuTorch’s shared GPU memory allocator, so there are no extra copies. Without it, pi0.5’s second engine wouldn’t load on the Orin Nano at all. Engines can also be larger than 2 GB and can live in a .ptd file next to the .pte, like other large data in ExecuTorch. On discrete GPUs, weight streaming also runs engines that don’t fit in GPU memory. Several policies on one GPU A robot rarely runs just one model. A big policy plans the next moves, a perception model looks at every camera frame, and a small controller has to run at a fixed, high rate. They all share one GPU’s memory and compute. Memory is the easier part. If one process loads the same program twice, say one policy per arm, Torch-TensorRT 2.15 keeps its engines in GPU memory only once. On the Orin Nano the second load took 76 MiB instead of 805 MiB. There’s also an option to let many engines share one working buffer per GPU. Compute is harder. A big model can fill every streaming multiprocessor (SM), and everything else has to wait. A CUDA green context gives a model its own fixed set of SMs. Every GPU backend in an ExecuTorch program runs on the CUDA stream you pick, so you create one stream per green context and run each policy on its own stream, in its own thread. It has to be a thread per policy, because forward() waits for its GPU work to finish: #include using namespace executorch::extension::cuda; // One thread per policy. Each thread has its own green context and stream. void run_policy(Module& policy, cudaStream_t stream) { CallerStreamGuard guard(stream); // this thread's GPU work runs on this policy's SMs while (running) { policy.forward(next_input(policy)); } } The helper is in executorch::extension::cuda and works with both the TensorRT and CUDA backends. A few limits: Memory bandwidth and other GPU resources are still shared, so delays get shorter but don’t go away. Jetsons don’t have many SMs (8 on the Orin Nano, 20 on the AGX Thor), so you can only split them a few ways. Torch-TensorRT builds each engine for the whole GPU. On a green context TensorRT warns about that, and an engine that uses kernels needing more SMs than the context has can fail, so give each green context enough SMs for its engine. What’s next End-to-end compilation for big policies. NVIDIA is working on compiling big models without splitting them by hand, so a Jetson Orin Nano can build pi0.5 and GR00T as a single program, with lower latency and a simpler workflow. LeRobot. We’re working with the Hugging Face LeRobot team on ExecuTorch export for LeRobot policies, so exported policies run faster than in PyTorch eager mode or torch.compile and don’t need PyTorch to run. You can follow which policies export and run on each GPU in this tracking issue, which uses newer builds than the tables above. Learn more ExecuTorch TensorRT backend docs Torch-TensorRT ExecuTorch deployment guide Examples in examples/torchtrt_executorch_example What model do you want to run, on which board, and where does it break today? Tell us in an issue on Torch-TensorRT or ExecuTorch.
AI NEWS JOURNAL
PyTorch BlogAI NEWS / JOURNAL
ExecuTorch-TensorRT: PyTorch Robot Policies at NVIDIA TensorRT Speed
TL;DR With Torch-TensorRT 2.15 and ExecuTorch 1.6 you can compile a PyTorch model with TensorRT, save it as an ExecuTorch program, and run it from C++ or Python without loading... The post ExecuTorch-TensorRT: PyTorch Robot Policies at NVIDIA TensorRT Speed appeared first on PyTorch.
翻译服务暂未运行,当前显示原文。