Metadata-Version: 2.4
Name: nablapo
Version: 0.1.0
Summary: NablaPO: first-order policy optimization through exact differentiable simulators (JAX)
Author: The NablaPO Authors
License-Expression: Apache-2.0
Project-URL: Repository, https://github.com/sailab-ai/NablaPO
Classifier: Environment :: GPU :: NVIDIA CUDA :: 12
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
License-File: THIRD_PARTY_NOTICES.md
Requires-Dist: numpy>=2.0
Provides-Extra: jax
Requires-Dist: jax==0.12.0.1; extra == "jax"
Requires-Dist: optax==0.2.8; extra == "jax"
Requires-Dist: mujoco==3.17.0; extra == "jax"
Requires-Dist: mujoco-mjx==3.17.0; extra == "jax"
Requires-Dist: scipy>=1.11; extra == "jax"
Provides-Extra: cuda
Requires-Dist: jax[cuda12]==0.12.0.1; extra == "cuda"
Provides-Extra: engine
Requires-Dist: nablaengine[jax]==1.0.5; extra == "engine"
Provides-Extra: warp
Requires-Dist: warp-lang==1.18.0; extra == "warp"
Provides-Extra: dmc
Requires-Dist: dm_control>=1.0.20; extra == "dmc"
Provides-Extra: brax
Requires-Dist: brax>=0.12; extra == "brax"
Provides-Extra: data
Requires-Dist: huggingface_hub>=0.24; extra == "data"
Provides-Extra: checks
Requires-Dist: pytest>=8; extra == "checks"
Requires-Dist: ruff>=0.6; extra == "checks"
Dynamic: license-file

<h1 align="center">∇PO: Ultra-Efficient Policy Optimization<br>Through Environment Gradients</h1>

<p align="center"><b>Many tasks. Minutes each.</b><br>All trained with ∇PO and the NablaEngine differentiable simulator, on one GPU.</p>

<p align="center">
  <a href="https://arxiv.org/abs/2611.39503"><img alt="Paper" src="https://sailab.ai/nablapo/assets/readme/badge_arxiv.svg" height="36"></a>
  <a href="https://sailab.ai/nablapo/"><img alt="Project page" src="https://sailab.ai/nablapo/assets/readme/badge_page.svg" height="36"></a>
  <a href="https://github.com/sailab-ai/NablaEngine"><img alt="NablaEngine" src="https://sailab.ai/nablapo/assets/readme/badge_engine.svg" height="36"></a>
  <a href="https://github.com/sailab-ai/NablaPO/blob/main/LICENSE"><img alt="License" src="https://sailab.ai/nablapo/assets/readme/badge_license.svg" height="36"></a>
</p>

<p align="center">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="https://sailab.ai/nablapo/assets/readme/tasks_grid_dark.gif?v=2">
    <img src="https://sailab.ai/nablapo/assets/readme/tasks_grid.gif?v=2" width="960" alt="Nine tasks trained with ∇PO, each with its training time: joystick + motion tracking 11 min, motion tracking 5 min, velocity tracking 3 min, BONES-SEED tracking 12.4 min, multi-terrain traversal 5.6 min, humanoid-object interaction 3.2 min, climb with hands 2.8 h, approach, sit, stand up 3.8 h, climbing stairs with a depth camera 32 min">
  </picture>
</p>
<p align="center"><sub>Minutes from the first update to each task's success criterion, on one GPU, mean over seeds. GPUs: A100
(joystick + tracking); RTX PRO 6000 or RTX PRO 6000-equivalent time (the others). Criteria: <a href="https://sailab.ai/nablapo/#tasks">project page</a>.</sub></p>

