Metadata-Version: 2.4
Name: leapp
Version: 0.8.0
Summary: LEAPP - Lightweight Export Annotations for Policy Pipelines: A Python package for tracing and exporting computational graphs from PyTorch code
Author-email: Frank Lai <frlai@nvidia.com>
Maintainer-email: Frank Lai <frlai@nvidia.com>
License-Expression: Apache-2.0
Project-URL: Homepage, https://nvidia-isaac.github.io/leapp/
Project-URL: Repository, https://github.com/nvidia-isaac/leapp
Project-URL: Issues, https://github.com/nvidia-isaac/leapp/issues
Keywords: machine-learning,pytorch,robotics,policy-pipelines,graph-export
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: torch>=2.7.0
Requires-Dist: PyYAML>=6.0
Requires-Dist: onnx>=1.19.0
Requires-Dist: onnxruntime<1.24,>=1.20.0; python_version < "3.11"
Requires-Dist: onnxruntime>=1.20.0; python_version >= "3.11"
Requires-Dist: onnxscript>=0.1.0
Requires-Dist: safetensors>=0.5.0
Requires-Dist: fast-sugiyama>=0.5.3; python_version >= "3.11"
Requires-Dist: Pillow>=10.0.0; python_version >= "3.11"
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: ruff==0.17.1; extra == "dev"
Requires-Dist: flake8; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Provides-Extra: test
Requires-Dist: warp-lang>=1.18; extra == "test"
Requires-Dist: opencv-python-headless>=4.8; extra == "test"
Provides-Extra: warp-cu12
Requires-Dist: warp-lang>=1.18; extra == "warp-cu12"
Requires-Dist: cupti-python<13,>=12.8; sys_platform == "linux" and extra == "warp-cu12"
Requires-Dist: onnxruntime-gpu[cuda,cudnn]<1.24,>=1.20.0; python_version < "3.11" and extra == "warp-cu12"
Requires-Dist: onnxruntime-gpu[cuda,cudnn]<1.27,>=1.20.0; python_version >= "3.11" and extra == "warp-cu12"
Provides-Extra: warp-cu13
Requires-Dist: warp-lang>=1.18; extra == "warp-cu13"
Requires-Dist: cupti-python<14,>=13; sys_platform == "linux" and extra == "warp-cu13"
Requires-Dist: onnxruntime-gpu[cuda,cudnn]>=1.27.0; python_version >= "3.11" and extra == "warp-cu13"
Dynamic: license-file

<!--
SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: Apache-2.0
-->

# LEAPP: Lightweight Export Annotations for Policy Pipelines

[Full Isaac LEAPP docs](https://nvidia-isaac.github.io/leapp/)

**Export the policy code you already run: preprocessing, model inference, and action processing together.**

Isaac LEAPP is NVIDIA's library for machine learning pipeline export. It traces supported PyTorch and NumPy computation across existing functions and objects. Export the complete path as **one ONNX, TorchScript, or PT2 model**, or choose separate stages when useful.

Input and output annotations capture computation as your application runs. A single model can capture computation across multiple input call sites, helper functions, and class methods. The annotations work directly in application code without a prescribed RL environment interface. [See annotation patterns](https://nvidia-isaac.github.io/leapp/guides/nodes.html).

- **Keep processing with the policy.** Capture supported NumPy preprocessing, conversions into PyTorch, and action transforms together. [Warp kernel regions](https://nvidia-isaac.github.io/leapp/tensor_libraries/warp.html) can also be captured into ONNX or PT2 with an additional runtime adapter.
- **Adapt unsupported calls with [FunctionPatch](https://nvidia-isaac.github.io/leapp/guides/patching.html).** Register a faithful replacement built from supported operations; existing module-level callers can stay in place.
- **Describe the deployment interface.** Attach tensor roles, joint names, and timing information with [semantic metadata](https://nvidia-isaac.github.io/leapp/semantics/usage.html), so downstream applications can interpret model inputs and outputs.
- **Inspect and validate the export.** Compare exported outputs, including state updates, against cached samples from consecutive Python iterations. Configure sample coverage, inspect the graph, and use [sequential replay](https://nvidia-isaac.github.io/leapp/guides/debugging.html#stateful-transitions-and-sequential-replay) to check accumulated drift and runtime feedback.

## Quick start

```bash
pip install leapp
```

Requires Python 3.10+ and PyTorch 2.7.0+.

This example exports NumPy preprocessing, a small PyTorch policy, and action scaling and clipping together:

```python
import numpy as np
import torch
import leapp
from leapp import annotate

def make_observation(position, velocity):
    return np.concatenate([np.clip(position, -1.0, 1.0), velocity * 0.1])

policy = torch.nn.Sequential(
    torch.nn.Linear(12, 32), torch.nn.Tanh(), torch.nn.Linear(32, 6),
).eval()

leapp.start(name="robot_policy")
position, velocity = annotate.input_tensors("control", {
    "position": np.zeros(6, dtype=np.float32),
    "velocity": np.ones(6, dtype=np.float32),
})

with torch.no_grad():
    observation = torch.from_numpy(make_observation(position, velocity))
    targets = torch.clamp(policy(observation) * 0.25, -1.0, 1.0)

annotate.output_tensors("control", {"targets": targets}, export_with="onnx")

leapp.stop()
leapp.compile_graph(validate=True)
```

Produces **`robot_policy/control.onnx`**, a YAML interface specification, and a graph PNG on Python 3.11+. This stateless model runs directly in ONNX Runtime; [InferenceManager](https://nvidia-isaac.github.io/leapp/leapp_runtime.html) loads the bundle for Python replay. Other applications can consume the exported artifacts through their chosen backend runtime.

## Capture scope

LEAPP captures the executed tensor path. Data-dependent Python branches are not preserved dynamically, and unsupported operations or scalar extraction can freeze values. Check tracing warnings and validate on fresh inputs. See [PyTorch](https://nvidia-isaac.github.io/leapp/tensor_libraries/torch_limitations.html) and [NumPy](https://nvidia-isaac.github.io/leapp/tensor_libraries/limitations.html) limitations.

[Getting started](https://nvidia-isaac.github.io/leapp/getting_started.html) · [Export options](https://nvidia-isaac.github.io/leapp/guides/export.html) · [API reference](https://nvidia-isaac.github.io/leapp/api/index.html)

## License

Copyright (c) 2026, NVIDIA Corporation & affiliates. Licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE) and [thirdparty.txt](thirdparty.txt).
