Skip to content

fix(dynamo): save programs with no inputs, keep attention masks that are not plain causal, fix uint8 shape ops and views left to PyTorch, show the runtime TensorRT build number, keep plugins that run PyTorch out of ExecuTorch programs - #4953

Merged
lanluo-nvidia merged 130 commits into
pytorch:mainfrom
shoumikhin:uint8-select-fallback
Nov 5, 2026

Conversation

@shoumikhin

@shoumikhin shoumikhin commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Fixes

  • Saving to ExecuTorch broke for programs with no tensor inputs, or where PyTorch fed an engine float64 (truncate_double=True).
  • uint8: shape ops such as permute failed to build. Comparisons and where with out-of-range integers follow PyTorch.
  • dtypes: int_tensor ** 0.5 gave 1. x * (n / 2) widened float16 to float32 for dynamic n.
  • RMSNorm: 16-bit inputs ran in 16 bits, not float32. Reading only the second output returned the first.
  • Views left to PyTorch became aten._reshape_copy, which ExecuTorch's CUDA backend lacks.
  • offload_module_to_cpu=True failed on some complex-number graphs.
  • Engine cache could reuse another graph's engine; older entries rebuild once. A refused refit now raises.
  • index_put, index and expand could give wrong results or fail.
  • Hierarchical partitioner put nodes no converter accepts into TensorRT blocks.
  • Windows: rejected input shapes crashed the Torch-TensorRT runtime.
  • ExecuTorch runtime: channels-last and other non-row-major inputs were misread, load errors showed equal TensorRT versions as different, and logging under the scratch pool lock could stall pooled engines.
  • Attention: a constant non-causal mask became is_causal=True; now kept for fixed lengths up to 4096. The attention decomposition ignored torch_executed_ops. A fully masked FP32 query gave NaN, not zeros; masked FP32 attention now runs as matmuls and softmax (about 17% slower with an additive mask). TensorRT-RTX lost accuracy on constant-scale attention.
  • Memory: compile and refit made unused random host tensors, which truncate_double=True also copied to the GPU.

New behavior

  • Saving to ExecuTorch raises for engines with plugins that run PyTorch (converters declare them with requires_pytorch_plugin=True), or with no record of them (older release, or hand-wrapped without pytorch_plugin_ops).
  • The ExecuTorch delegate requires libnvinfer_plugin, reorders a non-row-major input on every call (slow for channels-last), and returns InvalidArgument if the engine updates such an input in place.
  • attn_bias_is_causal="proven" replaces only a bias the compiler proves causal. Default stays True; None raises.

Opt-in settings

  • fallback_pytorch_plugin_ops: ops whose plugins run PyTorch stay in PyTorch; accumulating index_put uses ScatterElements where it can.
  • collapse_high_rank_permutes: static reshape and permute chains over 8 dims run in TensorRT.
  • convert_antialiased_resize: static antialiased bilinear and bicubic F.interpolate runs in TensorRT.

What was tested

Linux x86_64 (A100, H100), TensorRT 11.4; Windows and TensorRT-RTX only in CI. Nearly every fix adds or updates a test.

Overlaps with #4815, #4817, #4880, #4958. #4819 handles uint8 another way; maintainers should pick one.

@meta-cla meta-cla Bot added the cla signed label Oct 30, 2026
@github-actions github-actions Bot added component: tests Issues re: Tests component: core Issues re: The core compiler component: api [Python] Issues re: Python API component: api [C++] Issues re: C++ API component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths labels Oct 30, 2026
@shoumikhin shoumikhin changed the title fix(executorch): save programs with no inputs, and show the runtime TensorRT build number in load errors fix(dynamo): save programs with no inputs, keep uint8 shape ops in PyTorch, and show the runtime TensorRT build number Oct 30, 2026
@shoumikhin shoumikhin changed the title fix(dynamo): save programs with no inputs, keep uint8 shape ops in PyTorch, and show the runtime TensorRT build number fix(dynamo): save programs with no inputs, fix uint8 shape ops and views left to PyTorch, show the runtime TensorRT build number Oct 30, 2026
@github-actions github-actions Bot added the component: lowering Issues re: The lowering / preprocessing passes label Oct 30, 2026
@github-actions
github-actions Bot requested a review from narendasan October 30, 2026 17:50
@lanluo-nvidia lanluo-nvidia added this to the v2.15.0 milestone Oct 30, 2026

@lanluo-nvidia lanluo-nvidia left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@shoumikhin shoumikhin changed the title fix(dynamo): save programs with no inputs, fix uint8 shape ops and views left to PyTorch, show the runtime TensorRT build number fix(dynamo): save programs with no inputs, keep attention masks that are not plain causal, fix uint8 shape ops and views left to PyTorch, show the runtime TensorRT build number Oct 30, 2026
@github-actions github-actions Bot added documentation Improvements or additions to documentation component: conversion Issues re: Conversion stage labels Oct 30, 2026
@github-actions github-actions Bot added component: converters Issues re: Specific op converters component: runtime labels Oct 31, 2026
@shoumikhin shoumikhin changed the title fix(dynamo): save programs with no inputs, keep attention masks that are not plain causal, fix uint8 shape ops and views left to PyTorch, show the runtime TensorRT build number fix(dynamo): save programs with no inputs, keep attention masks that are not plain causal, fix uint8 shape ops and views left to PyTorch, show the runtime TensorRT build number, refuse ExecuTorch saves the runtime cannot load Oct 31, 2026
@shoumikhin shoumikhin changed the title fix(dynamo): save programs with no inputs, keep attention masks that are not plain causal, fix uint8 shape ops and views left to PyTorch, show the runtime TensorRT build number, refuse ExecuTorch saves the runtime cannot load fix(dynamo): save programs with no inputs, keep attention masks that are not plain causal, fix uint8 shape ops and views left to PyTorch, show the runtime TensorRT build number, refuse ExecuTorch saves of engines whose plugins run PyTorch Oct 31, 2026
@shoumikhin shoumikhin changed the title fix(dynamo): save programs with no inputs, keep attention masks that are not plain causal, fix uint8 shape ops and views left to PyTorch, show the runtime TensorRT build number, refuse ExecuTorch saves of engines whose plugins run PyTorch fix(dynamo): save programs with no inputs, keep attention masks that are not plain causal, fix uint8 shape ops and views left to PyTorch, show the runtime TensorRT build number, keep plugins that run PyTorch out of ExecuTorch programs Oct 31, 2026
shoumikhin added a commit to shoumikhin/lerobot that referenced this pull request Nov 2, 2026
lerobot-export compiles a trained policy into a bundle that
`lerobot-rollout --bundle.path=<folder>` runs:

    lerobot-export \
        --policy.path=outputs/train/act_so101/checkpoints/last/pretrained_model \
        --backend.type=executorch_tensorrt

Three pieces, each knowing one thing:

- A recipe knows the policy, never the compiler. It turns the policy into
  parts (a module, example inputs, and the names of its inputs and outputs)
  and makes the test case. The default recipe makes one part that does
  what lerobot-rollout does for one chunk: image conversion, the saved
  preprocessor, predict_action_chunk trimmed to the actions rollout plays,
  and the saved postprocessor. It takes the robot's frame and the starting
  noise, and returns actions in robot units. It covers policies that keep
  the chunk_inference_spec contract, draw at most one starting noise, and
  compute the same chunk twice from the same frame and noise; it refuses
  others with the reason. A policy that reads the task holds it, tokenized
  once at export. A policy that needs something else adds its own recipe
  in export_<type>.py beside its configuration, and the factory finds it
  there. The pieces a recipe shares (the robot's frame from the policy or
  its dataset, a random frame, the action scale) are plain functions.