∇PO (NablaPO, pronounced "Napo") is a first-order policy optimization library: it backpropagates the return through an
exact differentiable simulator ([NablaEngine](https://github.com/sailab-ai/NablaEngine) or a patched MuJoCo Warp), in JAX.

## ✨ Highlights

- **Fast.** One policy for all 40 LAFAN1 clips reaches PPO's 6-hour return in 1.2 minutes on one GPU: 220× faster.
- **Scales.** One policy tracks all 129,418 motions of BONES-SEED: every one of six seeds is below 20 failed motions
  within 12.4 minutes.
- **Exact gradients.** Per-sample gradient clipping and gradient-derived action targets make the simulator's own
  derivatives usable on contact-rich dynamics.
- **One learner, many tasks.** Motion tracking, joystick velocity control, joint joystick and tracking, multi-terrain
  locomotion, humanoid-object interaction and DeepMind Control / Brax tasks, all through one task interface.
- **Powered by NablaEngine.** 2.3M humanoid steps per second with gradients on one RTX PRO 6000.
- **World-model switch.** `[wm] mode = "backward"` replaces the simulator's derivatives with those of a world model fit
  online, on every task.
- **NumPy deployment.** A released policy is a weights file and a JSON specification; it runs with NumPy alone.

## 🏃 ∇Mimic: whole-body motion tracking on LAFAN1

<p align="center">
  <img src="https://sailab.ai/nablapo/assets/readme/results_lafan1.png" width="880" alt="LAFAN1 return against training time for ∇PO, InstantTrack, SuperMimic and PPO: ∇PO reaches 0.866 in 4.4 minutes, 41× faster than SuperMimic's reported 3 hours and 7.5× faster than InstantTrack">
</p>

Training time to reach each return level: **220×** faster than PPO, **41×** faster than SuperMimic's reported 3 hours,
**18.7×** faster than InstantTrack.

| Return level | ∇PO | InstantTrack | SuperMimic | PPO |
|---|---|---|---|---|
| 0.721, PPO's return after 6 hours | **1.2 min** | 1.5 min | 16.1 min | 4.4 h |
| 0.866, SuperMimic's reported 3-hour score | **4.4 min** | 33.2 min | 3 h (paper) | not reached |
| 0.890, InstantTrack's plateau | **8.3 min** | 2.6 h | not reached | not reached |
| 0.938, ∇PO's plateau | **81.4 min** | not reached | not reached | not reached |

<sub>Full-clip return over all 40 LAFAN1 clips, scored in MuJoCo Warp; after a fall the rest of the clip scores zero. 3 seeds
per method, all trained on one RTX PRO 6000. PPO: BeyondMimic's configuration, plateau 0.782. InstantTrack v1.4 and
SuperMimic: official code.</sub>

## 📈 BONES-SEED: 129,418 motions, learned in 12 minutes

<p align="center">
  <img src="https://sailab.ai/nablapo/assets/readme/results_bones.png" width="880" alt="BONES-SEED failed motions against training minutes: ∇PO has 1.4× fewer failed motions than BlinkMimic 2 at 12.6 min (16.5 vs 22.5), is more than 14× faster than SuperMimic and 1.2× faster than BlinkMimic 2 as reported">
</p>
<sub>The full BONES-SEED library, each motion played to the end in MuJoCo Warp; failed: motions with a fall. Lines: median
over seeds; bands: the middle half. Minutes on one RTX PRO 6000 (∇PO trained on a B300, converted at the measured time per
update). BlinkMimic 2: its code and released configuration, 3 seeds; reported: from its README. SuperMimic: read from its
paper's figures. Multipliers: <a href="https://sailab.ai/nablapo/#bones">project page</a>. BONES-SEED data scripts and
training configuration: coming in 0.1.1.</sub>

## 🎛️ Not just humanoids: 16 control benchmarks

<p align="center">
  <img src="https://sailab.ai/nablapo/assets/readme/results_bench.png" width="880" alt="Sixteen DeepMind Control and Brax tasks on one V100: minutes to 80% of peak return for ∇PO and PPO on every task; 16 of 16 reach 80% of peak return faster than PPO, 14 of 16 highest final return, 16 of 16 ahead of SHAC">
</p>
<sub>Minutes: V100 training time until the median seed reaches 80% of the best mean final return among single-configuration
methods. Final return: mean over seeds of 10 deterministic episodes in the original simulator. Some tasks use settings tuned
from the unified recipe. All methods trained in NablaEngine; SHAC and AHAC with their published settings.</sub>

📄 [Paper](https://arxiv.org/abs/2611.39503) · 🌐 [Project page](https://sailab.ai/nablapo/) · ⚙️ [NablaEngine](https://github.com/sailab-ai/NablaEngine)

## 🛠️ Installation

Linux x86_64, an NVIDIA GPU with a CUDA 12 driver, Python 3.12, and the `nvcc` of a CUDA 12.x toolkit (12.8 or newer
for Blackwell GPUs) for NablaEngine's one-time build.

```bash
git clone https://github.com/sailab-ai/NablaPO && cd NablaPO
bash scripts/setup_env.sh      # .venv: pinned versions, patched MuJoCo Warp, Menagerie's G1, NablaEngine, nablapo
source .venv/bin/activate
```

Only the policy loader: `pip install nablapo` (NumPy only). Details: [docs/installation.md](https://github.com/sailab-ai/NablaPO/blob/main/docs/installation.md).

## 🚀 Quick start

```bash
export XLA_PYTHON_CLIENT_PREALLOCATE=false
nablapo-train configs/bench/default.toml --out runs/cheetah --set task.env=cheetah-run    # DeepMind Control

bash scripts/download_lafan1.sh && export LAFAN1_G1_DIR=$PWD/data/lafan1_g1               # LAFAN1 (CC BY-NC-ND 4.0)
nablapo-train configs/demos/tracking_lafan1.toml --out runs/tracking                      # G1 motion tracking
nablapo-train configs/demos/joystick_early.toml --out runs/joystick                       # G1 velocity commands

nablapo-eval runs/tracking                                     # evaluate checkpoints -> runs/tracking/eval_*.json
nablapo-export-policy runs/joystick --out release/joystick     # actor.npz + policy_spec.json
```

Options after the config override it (`--set run.seed=1`); a stopped run continues with `nablapo-train --out DIR
--resume latest`. The demos and their results: [docs/demos.md](https://github.com/sailab-ai/NablaPO/blob/main/docs/demos.md).

## 🤖 Deployment

```python
import nablapo.policy

pol = nablapo.policy.load("release/joystick")    # NumPy only, no simulator
a = pol.act(history, goal)                        # observation history and goal -> action
q = pol.targets(a)                                # joint setpoints for the PD controller
```

The observation layout, PD gains, joint order and control timestep are in `policy_spec.json`
([docs/policy.md](https://github.com/sailab-ai/NablaPO/blob/main/docs/policy.md)). The released policies (the joystick base and the 16 bench policies) follow in a
later release; `src/nablapo/data/models.toml` lists them with the sha256 of every file.

## 📚 Documentation

[docs/README.md](https://github.com/sailab-ai/NablaPO/blob/main/docs/README.md): installation, configuration, writing a task, each task family, the learner,
samplers, WM mode, evaluation, policy format, extensions, and the public API ([docs/api.md](https://github.com/sailab-ai/NablaPO/blob/main/docs/api.md)).

## 📝 Citation

```bibtex
@article{lu2026nablapo,
  title   = {$\nabla$PO: Ultra-Efficient Policy Optimization Through Environment Gradients},
  author  = {Lu, Weyl and Zhu, Gao and Lai, Weijie and Xia, Zaishuo and Chen, Yubei},
  journal = {arXiv preprint arXiv:2611.39503},
  year    = {2026}
}

@article{lu2026nablamimic,
  title   = {$\nabla$Mimic: Ultra-Efficient Humanoid Control with Differentiable Simulation},
  author  = {Lu, Weyl and Chen, Yubei},
  journal = {arXiv preprint arXiv:2610.41654},
  year    = {2026}
}
```

## 🙏 Acknowledgments

Policy averaging, residual actions and the structured residual world model of the WM mode (`it`) with its mirror augmentation follow [InstantTrack](https://github.com/Huy-Quang-Dao/instantTrack).

## 📄 License

Apache License 2.0 (`LICENSE`, `NOTICE`); third-party code, models and data: `THIRD_PARTY_NOTICES.md`.