- A backend knows the compiler, never the policy. It is a config class
  chosen with --backend.type. executorch_tensorrt compiles each part with
  Torch-TensorRT into an ExecuTorch program whose inputs and outputs stay
  in GPU memory, with TensorRT's TF32 off so float32 stays float32. It
  keeps out of TensorRT any operation whose TensorRT plugin would need
  PyTorch at run time (Torch-TensorRT's fallback_pytorch_plugin_ops), since
  ExecuTorch programs run without PyTorch. That setting comes with
  pytorch/TensorRT#4953, not in a release yet, and the backend refuses an
  older Torch-TensorRT, which would ignore the setting without a word. An
  installed package named lerobot_backend_* adds a backend, the way
  lerobot_runtime_* adds a runtime. A backend given with
  --backend.discover_packages_path is loaded in every step that needs it.
- The bundle holds the programs, the manifest (written once, after the
  last part is compiled), the test case, and the policy config as a record.

lerobot-export itself never imports PyTorch. It traces the policy in one
process, compiles each part in a process of its own, and checks the bundle
in another, so each step starts with the memory the one before it used
given back. The checkpoint loads like in lerobot-rollout, at
--policy.pretrained_revision and with PEFT adapters folded into the base
weights, onto the CPU; the recipe moves what it compiles to the backend's
device. The load is strict: a weight the checkpoint does not fill would
keep its random value, and the export's own check compares the bundle with
that same policy, so it could not tell. PyTorch's TF32 is off in every step, so the test case is the
policy's float32 arithmetic. Tracing and compiling run without autograd,
which nothing there needs and which some of ExecuTorch's passes cannot
record (complex views). The tolerance is in normalized action units:
each action's scale is measured from the saved postprocessor and stored in
the manifest. The bundle is written to a temporary folder, checked in a new
process the way lerobot-rollout checks it, and only then moved to the
output folder. If the actions differ too much, or the check crashes,
nothing is written, and a step that is killed leaves no folder behind.

Torch-TensorRT is not added to an extra: it pins one torch minor version,
which uv's single lock would impose on every extra. ExecuTorch 1.6, which
the runtime needs, and torchao 0.19 are not on PyPI yet, so the `export`
extra is left out of pyproject.toml for now, with a note.

The tests export a tiny ACT through the command with a test backend, added
as a plugin package, and check that the bundle plays the same actions as
SyncInferenceEngine, that the command never imports PyTorch, and that a checkpoint missing a
weight is refused. They also cover the recipe's
task, noise, image, camera and same-chunk rules on small policies, and
check that the plugin setting reaches Torch-TensorRT, that an older
Torch-TensorRT is refused, and that a backend from
--backend.discover_packages_path reaches the compile step. Also tested
by hand on NVIDIA GPUs: ACT, SmolVLA and pi0 exported with
executorch_tensorrt and passed the check.
shoumikhin added a commit to shoumikhin/lerobot that referenced this pull request Nov 2, 2026
A policy that starts from a random noise, such as pi0.5, SmolVLA or GR00T, got that noise from the host:
the engine drew it with NumPy and copied it to the GPU for every chunk. On a GPU backend the export now
adds a small program without inputs that draws the noise on the GPU, and the bundle runs it first. So a
chunk copies only the robot's frame to the GPU.

The bundle's own check still gives the test case's recorded noise to the same `noise` input and skips the
draw, so the check against PyTorch does not change. ExecuTorch 1.6 cannot seed a draw on the GPU, so such
a draw cannot be replayed exactly; replays use noise from the host, as the check does.

Saving a program without inputs with `executorch_tensorrt` needs pytorch/TensorRT#4953, which is not in a
release yet. The docs say so.

A test on a GPU counts every copy between the host and the GPU while the bundle runs: each chunk
copies only the frame to the GPU and the actions back.
shoumikhin added a commit to shoumikhin/lerobot that referenced this pull request Nov 2, 2026
lerobot-export compiles a trained policy into a bundle that
`lerobot-rollout --bundle.path=<folder>` runs:

    lerobot-export \
        --policy.path=outputs/train/act_so101/checkpoints/last/pretrained_model \
        --backend.type=executorch_tensorrt

Three pieces, each knowing one thing:

- A recipe knows the policy, never the compiler. It turns the policy into
  parts (a module, example inputs, and the names of its inputs and outputs)
  and makes the test case. The default recipe makes one part that does
  what lerobot-rollout does for one chunk: image conversion, the saved
  preprocessor, predict_action_chunk trimmed to the actions rollout plays,
  and the saved postprocessor. It takes the robot's frame and the starting
  noise, and returns actions in robot units. It covers policies that keep
  the chunk_inference_spec contract, draw at most one starting noise, and
  compute the same chunk twice from the same frame and noise; it refuses
  others with the reason. A policy that reads the task holds it, tokenized
  once at export. A policy that needs something else adds its own recipe
  in export_<type>.py beside its configuration, and the factory finds it
  there. The pieces a recipe shares (the robot's frame from the policy or
  its dataset, a random frame, the action scale) are plain functions.
- A backend knows the compiler, never the policy. It is a config class
  chosen with --backend.type. executorch_tensorrt compiles each part with
  Torch-TensorRT into an ExecuTorch program whose inputs and outputs stay
  in GPU memory, with TensorRT's TF32 off so float32 stays float32. It
  keeps out of TensorRT any operation whose TensorRT plugin would need
  PyTorch at run time (Torch-TensorRT's fallback_pytorch_plugin_ops), since
  ExecuTorch programs run without PyTorch. That setting comes with
  pytorch/TensorRT#4953, not in a release yet, and the backend refuses an
  older Torch-TensorRT, which would ignore the setting without a word. An
  installed package named lerobot_backend_* adds a backend, the way
  lerobot_runtime_* adds a runtime. A backend given with
  --backend.discover_packages_path is loaded in every step that needs it.
- The bundle holds the programs, the manifest (written once, after the
  last part is compiled), the test case, and the policy config as a record.

lerobot-export itself never imports PyTorch. It traces the policy in one
process, compiles each part in a process of its own, and checks the bundle
in another, so each step starts with the memory the one before it used
given back. The checkpoint loads like in lerobot-rollout, at
--policy.pretrained_revision and with PEFT adapters folded into the base
weights, onto the CPU; the recipe moves what it compiles to the backend's
device. The load is strict: a weight the checkpoint does not fill would
keep its random value, and the export's own check compares the bundle with
that same policy, so it could not tell. PyTorch's TF32 is off in every step, so the test case is the
policy's float32 arithmetic. Tracing and compiling run without autograd,
which nothing there needs and which some of ExecuTorch's passes cannot
record (complex views). The tolerance is in normalized action units:
each action's scale is measured from the saved postprocessor and stored in
the manifest. The bundle is written to a temporary folder, checked in a new
process the way lerobot-rollout checks it, and only then moved to the
output folder. If the actions differ too much, or the check crashes,
nothing is written, and a step that is killed leaves no folder behind.

Torch-TensorRT is not added to an extra: it pins one torch minor version,
which uv's single lock would impose on every extra. ExecuTorch 1.6, which
the runtime needs, and torchao 0.19 are not on PyPI yet, so the `export`
extra is left out of pyproject.toml for now, with a note.

The tests export a tiny ACT through the command with a test backend, added
as a plugin package, and check that the bundle plays the same actions as
SyncInferenceEngine, that the command never imports PyTorch, and that a checkpoint missing a
weight is refused. They also cover the recipe's
task, noise, image, camera and same-chunk rules on small policies, and
check that the plugin setting reaches Torch-TensorRT, that an older
Torch-TensorRT is refused, and that a backend from
--backend.discover_packages_path reaches the compile step. Also tested
by hand on NVIDIA GPUs: ACT, SmolVLA and pi0 exported with
executorch_tensorrt and passed the check.
shoumikhin added a commit to shoumikhin/lerobot that referenced this pull request Nov 2, 2026
A policy that starts from a random noise, such as pi0.5, SmolVLA or GR00T, got that noise from the host:
the engine drew it with NumPy and copied it to the GPU for every chunk. On a GPU backend the export now
adds a small program without inputs that draws the noise on the GPU, and the bundle runs it first. So a
chunk copies only the robot's frame to the GPU.

The bundle's own check still gives the test case's recorded noise to the same `noise` input and skips the
draw, so the check against PyTorch does not change. ExecuTorch 1.6 cannot seed a draw on the GPU, so such
a draw cannot be replayed exactly; replays use noise from the host, as the check does.

Saving a program without inputs with `executorch_tensorrt` needs pytorch/TensorRT#4953, which is not in a
release yet. The docs say so.

A test on a GPU counts every copy between the host and the GPU while the bundle runs: each chunk
copies only the frame to the GPU and the actions back.

@5had3z 5had3z left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The copy-transpose function is the main thing that stood out to me as something that could be a performance concern. I played with the idea of detecting and inserting explicit permute layer instead of performing the transpose copy. TensorRT can then fuse this with the next layer. However, the blast radius of this feature is quite large. This is worth it for transposing high-resolution images BCHW->BHWC, but less so for the efficient attention transpose BSHD->BHSD.

Otherwise generally lgtm.

@micwill755

Copy link
Copy Markdown
Collaborator

Hi Anthony, #4964, and #4953 have overlap:

@shoumikhin
shoumikhin force-pushed the uint8-select-fallback branch from 6fa7d1b to de4cfc0 Compare November 3, 2026 03:32
shoumikhin added a commit to shoumikhin/lerobot that referenced this pull request Nov 5, 2026
lerobot-export compiles a trained policy into a bundle that
`lerobot-rollout --bundle.path=<folder>` runs:

    lerobot-export \
        --policy.path=outputs/train/act_so101/checkpoints/last/pretrained_model \
        --backend.type=executorch_tensorrt

Three pieces, each knowing one thing:

- A recipe knows the policy, never the compiler. It turns the policy into
  parts (a module, example inputs, and the names of its inputs and outputs)
  and makes the test case. The default recipe makes one part that does
  what lerobot-rollout does for one chunk: image conversion, the saved
  preprocessor, predict_action_chunk trimmed to the actions rollout plays,
  and the saved postprocessor. It takes the robot's frame and the starting
  noise, and returns actions in robot units. It covers policies that keep
  the chunk_inference_spec contract, draw a starting noise they take in
  one draw, and compute the same chunk twice from the same frame and noise;
  it refuses others with the reason. A policy that reads the task holds it, tokenized
  once at export. A policy that needs something else adds its own recipe
  in export_<type>.py beside its configuration, and the factory finds it
  there. The pieces a recipe shares (the robot's frame from the policy or
  its dataset, a random frame, the action scale) are plain functions.
- A backend knows the compiler, never the policy. It is a config class
  chosen with --backend.type. executorch_tensorrt compiles each part with
  Torch-TensorRT into an ExecuTorch program whose inputs and outputs stay
  in GPU memory, with TensorRT's TF32 off so float32 stays float32. It
  keeps out of TensorRT any operation whose TensorRT plugin would need
  PyTorch at run time (Torch-TensorRT's fallback_pytorch_plugin_ops), since
  ExecuTorch programs run without PyTorch. That setting comes with
  pytorch/TensorRT#4953 (Torch-TensorRT 2.15). An installed package named lerobot_backend_*
  adds a backend, the way lerobot_runtime_* adds a runtime. A backend given with
  --backend.discover_packages_path is loaded in every step that needs it.
- The bundle holds the programs, the manifest (written once, after the
  last part is compiled), the test case, and the policy config as a record.

lerobot-export itself never imports PyTorch. It traces the policy in one
process, compiles each part in a process of its own, and checks the bundle
in another, so each step starts with the memory the one before it used
given back. Like an installed command, each of those processes skips the
current folder when it looks for modules (`python -P`), so a .py file
there, for example in a downloaded checkpoint folder, cannot load in place
of one. The checkpoint loads like in lerobot-rollout, at
--policy.pretrained_revision and with PEFT adapters folded into the base
weights, onto the CPU; the recipe moves what it compiles to the backend's
device. The load is strict: a weight the checkpoint does not fill, or a
PEFT adapter weight missing from its file, would keep its random value, and the export's own check compares the bundle with
that same policy, so it could not tell. PyTorch's TF32 is off in every step, so the test case is the
policy's float32 arithmetic. Each part is traced non-strictly, which is
PyTorch 2.15's default, on every PyTorch: PyTorch 2.7 traces strictly by
default and cannot trace some policies, such as ACT. Tracing and compiling run without autograd,
which nothing there needs and which some of ExecuTorch's passes cannot
record (complex views). The tolerance is in normalized action units:
each action's scale is measured from the saved postprocessor and stored in
the manifest. The bundle is written to a temporary folder, checked in a new
process the way lerobot-rollout checks it, and only then moved to the
output folder. If the actions differ too much, or the check crashes,
nothing is written, and a step that crashes or is killed leaves no folder
behind. The parent folders the export made for the output folder are
removed too, when nothing else is in them. An output folder that appears while the export runs, such as from
a second export to the same folder, is left alone, and this export removes
its own bundle. An output path that is a link, even one to nothing,
counts as taken. A SIGKILL of lerobot-export itself ends it before it can
clean up.

Torch-TensorRT is not added to an extra: it pins one torch minor version,
which uv's single lock would impose on every extra.

The tests export a tiny ACT through the command with a test backend, added
as a plugin package, and check that the bundle plays the same actions as
SyncInferenceEngine, that the command never imports PyTorch, and that a checkpoint missing a
weight is refused, and so is a PEFT adapter missing one. They also run an export from a folder holding .py files
named like modules the steps import, make the output folder while an
export runs, and check that --help writes nothing. The tests also cover the recipe's
task, noise, image, camera and same-chunk rules on small policies, and
check that the plugin setting always reaches Torch-TensorRT, and that a
backend from --backend.discover_packages_path reaches the compile step. Also tested
by hand on NVIDIA GPUs: ACT, SmolVLA and pi0 exported with
executorch_tensorrt and passed the check.
shoumikhin added a commit to shoumikhin/lerobot that referenced this pull request Nov 5, 2026
A policy that starts from a random noise, such as pi0.5, SmolVLA or GR00T, got that noise from the host:
the engine drew it with NumPy and copied it to the GPU for every chunk. On a GPU backend the export now
adds a small program without inputs that draws the noise on the GPU, and the bundle runs it first. So a
chunk copies only the robot's frame to the GPU.

The bundle's own check still gives the test case's recorded noise to the same `noise` input and skips the
draw, so the check against PyTorch does not change. Since the check skips that whole run, a run that draws
the noise must write nothing else, and the engine refuses one that does. ExecuTorch 1.6 cannot seed a draw
on the GPU, so such a draw cannot be replayed exactly; replays use noise from the host, as the check does.

Saving the noise program with `executorch_tensorrt` needs the `fallback_pytorch_plugin_ops` setting of
pytorch/TensorRT#4953, which Torch-TensorRT 2.15 carries.

A test on a GPU counts every copy between the host and the GPU while the bundle runs: each chunk
copies only the frame to the GPU and the actions back.
shoumikhin added a commit to shoumikhin/lerobot that referenced this pull request Nov 5, 2026
…d drive a robot with the bundle

The export tests compared bundles with their PyTorch policies, mostly
with the PyTorch test backend. Nothing exported the main policies with
every backend that ExecuTorch runs, checked where their programs run, or
ran `lerobot-rollout --bundle.path` on a bundle that a real compiler
wrote.

`tests/export/test_export_backends.py` exports tiny ACT, Diffusion
Policy, pi0, pi0.5, SmolVLA and GR00T checkpoints with
`executorch_xnnpack`, `executorch_cuda` and `executorch_tensorrt`. The
export itself only writes a bundle that reproduces the PyTorch policy's
test case within the bundle's tolerance. Then, for each bundle:

- Each program runs where its backend runs it. Every XNNPACK program
  holds only `XnnpackBackend` delegates, every CUDA program only
  `CudaBackend` ones, and every TensorRT program `TensorRTBackend` or
  `CudaBackend` ones, with `TensorRTBackend` somewhere in the bundle. A
  GPU program leaves no operator on the CPU, and its inputs and outputs
  stay in GPU memory.
- `lerobot-rollout --bundle.path` drives a recording robot for at least
  12 actions, which takes several chunks, in a process that never loads
  PyTorch.

The recording robot can now show a bundle's test case: with
`--robot.frames=<test case file>` it has a camera for each image of the
test case, so a bundle of a policy with cameras can drive it.

Each backend takes its skip mark from `tests/export/backends.py`, so a
row that a released ExecuTorch or Torch-TensorRT cannot run yet skips
and says which fix it needs.

One kind of row fails on every wheel released so far, so it skips up to
the version with the bug and runs again on a newer one: pi0 and pi0.5
with TensorRT. TensorRT 11.4.0.106 cannot build an engine for the tiny
policies' concatenations. The full-size policies build.

Tested on Linux x86_64:

- XNNPACK, on the CPU: all 6 policies, 12 passed.
- CUDA and TensorRT, on an A100, with ExecuTorch 1.6 and Torch-TensorRT
  2.15 built from source, the latter with pytorch/TensorRT#4953: 20
  passed, and the 4 tiny pi0 and pi0.5 TensorRT tests skipped as
  described above.

The following commit runs the XNNPACK and CUDA rows in CI. No CI job
installs Torch-TensorRT yet, so the TensorRT rows skip there.
shoumikhin added a commit to shoumikhin/lerobot that referenced this pull request Nov 5, 2026
lerobot-export compiles a trained policy into a bundle that
`lerobot-rollout --bundle.path=<folder>` runs:

    lerobot-export \
        --policy.path=outputs/train/act_so101/checkpoints/last/pretrained_model \
        --backend.type=executorch_tensorrt

Three pieces, each knowing one thing:

- A recipe knows the policy, never the compiler. It turns the policy into
  parts (a module, example inputs, and the names of its inputs and outputs)
  and makes the test case. The default recipe makes one part that does
  what lerobot-rollout does for one chunk: image conversion, the saved
  preprocessor, predict_action_chunk trimmed to the actions rollout plays,
  and the saved postprocessor. It takes the robot's frame and the starting
  noise, and returns actions in robot units. It covers policies that keep
  the chunk_inference_spec contract, draw a starting noise they take in
  one draw, and compute the same chunk twice from the same frame and noise;
  it refuses others with the reason. A policy that reads the task holds it, tokenized
  once at export. A policy that needs something else adds its own recipe
  in export_<type>.py beside its configuration, and the factory finds it
  there. The pieces a recipe shares (the robot's frame from the policy or
  its dataset, a random frame, the action scale) are plain functions.
- A backend knows the compiler, never the policy. It is a config class
  chosen with --backend.type. executorch_tensorrt compiles each part with
  Torch-TensorRT into an ExecuTorch program whose inputs and outputs stay
  in GPU memory, with TensorRT's TF32 off so float32 stays float32. It
  keeps out of TensorRT any operation whose TensorRT plugin would need
  PyTorch at run time (Torch-TensorRT's fallback_pytorch_plugin_ops), since
  ExecuTorch programs run without PyTorch. That setting comes with
  pytorch/TensorRT#4953 (Torch-TensorRT 2.15). An installed package named lerobot_backend_*
  adds a backend, the way lerobot_runtime_* adds a runtime. A backend given with
  --backend.discover_packages_path is loaded in every step that needs it.
- The bundle holds the programs, the manifest (written once, after the
  last part is compiled), the test case, and the policy config as a record.

lerobot-export itself never imports PyTorch. It traces the policy in one
process, compiles each part in a process of its own, and checks the bundle
in another, so each step starts with the memory the one before it used
given back. Like an installed command, each of those processes skips the
current folder when it looks for modules (`python -P`), so a .py file
there, for example in a downloaded checkpoint folder, cannot load in place
of one. The checkpoint loads like in lerobot-rollout, at
--policy.pretrained_revision and with PEFT adapters folded into the base
weights, onto the CPU; the recipe moves what it compiles to the backend's
device. The load is strict: a weight the checkpoint does not fill, or a
PEFT adapter weight missing from its file, would keep its random value, and the export's own check compares the bundle with
that same policy, so it could not tell. PyTorch's TF32 is off in every step, so the test case is the
policy's float32 arithmetic. Each part is traced non-strictly, which is
PyTorch 2.15's default, on every PyTorch: PyTorch 2.7 traces strictly by
default and cannot trace some policies, such as ACT. Tracing and compiling run without autograd,
which nothing there needs and which some of ExecuTorch's passes cannot
record (complex views). The tolerance is in normalized action units:
each action's scale is measured from the saved postprocessor and stored in
the manifest. The bundle is written to a temporary folder, checked in a new
process the way lerobot-rollout checks it, and only then moved to the
output folder. If the actions differ too much, or the check crashes,
nothing is written, and a step that crashes or is killed leaves no folder
behind. The parent folders the export made for the output folder are
removed too, when nothing else is in them. An output folder that appears while the export runs, such as from
a second export to the same folder, is left alone, and this export removes
its own bundle. An output path that is a link, even one to nothing,
counts as taken. A SIGKILL of lerobot-export itself ends it before it can
clean up.

Torch-TensorRT is not added to an extra: it pins one torch minor version,
which uv's single lock would impose on every extra.

The tests export a tiny ACT through the command with a test backend, added
as a plugin package, and check that the bundle plays the same actions as
SyncInferenceEngine, that the command never imports PyTorch, and that a checkpoint missing a
weight is refused, and so is a PEFT adapter missing one. They also run an export from a folder holding .py files
named like modules the steps import, make the output folder while an
export runs, and check that --help writes nothing. The tests also cover the recipe's
task, noise, image, camera and same-chunk rules on small policies, and
check that the plugin setting always reaches Torch-TensorRT, and that a
backend from --backend.discover_packages_path reaches the compile step. Also tested
by hand on NVIDIA GPUs: ACT, SmolVLA and pi0 exported with
executorch_tensorrt and passed the check.
shoumikhin added a commit to shoumikhin/lerobot that referenced this pull request Nov 5, 2026
A policy that starts from a random noise, such as pi0.5, SmolVLA or GR00T, got that noise from the host:
the engine drew it with NumPy and copied it to the GPU for every chunk. On a GPU backend the export now
adds a small program without inputs that draws the noise on the GPU, and the bundle runs it first. So a
chunk copies only the robot's frame to the GPU.

The bundle's own check still gives the test case's recorded noise to the same `noise` input and skips the
draw, so the check against PyTorch does not change. Since the check skips that whole run, a run that draws
the noise must write nothing else, and the engine refuses one that does. ExecuTorch 1.6 cannot seed a draw
on the GPU, so such a draw cannot be replayed exactly; replays use noise from the host, as the check does.

Saving the noise program with `executorch_tensorrt` needs the `fallback_pytorch_plugin_ops` setting of
pytorch/TensorRT#4953, which Torch-TensorRT 2.15 carries.

A test on a GPU counts every copy between the host and the GPU while the bundle runs: each chunk
copies only the frame to the GPU and the actions back.
shoumikhin added a commit to shoumikhin/lerobot that referenced this pull request Nov 5, 2026
…d drive a robot with the bundle

The export tests compared bundles with their PyTorch policies, mostly
with the PyTorch test backend. Nothing exported the main policies with
every backend that ExecuTorch runs, checked where their programs run, or
ran `lerobot-rollout --bundle.path` on a bundle that a real compiler
wrote.

`tests/export/test_export_backends.py` exports tiny ACT, Diffusion
Policy, pi0, pi0.5, SmolVLA and GR00T checkpoints with
`executorch_xnnpack`, `executorch_cuda` and `executorch_tensorrt`. The
export itself only writes a bundle that reproduces the PyTorch policy's
test case within the bundle's tolerance. Then, for each bundle:

- Each program runs where its backend runs it. Every XNNPACK program
  holds only `XnnpackBackend` delegates, every CUDA program only
  `CudaBackend` ones, and every TensorRT program `TensorRTBackend` or
  `CudaBackend` ones, with `TensorRTBackend` somewhere in the bundle. A
  GPU program leaves no operator on the CPU, and its inputs and outputs
  stay in GPU memory.
- `lerobot-rollout --bundle.path` drives a recording robot for at least
  12 actions, which takes several chunks, in a process that never loads
  PyTorch.

The recording robot can now show a bundle's test case: with
`--robot.frames=<test case file>` it has a camera for each image of the
test case, so a bundle of a policy with cameras can drive it.

Each backend takes its skip mark from `tests/export/backends.py`, so a
row that a released ExecuTorch or Torch-TensorRT cannot run yet skips
and says which fix it needs.

One kind of row fails on every wheel released so far, so it skips up to
the version with the bug and runs again on a newer one: pi0 and pi0.5
with TensorRT. TensorRT 11.4.0.106 cannot build an engine for the tiny
policies' concatenations. The full-size policies build.

Tested on Linux x86_64:

- XNNPACK, on the CPU: all 6 policies, 12 passed.
- CUDA and TensorRT, on an A100, with ExecuTorch 1.6 and Torch-TensorRT
  2.15 built from source, the latter with pytorch/TensorRT#4953: 20
  passed, and the 4 tiny pi0 and pi0.5 TensorRT tests skipped as
  described above.

The following commit runs the XNNPACK and CUDA rows in CI. No CI job
installs Torch-TensorRT yet, so the TensorRT rows skip there.
shoumikhin added a commit to shoumikhin/lerobot that referenced this pull request Nov 5, 2026
lerobot-export compiles a trained policy into a bundle that
`lerobot-rollout --bundle.path=<folder>` runs:

    lerobot-export \
        --policy.path=outputs/train/act_so101/checkpoints/last/pretrained_model \
        --backend.type=executorch_tensorrt

Three pieces, each knowing one thing:

- A recipe knows the policy, never the compiler. It turns the policy into
  parts (a module, example inputs, and the names of its inputs and outputs)
  and makes the test case. The default recipe makes one part that does
  what lerobot-rollout does for one chunk: image conversion, the saved
  preprocessor, predict_action_chunk trimmed to the actions rollout plays,
  and the saved postprocessor. It takes the robot's frame and the starting
  noise, and returns actions in robot units. It covers policies that keep
  the chunk_inference_spec contract, draw a starting noise they take in
  one draw, and compute the same chunk twice from the same frame and noise;
  it refuses others with the reason. A policy that reads the task holds it, tokenized
  once at export. A policy that needs something else adds its own recipe
  in export_<type>.py beside its configuration, and the factory finds it
  there. The pieces a recipe shares (the robot's frame from the policy or
  its dataset, a random frame, the action scale) are plain functions.
- A backend knows the compiler, never the policy. It is a config class
  chosen with --backend.type. executorch_tensorrt compiles each part with
  Torch-TensorRT into an ExecuTorch program whose inputs and outputs stay
  in GPU memory, with TensorRT's TF32 off so float32 stays float32. It
  keeps out of TensorRT any operation whose TensorRT plugin would need
  PyTorch at run time (Torch-TensorRT's fallback_pytorch_plugin_ops), since
  ExecuTorch programs run without PyTorch. That setting comes with
  pytorch/TensorRT#4953 (Torch-TensorRT 2.15). An installed package named lerobot_backend_*
  adds a backend, the way lerobot_runtime_* adds a runtime. A backend given with
  --backend.discover_packages_path is loaded in every step that needs it.
- The bundle holds the programs, the manifest (written once, after the
  last part is compiled), the test case, and the policy config as a record.

lerobot-export itself never imports PyTorch. It traces the policy in one
process, compiles each part in a process of its own, and checks the bundle
in another, so each step starts with the memory the one before it used
given back. Like an installed command, each of those processes skips the
current folder when it looks for modules (`python -P`), so a .py file
there, for example in a downloaded checkpoint folder, cannot load in place
of one. The checkpoint loads like in lerobot-rollout, at
--policy.pretrained_revision and with PEFT adapters folded into the base
weights, onto the CPU; the recipe moves what it compiles to the backend's
device. The load is strict: a weight the checkpoint does not fill, or a
PEFT adapter weight missing from its file, would keep its random value, and the export's own check compares the bundle with
that same policy, so it could not tell. PyTorch's TF32 is off in every step, so the test case is the
policy's float32 arithmetic. Each part is traced non-strictly, which is
PyTorch 2.15's default, on every PyTorch: PyTorch 2.7 traces strictly by
default and cannot trace some policies, such as ACT. Tracing and compiling run without autograd,
which nothing there needs and which some of ExecuTorch's passes cannot
record (complex views). The tolerance is in normalized action units:
each action's scale is measured from the saved postprocessor and stored in
the manifest. The bundle is written to a temporary folder, checked in a new
process the way lerobot-rollout checks it, and only then moved to the
output folder. If the actions differ too much, or the check crashes,
nothing is written, and a step that crashes or is killed leaves no folder
behind. The parent folders the export made for the output folder are
removed too, when nothing else is in them. An output folder that appears while the export runs, such as from
a second export to the same folder, is left alone, and this export removes
its own bundle. An output path that is a link, even one to nothing,
counts as taken. A SIGKILL of lerobot-export itself ends it before it can
clean up.

Torch-TensorRT is not added to an extra: it pins one torch minor version,
which uv's single lock would impose on every extra.

The tests export a tiny ACT through the command with a test backend, added
as a plugin package, and check that the bundle plays the same actions as
SyncInferenceEngine, that the command never imports PyTorch, and that a checkpoint missing a
weight is refused, and so is a PEFT adapter missing one. They also run an export from a folder holding .py files
named like modules the steps import, make the output folder while an
export runs, and check that --help writes nothing. The tests also cover the recipe's
task, noise, image, camera and same-chunk rules on small policies, and
check that the plugin setting always reaches Torch-TensorRT, and that a
backend from --backend.discover_packages_path reaches the compile step. Also tested
by hand on NVIDIA GPUs: ACT, SmolVLA and pi0 exported with
executorch_tensorrt and passed the check.
shoumikhin added a commit to shoumikhin/lerobot that referenced this pull request Nov 5, 2026
A policy that starts from a random noise, such as pi0.5, SmolVLA or GR00T, got that noise from the host:
the engine drew it with NumPy and copied it to the GPU for every chunk. On a GPU backend the export now
adds a small program without inputs that draws the noise on the GPU, and the bundle runs it first. So a
chunk copies only the robot's frame to the GPU.

The bundle's own check still gives the test case's recorded noise to the same `noise` input and skips the
draw, so the check against PyTorch does not change. Since the check skips that whole run, a run that draws
the noise must write nothing else, and the engine refuses one that does. ExecuTorch 1.6 cannot seed a draw
on the GPU, so such a draw cannot be replayed exactly; replays use noise from the host, as the check does.

Saving the noise program with `executorch_tensorrt` needs the `fallback_pytorch_plugin_ops` setting of
pytorch/TensorRT#4953, which Torch-TensorRT 2.15 carries.

A test on a GPU counts every copy between the host and the GPU while the bundle runs: each chunk
copies only the frame to the GPU and the actions back.
shoumikhin added a commit to shoumikhin/lerobot that referenced this pull request Nov 5, 2026
…d drive a robot with the bundle

The export tests compared bundles with their PyTorch policies, mostly
with the PyTorch test backend. Nothing exported the main policies with
every backend that ExecuTorch runs, checked where their programs run, or
ran `lerobot-rollout --bundle.path` on a bundle that a real compiler
wrote.

`tests/export/test_export_backends.py` exports tiny ACT, Diffusion
Policy, pi0, pi0.5, SmolVLA and GR00T checkpoints with
`executorch_xnnpack`, `executorch_cuda` and `executorch_tensorrt`. The
export itself only writes a bundle that reproduces the PyTorch policy's
test case within the bundle's tolerance. Then, for each bundle:

- Each program runs where its backend runs it. Every XNNPACK program
  holds only `XnnpackBackend` delegates, every CUDA program only
  `CudaBackend` ones, and every TensorRT program `TensorRTBackend` or
  `CudaBackend` ones, with `TensorRTBackend` somewhere in the bundle. A
  GPU program leaves no operator on the CPU, and its inputs and outputs
  stay in GPU memory.
- `lerobot-rollout --bundle.path` drives a recording robot for at least
  12 actions, which takes several chunks, in a process that never loads
  PyTorch.

The recording robot can now show a bundle's test case: with
`--robot.frames=<test case file>` it has a camera for each image of the
test case, so a bundle of a policy with cameras can drive it.

Each backend takes its skip mark from `tests/export/backends.py`, so a
row that a released ExecuTorch or Torch-TensorRT cannot run yet skips
and says which fix it needs.

One kind of row fails on every wheel released so far, so it skips up to
the version with the bug and runs again on a newer one: pi0 and pi0.5
with TensorRT. TensorRT 11.4.0.106 cannot build an engine for the tiny
policies' concatenations. The full-size policies build.

Tested on Linux x86_64:

- XNNPACK, on the CPU: all 6 policies, 12 passed.
- CUDA and TensorRT, on an A100, with ExecuTorch 1.6 and Torch-TensorRT
  2.15 built from source, the latter with pytorch/TensorRT#4953: 20
  passed, and the 4 tiny pi0 and pi0.5 TensorRT tests skipped as
  described above.

The following commit runs the XNNPACK and CUDA rows in CI. No CI job
installs Torch-TensorRT yet, so the TensorRT rows skip there.
shoumikhin added a commit to shoumikhin/lerobot that referenced this pull request Nov 13, 2026
lerobot-export compiles a trained policy into a bundle that
`lerobot-rollout --bundle.path=<folder>` runs:

    lerobot-export \
        --policy.path=outputs/train/act_so101/checkpoints/last/pretrained_model \
        --backend.type=executorch_tensorrt

Three pieces, each knowing one thing:

- A recipe knows the policy, never the compiler. It turns the policy into
  parts (a module, example inputs, and the names of its inputs and outputs)
  and makes the test case. The default recipe makes one part that does
  what lerobot-rollout does for one chunk: image conversion, the saved
  preprocessor, predict_action_chunk trimmed to the actions rollout plays,
  and the saved postprocessor. It takes the robot's frame and the starting
  noise, and returns actions in robot units. It covers policies that keep
  the chunk_inference_spec contract, draw a starting noise they take in
  one draw, and compute the same chunk twice from the same frame and noise;
  it refuses others with the reason. A policy that reads the task holds it, tokenized
  once at export. A policy that needs something else adds its own recipe
  in export_<type>.py beside its configuration, and the factory finds it
  there. The pieces a recipe shares (the robot's frame from the policy or
  its dataset, a random frame, the action scale) are plain functions.
- A backend knows the compiler, never the policy. It is a config class
  chosen with --backend.type. executorch_tensorrt compiles each part with
  Torch-TensorRT into an ExecuTorch program whose inputs and outputs stay
  in GPU memory, with TensorRT's TF32 off so float32 stays float32. It
  keeps out of TensorRT any operation whose TensorRT plugin would need
  PyTorch at run time (Torch-TensorRT's fallback_pytorch_plugin_ops), since
  ExecuTorch programs run without PyTorch. That setting comes with
  pytorch/TensorRT#4953 (Torch-TensorRT 2.15). An installed package named lerobot_backend_*
  adds a backend, the way lerobot_runtime_* adds a runtime. A backend given with
  --backend.discover_packages_path is loaded in every step that needs it.
- The bundle holds the programs, the manifest (written once, after the
  last part is compiled), the test case, and the policy config as a record.

lerobot-export itself never imports PyTorch. It traces the policy in one
process, compiles each part in a process of its own, and checks the bundle
in another, so each step starts with the memory the one before it used
given back. Like an installed command, each of those processes skips the
current folder when it looks for modules (`python -P`), so a .py file
there, for example in a downloaded checkpoint folder, cannot load in place
of one. The checkpoint loads like in lerobot-rollout, at
--policy.pretrained_revision and with PEFT adapters folded into the base
weights, onto the CPU; the recipe moves what it compiles to the backend's
device. The load is strict: a weight the checkpoint does not fill, or a
PEFT adapter weight missing from its file, would keep its random value, and the export's own check compares the bundle with
that same policy, so it could not tell. PyTorch's TF32 is off in every step, so the test case is the
policy's float32 arithmetic. Each part is traced non-strictly, which is
PyTorch 2.15's default, on every PyTorch: PyTorch 2.7 traces strictly by
default and cannot trace some policies, such as ACT. Tracing and compiling run without autograd,
which nothing there needs and which some of ExecuTorch's passes cannot
record (complex views). The tolerance is in normalized action units:
each action's scale is measured from the saved postprocessor and stored in
the manifest. The bundle is written to a temporary folder, checked in a new
process the way lerobot-rollout checks it, and only then moved to the
output folder. If the actions differ too much, or the check crashes,
nothing is written, and a step that crashes or is killed leaves no folder
behind. The parent folders the export made for the output folder are
removed too, when nothing else is in them. An output folder that appears while the export runs, such as from
a second export to the same folder, is left alone, and this export removes
its own bundle. An output path that is a link, even one to nothing,
counts as taken. A SIGKILL of lerobot-export itself ends it before it can
clean up.

Torch-TensorRT is not added to an extra: it pins one torch minor version,
which uv's single lock would impose on every extra.

The tests export a tiny ACT through the command with a test backend, added
as a plugin package, and check that the bundle plays the same actions as
SyncInferenceEngine, that the command never imports PyTorch, and that a checkpoint missing a
weight is refused, and so is a PEFT adapter missing one. They also run an export from a folder holding .py files
named like modules the steps import, make the output folder while an
export runs, and check that --help writes nothing. The tests also cover the recipe's
task, noise, image, camera and same-chunk rules on small policies, and
check that the plugin setting always reaches Torch-TensorRT, and that a
backend from --backend.discover_packages_path reaches the compile step, and that each
backend's install command brings the modules a bundle imports. Also tested
by hand on NVIDIA GPUs: ACT, SmolVLA and pi0 exported with
executorch_tensorrt and passed the check.
shoumikhin added a commit to shoumikhin/lerobot that referenced this pull request Nov 13, 2026
A policy that starts from a random noise, such as pi0.5, SmolVLA or GR00T, got that noise from the host:
the engine drew it with NumPy and copied it to the GPU for every chunk. On a GPU backend the export now
adds a small program without inputs that draws the noise on the GPU, and the bundle runs it first. So a
chunk copies only the robot's frame to the GPU.

The bundle's own check still gives the test case's recorded noise to the same `noise` input and skips the
draw, so the check against PyTorch does not change. Since the check skips that whole run, a run that draws
the noise must write nothing else, and the engine refuses one that does. ExecuTorch 1.6 cannot seed a draw
on the GPU, so such a draw cannot be replayed exactly; replays use noise from the host, as the check does.

Saving the noise program with `executorch_tensorrt` needs the `fallback_pytorch_plugin_ops` setting of
pytorch/TensorRT#4953, which Torch-TensorRT 2.15 carries.

A test on a GPU counts every copy between the host and the GPU while the bundle runs: each chunk
copies only the frame to the GPU and the actions back.
shoumikhin added a commit to shoumikhin/lerobot that referenced this pull request Nov 13, 2026
…d drive a robot with the bundle

The export tests compared bundles with their PyTorch policies, mostly
with the PyTorch test backend. Nothing exported the main policies with
every backend that ExecuTorch runs, checked where their programs run, or
ran `lerobot-rollout --bundle.path` on a bundle that a real compiler
wrote.

`tests/export/test_export_backends.py` exports tiny ACT, Diffusion
Policy, pi0, pi0.5, SmolVLA and GR00T checkpoints with
`executorch_xnnpack`, `executorch_cuda` and `executorch_tensorrt`. The
export itself only writes a bundle that reproduces the PyTorch policy's
test case within the bundle's tolerance. Then, for each bundle:

- Each program runs where its backend runs it. Every XNNPACK program
  holds only `XnnpackBackend` delegates, every CUDA program only
  `CudaBackend` ones, and every TensorRT program `TensorRTBackend` or
  `CudaBackend` ones, with `TensorRTBackend` somewhere in the bundle. A
  GPU program leaves no operator on the CPU, and its inputs and outputs
  stay in GPU memory.
- `lerobot-rollout --bundle.path` drives a recording robot for at least
  12 actions, which takes several chunks, in a process that never loads
  PyTorch.

The recording robot can now show a bundle's test case: with
`--robot.frames=<test case file>` it has a camera for each image of the
test case, so a bundle of a policy with cameras can drive it.

Each backend takes its skip mark from `tests/export/backends.py`, so a
row that a released ExecuTorch or Torch-TensorRT cannot run yet skips
and says which fix it needs.

One kind of row fails on every wheel released so far, so it skips up to
the version with the bug and runs again on a newer one: pi0 and pi0.5
with TensorRT. TensorRT 11.4.0.106 cannot build an engine for the tiny
policies' concatenations. The full-size policies build.

Tested on Linux x86_64:

- XNNPACK, on the CPU: all 6 policies, 12 passed.
- CUDA and TensorRT, on an A100, with ExecuTorch 1.6 and Torch-TensorRT
  2.15 built from source, the latter with pytorch/TensorRT#4953: 20
  passed, and the 4 tiny pi0 and pi0.5 TensorRT tests skipped as
  described above.

The following commit runs the XNNPACK and CUDA rows in CI. No CI job
installs Torch-TensorRT yet, so the TensorRT rows skip there.
shoumikhin added a commit to shoumikhin/lerobot that referenced this pull request Nov 23, 2026
lerobot-export compiles a trained policy into a bundle that
`lerobot-rollout --bundle.path=<folder>` runs:

    lerobot-export \
        --policy.path=outputs/train/act_so101/checkpoints/last/pretrained_model \
        --backend.type=executorch_tensorrt

Three pieces, each knowing one thing:

- A recipe knows the policy, never the compiler. It turns the policy into
  parts (a module, example inputs, and the names of its inputs and outputs)
  and makes the test case. The default recipe makes one part that does
  what lerobot-rollout does for one chunk: image conversion, the saved
  preprocessor, predict_action_chunk trimmed to the actions rollout plays,
  and the saved postprocessor. It takes the robot's frame and the starting
  noise, and returns actions in robot units. It covers policies that keep
  the chunk_inference_spec contract, draw a starting noise they take in
  one draw, and compute the same chunk twice from the same frame and noise;
  it refuses others with the reason. A policy that reads the task holds it, tokenized
  once at export. A policy that needs something else adds its own recipe
  in export_<type>.py beside its configuration, and the factory finds it
  there. The pieces a recipe shares (the robot's frame from the policy or
  its dataset, a random frame, the action scale) are plain functions.
- A backend knows the compiler, never the policy. It is a config class
  chosen with --backend.type. executorch_tensorrt compiles each part with
  Torch-TensorRT into an ExecuTorch program whose inputs and outputs stay
  in GPU memory, with TensorRT's TF32 off so float32 stays float32. It
  keeps out of TensorRT any operation whose TensorRT plugin would need
  PyTorch at run time (Torch-TensorRT's fallback_pytorch_plugin_ops), since
  ExecuTorch programs run without PyTorch. That setting comes with
  pytorch/TensorRT#4953 (Torch-TensorRT 2.15). An installed package named lerobot_backend_*
  adds a backend. A backend given with
  --backend.discover_packages_path is loaded in every step that needs it.
- The bundle holds the programs, the manifest (written once, after the
  last part is compiled), the test case, and the policy config as a record.

lerobot-export itself never imports PyTorch. It traces the policy in one
process, compiles each part in a process of its own, and checks the bundle
in another, so each step starts with the memory the one before it used
given back. Like an installed command, each of those processes skips the
current folder when it looks for modules (`python -P`), so a .py file
there, for example in a downloaded checkpoint folder, cannot load in place
of one. The checkpoint loads like in lerobot-rollout, at
--policy.pretrained_revision and with PEFT adapters folded into the base
weights, onto the CPU; the recipe moves what it compiles to the backend's
device. The load is strict: a weight the checkpoint does not fill, or a
PEFT adapter weight missing from its file, would keep its random value, and the export's own check compares the bundle with
that same policy, so it could not tell. PyTorch's TF32 is off in every step, so the test case is the
policy's float32 arithmetic. Each part is traced non-strictly, which is
PyTorch 2.15's default, on every PyTorch: PyTorch 2.7 traces strictly by
default and cannot trace some policies, such as ACT. Tracing and compiling run without autograd,
which nothing there needs and which some of ExecuTorch's passes cannot
record (complex views). The tolerance is in normalized action units:
each action's scale is measured from the saved postprocessor and stored in
the manifest. The bundle is written to a temporary folder, checked in a new
process the way lerobot-rollout checks it, and only then moved to the
output folder. If the actions differ too much, or the check crashes,
nothing is written, and a step that crashes or is killed leaves no folder
behind. The parent folders the export made for the output folder are
removed too, when nothing else is in them. An output folder that appears while the export runs, such as from
a second export to the same folder, is left alone, and this export removes
its own bundle. An output path that is a link, even one to nothing,
counts as taken. A SIGKILL of lerobot-export itself ends it before it can
clean up.

Torch-TensorRT is not added to an extra: it pins one torch minor version,
which uv's single lock would impose on every extra.

The tests export a tiny ACT through the command with a test backend, added
as a plugin package, and check that the bundle plays the same actions as
SyncInferenceEngine, that the command never imports PyTorch, and that a checkpoint missing a
weight is refused, and so is a PEFT adapter missing one. They also run an export from a folder holding .py files
named like modules the steps import, make the output folder while an
export runs, and check that --help writes nothing. The tests also cover the recipe's
task, noise, image, camera and same-chunk rules on small policies, and
check that the plugin setting always reaches Torch-TensorRT, and that a
backend from --backend.discover_packages_path reaches the compile step. Also tested
by hand on NVIDIA GPUs: ACT, SmolVLA and pi0 exported with
executorch_tensorrt and passed the check.
shoumikhin added a commit to shoumikhin/lerobot that referenced this pull request Nov 23, 2026
A policy that starts from a random noise, such as pi0.5, SmolVLA or GR00T, got that noise from the host:
the engine drew it with NumPy and copied it to the GPU for every chunk. On a GPU backend the export now
adds a small program without inputs that draws the noise on the GPU, and the bundle runs it first. So a
chunk copies only the robot's frame to the GPU.

The bundle's own check still gives the test case's recorded noise to the same `noise` input and skips the
draw, so the check against PyTorch does not change. Since the check skips that whole run, a run that draws
the noise must write nothing else, and the engine refuses one that does. ExecuTorch 1.6 cannot seed a draw
on the GPU, so such a draw cannot be replayed exactly; replays use noise from the host, as the check does.

Saving the noise program with `executorch_tensorrt` needs the `fallback_pytorch_plugin_ops` setting of
pytorch/TensorRT#4953, which Torch-TensorRT 2.15 carries.

A test on a GPU counts every copy between the host and the GPU while the bundle runs: each chunk
copies only the frame to the GPU and the actions back.
shoumikhin added a commit to shoumikhin/lerobot that referenced this pull request Nov 23, 2026
…d drive a robot with the bundle

The export tests compared bundles with their PyTorch policies, mostly
with the PyTorch test backend. Nothing exported the main policies with
every backend that ExecuTorch runs, checked where their programs run, or
ran `lerobot-rollout --bundle.path` on a bundle that a real compiler
wrote.

`tests/export/test_export_backends.py` exports tiny ACT, Diffusion
Policy, pi0, pi0.5, SmolVLA and GR00T checkpoints with
`executorch_xnnpack`, `executorch_cuda` and `executorch_tensorrt`. The
export itself only writes a bundle that reproduces the PyTorch policy's
test case within the bundle's tolerance. Then, for each bundle:

- Each program runs where its backend runs it. Every XNNPACK program
  holds only `XnnpackBackend` delegates, every CUDA program only
  `CudaBackend` ones, and every TensorRT program `TensorRTBackend` or
  `CudaBackend` ones, with `TensorRTBackend` somewhere in the bundle. A
  GPU program leaves no operator on the CPU, and its inputs and outputs
  stay in GPU memory.
- `lerobot-rollout --bundle.path` drives a recording robot for at least
  12 actions, which takes several chunks, in a process that never loads
  PyTorch.

The recording robot can now show a bundle's test case: with
`--robot.frames=<test case file>` it has a camera for each image of the
test case, so a bundle of a policy with cameras can drive it.

Each backend takes its skip mark from `tests/export/backends.py`, so a
row that a released ExecuTorch or Torch-TensorRT cannot run yet skips
and says which fix it needs.

One kind of row fails on every wheel released so far, so it skips up to
the version with the bug and runs again on a newer one: pi0 and pi0.5
with TensorRT. TensorRT 11.4.0.106 cannot build an engine for the tiny
policies' concatenations. The full-size policies build.

Tested on Linux x86_64:

- XNNPACK, on the CPU: all 6 policies, 12 passed.
- CUDA and TensorRT, on an A100, with ExecuTorch 1.6 and Torch-TensorRT
  2.15 built from source, the latter with pytorch/TensorRT#4953: 20
  passed, and the 4 tiny pi0 and pi0.5 TensorRT tests skipped as
  described above.

The export jobs in CI run the XNNPACK and CUDA rows. No CI job
installs Torch-TensorRT yet, so the TensorRT rows skip there.
shoumikhin added a commit to shoumikhin/lerobot that referenced this pull request Nov 23, 2026
lerobot-export compiles a trained policy into a bundle that
`lerobot-rollout --bundle.path=<folder>` runs:

    lerobot-export \
        --policy.path=outputs/train/act_so101/checkpoints/last/pretrained_model \
        --backend.type=executorch_tensorrt

Three pieces, each knowing one thing:

- A recipe knows the policy, never the compiler. It turns the policy into
  parts (a module, example inputs, and the names of its inputs and outputs)
  and makes the test case. The default recipe makes one part that does
  what lerobot-rollout does for one chunk: image conversion, the saved
  preprocessor, predict_action_chunk trimmed to the actions rollout plays,
  and the saved postprocessor. It takes the robot's frame and the starting
  noise, and returns actions in robot units. It covers policies that keep
  the chunk_inference_spec contract, draw a starting noise they take in
  one draw, and compute the same chunk twice from the same frame and noise;
  it refuses others with the reason. A policy that reads the task holds it, tokenized
  once at export. A policy that needs something else adds its own recipe
  in export_<type>.py beside its configuration, and the factory finds it
  there. The pieces a recipe shares (the robot's frame from the policy or
  its dataset, a random frame, the action scale) are plain functions.
- A backend knows the compiler, never the policy. It is a config class
  chosen with --backend.type. executorch_tensorrt compiles each part with
  Torch-TensorRT into an ExecuTorch program whose inputs and outputs stay
  in GPU memory, with TensorRT's TF32 off so float32 stays float32. It
  keeps out of TensorRT any operation whose TensorRT plugin would need
  PyTorch at run time (Torch-TensorRT's fallback_pytorch_plugin_ops), since
  ExecuTorch programs run without PyTorch. That setting comes with
  pytorch/TensorRT#4953 (Torch-TensorRT 2.15). An installed package named lerobot_backend_*
  adds a backend. A backend given with
  --backend.discover_packages_path is loaded in every step that needs it.
- The bundle holds the programs, the manifest (written once, after the
  last part is compiled), the test case, and the policy config as a record.

lerobot-export itself never imports PyTorch. It traces the policy in one
process, compiles each part in a process of its own, and checks the bundle
in another, so each step starts with the memory the one before it used
given back. Like an installed command, each of those processes skips the
current folder when it looks for modules (`python -P`), so a .py file
there, for example in a downloaded checkpoint folder, cannot load in place
of one. The checkpoint loads like in lerobot-rollout, at
--policy.pretrained_revision and with PEFT adapters folded into the base
weights, onto the CPU; the recipe moves what it compiles to the backend's
device. The load is strict: a weight the checkpoint does not fill, or a
PEFT adapter weight missing from its file, would keep its random value, and the export's own check compares the bundle with
that same policy, so it could not tell. PyTorch's TF32 is off in every step, so the test case is the
policy's float32 arithmetic. Each part is traced non-strictly, which is
PyTorch 2.15's default, on every PyTorch: PyTorch 2.7 traces strictly by
default and cannot trace some policies, such as ACT. Tracing and compiling run without autograd,
which nothing there needs and which some of ExecuTorch's passes cannot
record (complex views). The tolerance is in normalized action units:
each action's scale is measured from the saved postprocessor and stored in
the manifest. The bundle is written to a temporary folder, checked in a new
process the way lerobot-rollout checks it, and only then moved to the
output folder. If the actions differ too much, or the check crashes,
nothing is written, and a step that crashes or is killed leaves no folder
behind. The parent folders the export made for the output folder are
removed too, when nothing else is in them. An output folder that appears while the export runs, such as from
a second export to the same folder, is left alone, and this export removes
its own bundle. An output path that is a link, even one to nothing,
counts as taken. A SIGKILL of lerobot-export itself ends it before it can
clean up.

Torch-TensorRT is not added to an extra: it pins one torch minor version,
which uv's single lock would impose on every extra.

The tests export a tiny ACT through the command with a test backend, added
as a plugin package, and check that the bundle plays the same actions as
SyncInferenceEngine, that the command never imports PyTorch, and that a checkpoint missing a
weight is refused, and so is a PEFT adapter missing one. They also run an export from a folder holding .py files
named like modules the steps import, make the output folder while an
export runs, and check that --help writes nothing. The tests also cover the recipe's
task, noise, image, camera and same-chunk rules on small policies, and
check that the plugin setting always reaches Torch-TensorRT, and that a
backend from --backend.discover_packages_path reaches the compile step. Also tested
by hand on NVIDIA GPUs: ACT, SmolVLA and pi0 exported with
executorch_tensorrt and passed the check.
shoumikhin added a commit to shoumikhin/lerobot that referenced this pull request Nov 23, 2026
A policy that starts from a random noise, such as pi0.5, SmolVLA or GR00T, got that noise from the host:
the engine drew it with NumPy and copied it to the GPU for every chunk. On a GPU backend the export now
adds a small program without inputs that draws the noise on the GPU, and the bundle runs it first. So a
chunk copies only the robot's frame to the GPU.

The bundle's own check still gives the test case's recorded noise to the same `noise` input and skips the
draw, so the check against PyTorch does not change. Since the check skips that whole run, a run that draws
the noise must write nothing else, and the engine refuses one that does. ExecuTorch 1.6 cannot seed a draw
on the GPU, so such a draw cannot be replayed exactly; replays use noise from the host, as the check does.

Saving the noise program with `executorch_tensorrt` needs the `fallback_pytorch_plugin_ops` setting of
pytorch/TensorRT#4953, which Torch-TensorRT 2.15 carries.

A test on a GPU counts every copy between the host and the GPU while the bundle runs: each chunk
copies only the frame to the GPU and the actions back.
shoumikhin added a commit to shoumikhin/lerobot that referenced this pull request Nov 23, 2026
…d drive a robot with the bundle

The export tests compared bundles with their PyTorch policies, mostly
with the PyTorch test backend. Nothing exported the main policies with
every backend that ExecuTorch runs, checked where their programs run, or
ran `lerobot-rollout --bundle.path` on a bundle that a real compiler
wrote.

`tests/export/test_export_backends.py` exports tiny ACT, Diffusion
Policy, pi0, pi0.5, SmolVLA and GR00T checkpoints with
`executorch_xnnpack`, `executorch_cuda` and `executorch_tensorrt`. The
export itself only writes a bundle that reproduces the PyTorch policy's
test case within the bundle's tolerance. Then, for each bundle:

- Each program runs where its backend runs it. Every XNNPACK program
  holds only `XnnpackBackend` delegates, every CUDA program only
  `CudaBackend` ones, and every TensorRT program `TensorRTBackend` or
  `CudaBackend` ones, with `TensorRTBackend` somewhere in the bundle. A
  GPU program leaves no operator on the CPU, and its inputs and outputs
  stay in GPU memory.
- `lerobot-rollout --bundle.path` drives a recording robot for at least
  12 actions, which takes several chunks, in a process that never loads
  PyTorch.

The recording robot can now show a bundle's test case: with
`--robot.frames=<test case file>` it has a camera for each image of the
test case, so a bundle of a policy with cameras can drive it.

Each backend takes its skip mark from `tests/export/backends.py`, so a
row that a released ExecuTorch or Torch-TensorRT cannot run yet skips
and says which fix it needs.

One kind of row fails on every wheel released so far, so it skips up to
the version with the bug and runs again on a newer one: pi0 and pi0.5
with TensorRT. TensorRT 11.4.0.106 cannot build an engine for the tiny
policies' concatenations. The full-size policies build.

Tested on Linux x86_64:

- XNNPACK, on the CPU: all 6 policies, 12 passed.
- CUDA and TensorRT, on an A100, with ExecuTorch 1.6 and Torch-TensorRT
  2.15 built from source, the latter with pytorch/TensorRT#4953: 20
  passed, and the 4 tiny pi0 and pi0.5 TensorRT tests skipped as
  described above.

The export jobs in CI run the XNNPACK and CUDA rows. No CI job
installs Torch-TensorRT yet, so the TensorRT rows skip there.
shoumikhin added a commit to shoumikhin/lerobot that referenced this pull request Nov 23, 2026
lerobot-export compiles a trained policy into a bundle that
`lerobot-rollout --bundle.path=<folder>` runs:

    lerobot-export \
        --policy.path=outputs/train/act_so101/checkpoints/last/pretrained_model \
        --backend.type=executorch_tensorrt

Three pieces, each knowing one thing:

- A recipe knows the policy, never the compiler. It turns the policy into
  parts (a module, example inputs, and the names of its inputs and outputs)
  and makes the test case. The default recipe makes one part that does
  what lerobot-rollout does for one chunk: image conversion, the saved
  preprocessor, predict_action_chunk trimmed to the actions rollout plays,
  and the saved postprocessor. It takes the robot's frame and the starting
  noise, and returns actions in robot units. It covers policies that keep
  the chunk_inference_spec contract, draw a starting noise they take in
  one draw, and compute the same chunk twice from the same frame and noise;
  it refuses others with the reason. A policy that reads the task holds it, tokenized
  once at export. A policy that needs something else adds its own recipe
  in export_<type>.py beside its configuration, and the factory finds it
  there. The pieces a recipe shares (the robot's frame from the policy or
  its dataset, a random frame, the action scale) are plain functions.
- A backend knows the compiler, never the policy. It is a config class
  chosen with --backend.type. executorch_tensorrt compiles each part with
  Torch-TensorRT into an ExecuTorch program whose inputs and outputs stay
  in GPU memory, with TensorRT's TF32 off so float32 stays float32. It
  keeps out of TensorRT any operation whose TensorRT plugin would need
  PyTorch at run time (Torch-TensorRT's fallback_pytorch_plugin_ops), since
  ExecuTorch programs run without PyTorch. That setting comes with
  pytorch/TensorRT#4953 (Torch-TensorRT 2.15). An installed package named lerobot_backend_*
  adds a backend. A backend given with
  --backend.discover_packages_path is loaded in every step that needs it.
- The bundle holds the programs, the manifest (written once, after the
  last part is compiled), the test case, and the policy config as a record.

lerobot-export itself never imports PyTorch. It traces the policy in one
process, compiles each part in a process of its own, and checks the bundle
in another, so each step starts with the memory the one before it used
given back. Like an installed command, each of those processes skips the
current folder when it looks for modules (`python -P`), so a .py file
there, for example in a downloaded checkpoint folder, cannot load in place
of one. The checkpoint loads like in lerobot-rollout, at
--policy.pretrained_revision and with PEFT adapters folded into the base
weights, onto the CPU; the recipe moves what it compiles to the backend's
device. The load is strict: a weight the checkpoint does not fill, or a
PEFT adapter weight missing from its file, would keep its random value, and the export's own check compares the bundle with
that same policy, so it could not tell. PyTorch's TF32 is off in every step, so the test case is the
policy's float32 arithmetic. Each part is traced non-strictly, which is
PyTorch 2.15's default, on every PyTorch: PyTorch 2.7 traces strictly by
default and cannot trace some policies, such as ACT. Tracing and compiling run without autograd,
which nothing there needs and which some of ExecuTorch's passes cannot
record (complex views). The tolerance is in normalized action units:
each action's scale is measured from the saved postprocessor and stored in
the manifest. The bundle is written to a temporary folder, checked in a new
process the way lerobot-rollout checks it, and only then moved to the
output folder. If the actions differ too much, or the check crashes,
nothing is written, and a step that crashes or is killed leaves no folder
behind. The parent folders the export made for the output folder are
removed too, when nothing else is in them. An output folder that appears while the export runs, such as from
a second export to the same folder, is left alone, and this export removes
its own bundle. An output path that is a link, even one to nothing,
counts as taken. A SIGKILL of lerobot-export itself ends it before it can
clean up.

Torch-TensorRT is not added to an extra: it pins one torch minor version,
which uv's single lock would impose on every extra.

The tests export a tiny ACT through the command with a test backend, added
as a plugin package, and check that the bundle plays the same actions as
SyncInferenceEngine, that the command never imports PyTorch, and that a checkpoint missing a
weight is refused, and so is a PEFT adapter missing one. They also run an export from a folder holding .py files
named like modules the steps import, make the output folder while an
export runs, and check that --help writes nothing. The tests also cover the recipe's
task, noise, image, camera and same-chunk rules on small policies, and
check that the plugin setting always reaches Torch-TensorRT, and that a
backend from --backend.discover_packages_path reaches the compile step. Also tested
by hand on NVIDIA GPUs: ACT, SmolVLA and pi0 exported with
executorch_tensorrt and passed the check.
shoumikhin added a commit to shoumikhin/lerobot that referenced this pull request Nov 23, 2026
A policy that starts from a random noise, such as pi0.5, SmolVLA or GR00T, got that noise from the host:
the engine drew it with NumPy and copied it to the GPU for every chunk. On a GPU backend the export now
adds a small program without inputs that draws the noise on the GPU, and the bundle runs it first. So a
chunk copies only the robot's frame to the GPU.

The bundle's own check still gives the test case's recorded noise to the same `noise` input and skips the
draw, so the check against PyTorch does not change. Since the check skips that whole run, a run that draws
the noise must write nothing else, and the engine refuses one that does. ExecuTorch 1.6 cannot seed a draw
on the GPU, so such a draw cannot be replayed exactly; replays use noise from the host, as the check does.

Saving the noise program with `executorch_tensorrt` needs the `fallback_pytorch_plugin_ops` setting of
pytorch/TensorRT#4953, which Torch-TensorRT 2.15 carries.

A test on a GPU counts every copy between the host and the GPU while the bundle runs: each chunk
copies only the frame to the GPU and the actions back.
shoumikhin added a commit to shoumikhin/lerobot that referenced this pull request Nov 23, 2026
…d drive a robot with the bundle

The export tests compared bundles with their PyTorch policies, mostly
with the PyTorch test backend. Nothing exported the main policies with
every backend that ExecuTorch runs, checked where their programs run, or
ran `lerobot-rollout --bundle.path` on a bundle that a real compiler
wrote.

`tests/export/test_export_backends.py` exports tiny ACT, Diffusion
Policy, pi0, pi0.5, SmolVLA and GR00T checkpoints with
`executorch_xnnpack`, `executorch_cuda` and `executorch_tensorrt`. The
export itself only writes a bundle that reproduces the PyTorch policy's
test case within the bundle's tolerance. Then, for each bundle:

- Each program runs where its backend runs it. Every XNNPACK program
  holds only `XnnpackBackend` delegates, every CUDA program only
  `CudaBackend` ones, and every TensorRT program `TensorRTBackend` or
  `CudaBackend` ones, with `TensorRTBackend` somewhere in the bundle. A
  GPU program leaves no operator on the CPU, and its inputs and outputs
  stay in GPU memory.
- `lerobot-rollout --bundle.path` drives a recording robot for at least
  12 actions, which takes several chunks, in a process that never loads
  PyTorch.

The recording robot can now show a bundle's test case: with
`--robot.frames=<test case file>` it has a camera for each image of the
test case, so a bundle of a policy with cameras can drive it.

Each backend takes its skip mark from `tests/export/backends.py`, so a
row that a released ExecuTorch or Torch-TensorRT cannot run yet skips
and says which fix it needs.

One kind of row fails on every wheel released so far, so it skips up to
the version with the bug and runs again on a newer one: pi0 and pi0.5
with TensorRT. TensorRT 11.4.0.106 cannot build an engine for the tiny
policies' concatenations. The full-size policies build.

Tested on Linux x86_64:

- XNNPACK, on the CPU: all 6 policies, 12 passed.
- CUDA and TensorRT, on an A100, with ExecuTorch 1.6 and Torch-TensorRT
  2.15 built from source, the latter with pytorch/TensorRT#4953: 20
  passed, and the 4 tiny pi0 and pi0.5 TensorRT tests skipped as
  described above.

The export jobs in CI run the XNNPACK and CUDA rows. No CI job
installs Torch-TensorRT yet, so the TensorRT rows skip there.
shoumikhin added a commit to shoumikhin/lerobot that referenced this pull request Nov 24, 2026
lerobot-export compiles a trained policy into a bundle that
`lerobot-rollout --bundle.path=<folder>` runs:

    lerobot-export \
        --policy.path=outputs/train/act_so101/checkpoints/last/pretrained_model \
        --backend.type=executorch_tensorrt

Three pieces, each knowing one thing:

- A recipe knows the policy, never the compiler. It turns the policy into
  parts (a module, example inputs, and the names of its inputs and outputs)
  and makes the test case. The default recipe makes one part that does
  what lerobot-rollout does for one chunk: image conversion, the saved
  preprocessor, predict_action_chunk trimmed to the actions rollout plays,
  and the saved postprocessor. It takes the robot's frame and the starting
  noise, and returns actions in robot units. It covers policies that keep
  the chunk_inference_spec contract, draw a starting noise they take in
  one draw, and compute the same chunk twice from the same frame and noise;
  it refuses others with the reason. A policy that reads the task holds it, tokenized
  once at export. A policy that needs something else adds its own recipe
  in export_<type>.py beside its configuration, and the factory finds it
  there. The pieces a recipe shares (the robot's frame from the policy or
  its dataset, a random frame, the action scale) are plain functions.
- A backend knows the compiler, never the policy. It is a config class
  chosen with --backend.type. executorch_tensorrt compiles each part with
  Torch-TensorRT into an ExecuTorch program whose inputs and outputs stay
  in GPU memory, with TensorRT's TF32 off so float32 stays float32. It
  keeps out of TensorRT any operation whose TensorRT plugin would need
  PyTorch at run time (Torch-TensorRT's fallback_pytorch_plugin_ops), since
  ExecuTorch programs run without PyTorch. That setting comes with
  pytorch/TensorRT#4953 (Torch-TensorRT 2.15). An installed package named lerobot_backend_*
  adds a backend. A backend given with
  --backend.discover_packages_path is loaded in every step that needs it.
- The bundle holds the programs, the manifest (written once, after the
  last part is compiled), the test case, and the policy config as a record.

lerobot-export itself never imports PyTorch. It traces the policy in one
process, compiles each part in a process of its own, and checks the bundle
in another, so each step starts with the memory the one before it used
given back. Like an installed command, each of those processes skips the
current folder when it looks for modules (`python -P`), so a .py file
there, for example in a downloaded checkpoint folder, cannot load in place
of one. The checkpoint loads like in lerobot-rollout, at
--policy.pretrained_revision and with PEFT adapters folded into the base
weights, onto the CPU; the recipe moves what it compiles to the backend's
device. The load is strict: a weight the checkpoint does not fill, or a
PEFT adapter weight missing from its file, would keep its random value, and the export's own check compares the bundle with
that same policy, so it could not tell. PyTorch's TF32 is off in every step, so the test case is the
policy's float32 arithmetic. Each part is traced non-strictly, which is
PyTorch 2.15's default, on every PyTorch: PyTorch 2.7 traces strictly by
default and cannot trace some policies, such as ACT. Tracing and compiling run without autograd,
which nothing there needs and which some of ExecuTorch's passes cannot
record (complex views). The tolerance is in normalized action units:
each action's scale is measured from the saved postprocessor and stored in
the manifest. The bundle is written to a temporary folder, checked in a new
process the way lerobot-rollout checks it, and only then moved to the
output folder. If the actions differ too much, or the check crashes,
nothing is written, and a step that crashes or is killed leaves no folder
behind. The parent folders the export made for the output folder are
removed too, when nothing else is in them. An output folder that appears while the export runs, such as from
a second export to the same folder, is left alone, and this export removes
its own bundle. An output path that is a link, even one to nothing,
counts as taken. A SIGKILL of lerobot-export itself ends it before it can
clean up.

Torch-TensorRT is not added to an extra: it pins one torch minor version,
which uv's single lock would impose on every extra.

The tests export a tiny ACT through the command with a test backend, added
as a plugin package, and check that the bundle plays the same actions as
SyncInferenceEngine, that the command never imports PyTorch, and that a checkpoint missing a
weight is refused, and so is a PEFT adapter missing one. They also run an export from a folder holding .py files
named like modules the steps import, make the output folder while an
export runs, and check that --help writes nothing. The tests also cover the recipe's
task, noise, image, camera and same-chunk rules on small policies, and
check that the plugin setting always reaches Torch-TensorRT, and that a
backend from --backend.discover_packages_path reaches the compile step. Also tested
by hand on NVIDIA GPUs: ACT, SmolVLA and pi0 exported with
executorch_tensorrt and passed the check.
shoumikhin added a commit to shoumikhin/lerobot that referenced this pull request Nov 24, 2026
A policy that starts from a random noise, such as pi0.5, SmolVLA or GR00T, got that noise from the host:
the engine drew it with NumPy and copied it to the GPU for every chunk. On a GPU backend the export now
adds a small program without inputs that draws the noise on the GPU, and the bundle runs it first. So a
chunk copies only the robot's frame to the GPU.

The bundle's own check still gives the test case's recorded noise to the same `noise` input and skips the
draw, so the check against PyTorch does not change. Since the check skips that whole run, a run that draws
the noise must write nothing else, and the engine refuses one that does. ExecuTorch 1.6 cannot seed a draw
on the GPU, so such a draw cannot be replayed exactly; replays use noise from the host, as the check does.

Saving the noise program with `executorch_tensorrt` needs the `fallback_pytorch_plugin_ops` setting of
pytorch/TensorRT#4953, which Torch-TensorRT 2.15 carries.

A test on a GPU counts every copy between the host and the GPU while the bundle runs: each chunk
copies only the frame to the GPU and the actions back.
shoumikhin added a commit to shoumikhin/lerobot that referenced this pull request Nov 24, 2026
…d drive a robot with the bundle

The export tests compared bundles with their PyTorch policies, mostly
with the PyTorch test backend. Nothing exported the main policies with
every backend that ExecuTorch runs, checked where their programs run, or
ran `lerobot-rollout --bundle.path` on a bundle that a real compiler
wrote.

`tests/export/test_export_backends.py` exports tiny ACT, Diffusion
Policy, pi0, pi0.5, SmolVLA and GR00T checkpoints with
`executorch_xnnpack`, `executorch_cuda` and `executorch_tensorrt`. The
export itself only writes a bundle that reproduces the PyTorch policy's
test case within the bundle's tolerance. Then, for each bundle:

- Each program runs where its backend runs it. Every XNNPACK program
  holds only `XnnpackBackend` delegates, every CUDA program only
  `CudaBackend` ones, and every TensorRT program `TensorRTBackend` or
  `CudaBackend` ones, with `TensorRTBackend` somewhere in the bundle. A
  GPU program leaves no operator on the CPU, and its inputs and outputs
  stay in GPU memory.
- `lerobot-rollout --bundle.path` drives a recording robot for at least
  12 actions, which takes several chunks, in a process that never loads
  PyTorch.

The recording robot can now show a bundle's test case: with
`--robot.frames=<test case file>` it has a camera for each image of the
test case, so a bundle of a policy with cameras can drive it.

Each backend takes its skip mark from `tests/export/backends.py`, so a
row that a released ExecuTorch or Torch-TensorRT cannot run yet skips
and says which fix it needs.

One kind of row fails on every wheel released so far, so it skips up to
the version with the bug and runs again on a newer one: pi0 and pi0.5
with TensorRT. TensorRT 11.4.0.106 cannot build an engine for the tiny
policies' concatenations. The full-size policies build.

Tested on Linux x86_64:

- XNNPACK, on the CPU: all 6 policies, 12 passed.
- CUDA and TensorRT, on an A100, with ExecuTorch 1.6 and Torch-TensorRT
  2.15 built from source, the latter with pytorch/TensorRT#4953: 20
  passed, and the 4 tiny pi0 and pi0.5 TensorRT tests skipped as
  described above.

The export jobs in CI run the XNNPACK and CUDA rows. No CI job
installs Torch-TensorRT yet, so the TensorRT rows skip there.
shoumikhin added a commit to shoumikhin/lerobot that referenced this pull request Nov 24, 2026
lerobot-export compiles a trained policy into a bundle that
`lerobot-rollout --bundle.path=<folder>` runs:

    lerobot-export \
        --policy.path=outputs/train/act_so101/checkpoints/last/pretrained_model \
        --backend.type=executorch_tensorrt

Three pieces, each knowing one thing:

- A recipe knows the policy, never the compiler. It turns the policy into
  parts (a module, example inputs, and the names of its inputs and outputs)
  and makes the test case. The default recipe makes one part that does
  what lerobot-rollout does for one chunk: image conversion, the saved
  preprocessor, predict_action_chunk trimmed to the actions rollout plays,
  and the saved postprocessor. It takes the robot's frame and the starting
  noise, and returns actions in robot units. It covers policies that keep
  the chunk_inference_spec contract, draw a starting noise they take in
  one draw, and compute the same chunk twice from the same frame and noise;
  it refuses others with the reason. A policy that reads the task holds it, tokenized
  once at export. A policy that needs something else adds its own recipe
  in export_<type>.py beside its configuration, and the factory finds it
  there. The pieces a recipe shares (the robot's frame from the policy or
  its dataset, a random frame, the action scale) are plain functions.
- A backend knows the compiler, never the policy. It is a config class
  chosen with --backend.type. executorch_tensorrt compiles each part with
  Torch-TensorRT into an ExecuTorch program whose inputs and outputs stay
  in GPU memory, with TensorRT's TF32 off so float32 stays float32. It
  keeps out of TensorRT any operation whose TensorRT plugin would need
  PyTorch at run time (Torch-TensorRT's fallback_pytorch_plugin_ops), since
  ExecuTorch programs run without PyTorch. That setting comes with
  pytorch/TensorRT#4953 (Torch-TensorRT 2.15). An installed package named lerobot_backend_*
  adds a backend. A backend given with
  --backend.discover_packages_path is loaded in every step that needs it.
- The bundle holds the programs, the manifest (written once, after the
  last part is compiled), the test case, and the policy config as a record.

lerobot-export itself never imports PyTorch. It traces the policy in one
process, compiles each part in a process of its own, and checks the bundle
in another, so each step starts with the memory the one before it used
given back. Like an installed command, each of those processes skips the
current folder when it looks for modules (`python -P`), so a .py file
there, for example in a downloaded checkpoint folder, cannot load in place
of one. The checkpoint loads like in lerobot-rollout, at
--policy.pretrained_revision and with PEFT adapters folded into the base
weights, onto the CPU; the recipe moves what it compiles to the backend's
device. The load is strict: a weight the checkpoint does not fill, or a
PEFT adapter weight missing from its file, would keep its random value, and the export's own check compares the bundle with
that same policy, so it could not tell. PyTorch's TF32 is off in every step, so the test case is the
policy's float32 arithmetic. Each part is traced non-strictly, which is
PyTorch 2.15's default, on every PyTorch: PyTorch 2.7 traces strictly by
default and cannot trace some policies, such as ACT. Tracing and compiling run without autograd,
which nothing there needs and which some of ExecuTorch's passes cannot
record (complex views). The tolerance is in normalized action units:
each action's scale is measured from the saved postprocessor and stored in
the manifest. The bundle is written to a temporary folder, checked in a new
process the way lerobot-rollout checks it, and only then moved to the
output folder. If the actions differ too much, or the check crashes,
nothing is written, and a step that crashes or is killed leaves no folder
behind. The parent folders the export made for the output folder are
removed too, when nothing else is in them. An output folder that appears while the export runs, such as from
a second export to the same folder, is left alone, and this export removes
its own bundle. An output path that is a link, even one to nothing,
counts as taken. A SIGKILL of lerobot-export itself ends it before it can
clean up.

Torch-TensorRT is not added to an extra: it pins one torch minor version,
which uv's single lock would impose on every extra.

The tests export a tiny ACT through the command with a test backend, added
as a plugin package, and check that the bundle plays the same actions as
SyncInferenceEngine, that the command never imports PyTorch, and that a checkpoint missing a
weight is refused, and so is a PEFT adapter missing one. They also run an export from a folder holding .py files
named like modules the steps import, make the output folder while an
export runs, and check that --help writes nothing. The tests also cover the recipe's
task, noise, image, camera and same-chunk rules on small policies, and
check that the plugin setting always reaches Torch-TensorRT, and that a
backend from --backend.discover_packages_path reaches the compile step. Also tested
by hand on NVIDIA GPUs: ACT, SmolVLA and pi0 exported with
executorch_tensorrt and passed the check.
shoumikhin added a commit to shoumikhin/lerobot that referenced this pull request Nov 24, 2026
A policy that starts from a random noise, such as pi0.5, SmolVLA or GR00T, got that noise from the host:
the engine drew it with NumPy and copied it to the GPU for every chunk. On a GPU backend the export now
adds a small program without inputs that draws the noise on the GPU, and the bundle runs it first. So a
chunk copies only the robot's frame to the GPU.

The bundle's own check still gives the test case's recorded noise to the same `noise` input and skips the
draw, so the check against PyTorch does not change. Since the check skips that whole run, a run that draws
the noise must write nothing else, and the engine refuses one that does. ExecuTorch 1.6 cannot seed a draw
on the GPU, so such a draw cannot be replayed exactly; replays use noise from the host, as the check does.

Saving the noise program with `executorch_tensorrt` needs the `fallback_pytorch_plugin_ops` setting of
pytorch/TensorRT#4953, which Torch-TensorRT 2.15 carries.

A test on a GPU counts every copy between the host and the GPU while the bundle runs: each chunk
copies only the frame to the GPU and the actions back.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci: full cla signed component: api [C++] Issues re: C++ API component: api [Python] Issues re: Python API component: conversion Issues re: Conversion stage component: converters Issues re: Specific op converters component: core Issues re: The core compiler component: dynamo Issues relating to the `torch.compile` or `torch._dynamo.export` paths component: lowering Issues re: The lowering / preprocessing passes component: runtime component: tests Issues re: Tests documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants