Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions docs/sphinx/source/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,23 @@ PyPI 版本变更与未发布变更;发布日期采用 PyPI 上传日期。完

### Added / 新增

- Added `env.mjwarp_overflow_check_interval` (default `0`) using the public
`unisim-core` 2.9.3 capacity diagnostics. When enabled, Manager control steps
flush tensor validation after physics and outside autoreset graph capture, so
contact/constraint capacity errors include the affected environment and
occupancy instead of silently truncating contacts; zero preserves the previous
hot path. Updated both dependency tracks to `unisim-core` 2.9.3 and aligned
MuJoCo/MJWarp 4.1.0 with `mjbatch-uni` 0.3.5; this release also keeps solver
iteration-limit flags distinct from capacity failures
([#2682](https://github.com/Motphys/UniLab/issues/2682)).
新增 `env.mjwarp_overflow_check_interval`(默认 `0`),使用 `unisim-core`
2.9.3 的公共容量诊断接口。启用后,Manager 在物理控制步结束、autoreset graph
捕获段之外 flush tensor validation,使接触/约束容量错误报告受影响的环境和占用量,
不再静默丢弃接触;`0` 保持原有热路径。双依赖轨道同步升级至 `unisim-core`
2.9.3,并对齐 MuJoCo/MJWarp 4.1.0 与 `mjbatch-uni` 0.3.5;该版本还将求解器
迭代上限标志与容量错误区分开
([#2682](https://github.com/Motphys/UniLab/issues/2682))。

- FlashSAC learners on the NVIDIA CUDA whole-cycle path can fuse the non-GEMM
steps of an update into a few kernels with
`algo.algo_params.fuse_learner_steps=true` (off by default): the Adam steps
Expand Down Expand Up @@ -56,6 +73,44 @@ PyPI 版本变更与未发布变更;发布日期采用 PyPI 上传日期。完

### Fixed / 修复

- Reset-state tensor writes now cache root and joint column indices per layout
instead of retaining only the most recent layout. Alternating any number of
layouts no longer repeatedly uploads index tensors, and an uncached layout
encountered during CUDA graph capture raises a `RuntimeError` identifying its
qpos/qvel indices instead of attempting an invalid host-to-device copy
([#2681](https://github.com/Motphys/UniLab/issues/2681)).
reset-state tensor 写入现在按 layout 分别缓存 root 与 joint 列索引,不再只保留
最近使用的 layout。任意多个 layout 交替写入时无需重复上传索引 tensor;CUDA graph
捕获期间遇到未缓存 layout 时,会抛出包含其 qpos/qvel 索引的 `RuntimeError`,不再
尝试非法的 host-to-device 拷贝
([#2681](https://github.com/Motphys/UniLab/issues/2681))。

- Autoreset CUDA graphs now fail closed when a tensor read by the captured
segment changes storage address. The scene read plan records actual body,
sensor, site and custom packet reads through the existing replay-guard
lifecycle, checks them during early replays and on the first replay after
every refresh, and probes device-resident sensor addresses twice at
graph-enabled environment construction
([#2686](https://github.com/Motphys/UniLab/issues/2686)).
autoreset CUDA 图捕获段读取的张量存储地址发生变化时现在会 fail closed。场景
read plan 通过现有 replay guard 生命周期记录实际发生的 body、sensor、site
与自定义 packet 读取,在早期 replay 及每次 refresh 后的首次 replay 前检查地址,
并在启用图的环境构造期对 device-resident sensor 进行两次地址探测
([#2686](https://github.com/Motphys/UniLab/issues/2686))。

- Fixed-shape masked autoreset now accumulates reset row counts and reset-done
phase timings in persistent device buffers and drains them with episode logs
at each finite-validation poll. Non-poll steps use explicit zero placeholders;
CUDA graph replays contribute device-clock phase timings without adding a
hot-path host/device synchronization, while the selected-row path keeps its
per-reset semantics
([#2688](https://github.com/Motphys/UniLab/issues/2688)).
fixed-shape masked autoreset 现在通过 device 侧持久缓冲累加 reset 行数和各阶段
耗时,并在 finite-validation poll 边界与 episode 日志一起发布。非 poll 步使用
明确的零占位;CUDA graph 重放会累计 device-clock 分段耗时,热路径无需新增
host/device 同步;selected-row 路径仍保持逐次 reset 的发布语义
([#2688](https://github.com/Motphys/UniLab/issues/2688))。

- The masked autoreset body executed by Python (the warm-up steps before
capture and any eager fallback) no longer rebinds the public step state to
UniLab's working object when an owner's `update_state` returns its own state
Expand Down
18 changes: 9 additions & 9 deletions docs/sphinx/source/en/1-getting_started/2-installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ live in the getting-started and algorithm pages.
- `uv`, used for dependency sync and command execution.
- Git and `curl`, used to clone the repository and fetch runtime assets.
- For the `mujoco` and `mjwarp` extras: Python `>=3.11` is required by the
MuJoCo 4.0 line. The `mujoco` extra installs the published
`mjbatch-uni==0.3.3` native engine, which provides prebuilt wheels for
MuJoCo 4.1 line. The `mujoco` extra installs the published
`mjbatch-uni==0.3.5` native engine, which provides prebuilt wheels for
CPython 3.11–3.13 on Linux, macOS, and Windows. If a source build is needed,
install a C++17 toolchain and Python development headers:
- macOS: `xcode-select --install`
Expand Down Expand Up @@ -83,7 +83,7 @@ pip install -e .
# pip install .

# MuJoCo (Python >=3.11):
pip install "mujoco~=4.0.1" "mjbatch-uni==0.3.3"
pip install "mujoco~=4.1.0" "mjbatch-uni==0.3.5"
```

The editable install points at the checkout; the regular install copies the
Expand Down Expand Up @@ -120,7 +120,7 @@ claim; use the generated support matrix for the evidence grade of each
algorithm/task/backend combination.

```bash
# Compatible MuJoCo 4.0-line backends:
# Compatible MuJoCo 4.1-line backends:
uv sync --extra mujoco --extra mjwarp --extra genesis --extra motrix --extra mtxwarp

# Newton and SuperDex use MuJoCo 3.11; sync them separately from the set above:
Expand All @@ -130,13 +130,13 @@ uv sync --extra superdex

| Backend | Install path | Important prerequisites |
| --- | --- | --- |
| MuJoCo | `make setup` or `uv sync --extra mujoco` | Python >=3.11; installs prebuilt `mjbatch-uni==0.3.3` wheels where available |
| MuJoCo | `make setup` or `uv sync --extra mujoco` | Python >=3.11; installs prebuilt `mjbatch-uni==0.3.5` wheels where available |
| MJWarp | `uv sync --extra mujoco --extra mjwarp` | Python >=3.11 and NVIDIA CUDA; on a single-GPU host the current CUDA device is used by default, while multi-GPU topology remains explicit |
| Genesis | `uv sync --extra genesis` | Linux x86_64 with NVIDIA CUDA; Linux ROCm uses HIP Torch and exact `gs.amdgpu` (see the ROCm notes) |
| Newton | `uv sync --extra newton` | Linux CUDA with the pinned newton / MuJoCo-Warp / Warp versions; use a separate environment from `mujoco` and `mjwarp` |
| Motrix | `uv sync --extra motrix` | CPU-authoritative MotrixSim with packed Torch HOST_BRIDGE transfers |
| Motrix Warp | `uv sync --extra mtxwarp` | CUDA-resident MotrixSim on Linux x86_64 with NVIDIA CUDA |
| SuperDex | `uv sync --extra superdex` | Python 3.12 or 3.13 on Linux x86_64; scoped to the configured PPO `go2_joystick_flat` owner and separate from the MuJoCo 4.0-line extras |
| SuperDex | `uv sync --extra superdex` | Python 3.12 or 3.13 on Linux x86_64; scoped to the configured PPO `go2_joystick_flat` owner and separate from the MuJoCo 4.1-line extras |
| Drake | `make setup-drake` | Local Drake C++ prefix plus the DrakeUni native batch extension; currently scoped to PPO `go2_joystick_flat` |
| IsaacGym | `bash scripts/tools/setup_isaacgym_env.sh` | Isolated external Python 3.8 IsaacGym Preview 4 worker on Linux CUDA |
| IsaacSim | `bash scripts/tools/setup_isaacsim_env.sh` | Isolated external Python 3.11 IsaacSim/IsaacLab worker on Linux CUDA |
Expand Down Expand Up @@ -183,8 +183,8 @@ If your code imports `uni_rl` directly, see

## Switching The Local MuJoCo Version

On Python 3.11 and newer, the `mujoco` extra declares `mujoco~=4.0.1` and
`mjbatch-uni==0.3.3`. The engine records its build-time mujoco version and
On Python 3.11 and newer, the `mujoco` extra declares `mujoco~=4.1.0` and
`mjbatch-uni==0.3.5`. The engine records its build-time mujoco version and
refuses to import against a different one (see the watchdog row in "Install
Error Signatures"). Switching the local MuJoCo version therefore requires a
compatible `mjbatch` release — it is not a UniLab config change:
Expand Down Expand Up @@ -219,7 +219,7 @@ playback uses the `mjpython` application bundled by the official MuJoCo wheel. T
`cuda` alias resolves to MPS when CUDA is absent.

On Windows, use the direct `uv sync` commands from above unless GNU `make` and
Bash are available. `mjbatch-uni` 0.3.3 publishes Windows wheels, but the
Bash are available. `mjbatch-uni` 0.3.5 publishes Windows wheels, but the
MuJoCo physics backend is not a validated Windows support lane; plain
`mujoco` (MJCF conversion and playback rendering via other backends) still
installs. If you want to use the Makefile, install GNU Make and Bash separately
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,33 @@ the faulty step. Packed-reset failures name the poll step
(`first detected at poll boundary, step N`). To localize a fault, rerun with
`env.finite_validation_interval=1` so every step is a poll boundary.

**Stale diagnostic counters.** On the fixed-shape path the env has no
host-side reset row count or per-phase split. Consequences:

- The per-reset detail keys in `info["timing"]`
(`RESET_DONE_DETAIL_TIMING_KEYS` in `src/unilab/base/backend_timing.py`, for
example `reset_done_count`) are written as `0` on every step. Only
`reset_done_reset_call_ms` is filled. A `0` there does not mean that no row
reset.
- Episode logs (`Episode_Termination/*`, `Episode_Metrics/*` and command reset
metrics) accumulate on the device. They are published into `info["log"]`
only at the deferred-validation poll, and each value covers every episode
that completed since the previous poll. Read them as interval aggregates,
not per-step values.
**Reset diagnostics and episode logs use poll intervals.** Fixed-shape reset
counters and phase timings accumulate in persistent device buffers without a
host read in the step hot path. At each deferred-validation poll,
`RESET_DONE_DETAIL_TIMING_KEYS` in `src/unilab/base/backend_timing.py` are
drained into `info["timing"]` and the accumulators restart from zero:

- `reset_done_count` is the total number of reset rows in the interval. The
other `*_count` keys sum their per-reset invocation counts (for example,
active event terms or sampler dispatches); they are not row counts.
- `*_ms` keys sum phase elapsed time over every fixed-shape reset in the
interval. CPU uses wall-clock spans; eager CUDA combines existing host owner
timings with device spans; captured CUDA uses device-clock spans for every
published env-owned phase, including graph replays. The outer
`reset_done_reset_call_ms` overlaps its nested phases by design.
- Steps between polls publish `0` for every detail key as a no-publication
placeholder. Do not interpret those zeros as an empty interval. At a poll,
zero instead means no accumulated work or that the key has no producer on
the current path (the same N/A convention as the selected-row schema).
Backend-returned host-only nested `set_state_*` sub-timings cannot be
replayed by a CUDA graph and stay N/A there; use the device-timed
`dr_reset_set_state_ms` and higher-level reset phases for graph attribution.

Episode logs (`Episode_Termination/*`, `Episode_Metrics/*` and command reset
metrics) drain at the same poll into `info["log"]`. Each value covers every
episode that completed since the previous poll, not just the current step.
With `autoreset_cuda_graph=false`, the selected-row lifecycle and its per-reset
publication semantics are unchanged.

**Host state under graph replay.** A CUDA graph replays device work only. Python
state that the reset segment changes, such as a pending-metrics flag or a host
Expand All @@ -119,6 +133,22 @@ lower bound, must be declared with
re-applies these transitions after every replay. Undeclared host state keeps the
value it had at capture time.

**Tensor addresses under graph replay.** A CUDA graph records the storage
address of every tensor read by the captured segment. Read-plan packet tensors,
including named sensors, body blocks, site carriers, joint state and custom term
packet reads, must keep the same address across refreshes and replays; refresh
their values in place rather than rebinding the packet to a new tensor. A tensor
created afresh on every step is capture-safe only when it is both created and
consumed inside the captured segment.

When `autoreset_cuda_graph` is enabled, the read plan probes each device-resident
sensor across two construction-time refreshes and rejects unstable storage.
During capture it records the packet and site-carrier addresses actually read.
The existing replay-guard lifecycle compares them during early replays and on
the first replay after every refresh, and raises `GraphCaptureError` before
replay if an address changes. The guard checks addresses only; it does not synchronize or read tensor
values from the device.

## Step-output ownership

On both the eager and fixed-shape paths, `state.obs`, `state.reward`,
Expand Down
6 changes: 3 additions & 3 deletions docs/sphinx/source/en/2-user_guide/3-backends/1-mujoco.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

MuJoCo is the default backend path in the committed owner configs. On Python
3.11 and newer, the `mujoco` extra installs the official `mujoco` package
(`~=4.0.1`) plus the published `mjbatch-uni==0.3.3` native batch engine, with
(`~=4.1.0`) plus the published `mjbatch-uni==0.3.5` native batch engine, with
exact versions pinned by the committed `uv.lock`. Python 3.10 is not a supported
backend lane: dependency markers leave the extra empty and the runtime fails
closed. The adapter lives under `unisim.backend.mujoco`.
Expand Down Expand Up @@ -30,8 +30,8 @@ rather than opening the Motrix native interactive renderer.

## Switching MuJoCo Versions

On Python 3.11 and newer, pyproject constrains `mujoco~=4.0.1` and pins
`mjbatch-uni==0.3.3`; the committed `uv.lock` pins the exact default versions,
On Python 3.11 and newer, pyproject constrains `mujoco~=4.1.0` and pins
`mjbatch-uni==0.3.5`; the committed `uv.lock` pins the exact default versions,
and uv's prefer-locked semantics keep ordinary relocks from drifting. The
`mjbatch` engine records its build-time `mujoco` version and refuses to import
against a different one (fail-closed, never a silent behavior change).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ The extra pins `newton==1.5.1`, `mujoco-warp==3.11.0`, and `mujoco==3.11.0`
exactly, requires `warp-lang>=1.16.0` (resolved to 1.17.0 in `uv.lock`), and
includes the native ViewerGL dependencies (`pyglet>=2.1.6,<3`,
`imgui-bundle>=1.92.0`). The `mujoco` and `mjwarp` extras
now use the MuJoCo 4.0.1 line, so their dependency resolver declarations are
now use the MuJoCo 4.1.0 line, so their dependency resolver declarations are
explicitly mutually exclusive with `newton`. Install Newton in a separate
environment; do not combine it with the `mujoco` or `mjwarp` extra.

Expand Down
18 changes: 9 additions & 9 deletions docs/sphinx/source/zh_CN/1-getting_started/2-installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
- Python `>=3.10,<3.14`,来自 `pyproject.toml`。
- `uv`,用于依赖同步和命令执行。
- Git 和 `curl`,用于克隆仓库及下载 runtime asset。
- 使用 `mujoco` 和 `mjwarp` extra 时:MuJoCo 4.0 版本线要求 Python `>=3.11`。
`mujoco` extra 安装发布版 `mjbatch-uni==0.3.3` 原生引擎,其为 Linux、
- 使用 `mujoco` 和 `mjwarp` extra 时:MuJoCo 4.1 版本线要求 Python `>=3.11`。
`mujoco` extra 安装发布版 `mjbatch-uni==0.3.5` 原生引擎,其为 Linux、
macOS 和 Windows 上的 CPython 3.11–3.13 提供预编译 wheel。若需要从源码
构建,请安装 C++17 工具链和 Python 开发头文件:
- macOS:`xcode-select --install`
Expand Down Expand Up @@ -77,7 +77,7 @@ pip install -e .
# pip install .

# 需要 MuJoCo 时(Python >=3.11):
pip install "mujoco~=4.0.1" "mjbatch-uni==0.3.3"
pip install "mujoco~=4.1.0" "mjbatch-uni==0.3.5"
```

editable install 会指向源码 checkout;常规安装会把 package 和任务配置
Expand Down Expand Up @@ -108,7 +108,7 @@ Hugging Face endpoint 无法访问时,可设置 `HF_ENDPOINT=https://hf-mirror
证据等级请查看生成的支持矩阵。

```bash
# 可组合的 MuJoCo 4.0 版本线后端:
# 可组合的 MuJoCo 4.1 版本线后端:
uv sync --extra mujoco --extra mjwarp --extra genesis --extra motrix --extra mtxwarp

# Newton 和 SuperDex 使用 MuJoCo 3.11,需与上面一组分开同步:
Expand All @@ -118,13 +118,13 @@ uv sync --extra superdex

| 后端 | 安装路径 | 重要前置条件 |
| --- | --- | --- |
| MuJoCo | `make setup` 或 `uv sync --extra mujoco` | Python >=3.11;在可用平台上安装预编译 `mjbatch-uni==0.3.3` wheel |
| MuJoCo | `make setup` 或 `uv sync --extra mujoco` | Python >=3.11;在可用平台上安装预编译 `mjbatch-uni==0.3.5` wheel |
| MJWarp | `uv sync --extra mujoco --extra mjwarp` | Python >=3.11 与 NVIDIA CUDA;单 GPU 主机默认使用当前 CUDA 设备,多卡拓扑仍需显式配置 |
| Genesis | `uv sync --extra genesis` | Linux x86_64 + NVIDIA CUDA;Linux ROCm 使用 HIP Torch 和 exact `gs.amdgpu`(见下方 ROCm 说明) |
| Newton | `uv sync --extra newton` | Linux CUDA,并钉定 newton / MuJoCo-Warp / Warp 版本;需与 `mujoco`、`mjwarp` 使用独立环境 |
| Motrix | `uv sync --extra motrix` | CPU-authoritative MotrixSim 与 packed Torch HOST_BRIDGE 传输 |
| Motrix Warp | `uv sync --extra mtxwarp` | Linux x86_64 + NVIDIA CUDA 上的 CUDA-resident MotrixSim |
| SuperDex | `uv sync --extra superdex` | Linux x86_64 上的 Python 3.12 或 3.13;当前 scoped 到已配置的 PPO `go2_joystick_flat` owner,并与 MuJoCo 4.0 版本线 extras 分开安装 |
| SuperDex | `uv sync --extra superdex` | Linux x86_64 上的 Python 3.12 或 3.13;当前 scoped 到已配置的 PPO `go2_joystick_flat` owner,并与 MuJoCo 4.1 版本线 extras 分开安装 |
| Drake | `make setup-drake` | 本地 Drake C++ 前缀与 DrakeUni native batch extension;当前 scoped 到 PPO `go2_joystick_flat` |
| IsaacGym | `bash scripts/tools/setup_isaacgym_env.sh` | Linux CUDA 上隔离的外部 Python 3.8 IsaacGym Preview 4 worker |
| IsaacSim | `bash scripts/tools/setup_isaacsim_env.sh` | Linux CUDA 上隔离的外部 Python 3.11 IsaacSim/IsaacLab worker |
Expand Down Expand Up @@ -167,8 +167,8 @@ extra(例如从 `mujoco` 换到 `newton`)不会再卸载训练栈,

## 切换本地 MuJoCo 版本

在 Python 3.11 及更高版本上,`mujoco` extra 声明 `mujoco~=4.0.1` 和
`mjbatch-uni==0.3.3`。引擎会记录编译时的 mujoco 版本,加载时检测到不一致
在 Python 3.11 及更高版本上,`mujoco` extra 声明 `mujoco~=4.1.0` 和
`mjbatch-uni==0.3.5`。引擎会记录编译时的 mujoco 版本,加载时检测到不一致
会拒绝导入(见「安装错误特征对照表」中的 watchdog 行)。因此切换本地
MuJoCo 版本需要兼容的 `mjbatch` 发布版本,而不是修改 UniLab 配置:

Expand Down Expand Up @@ -200,7 +200,7 @@ wheel 来源是在 `pyproject.toml` 中配置的 PyTorch `cu130` 索引。
没有 CUDA 时,`cuda` alias 会解析到 MPS。

在 Windows 上,如果没有 GNU `make` 和 Bash,请使用上面的直接 `uv sync` 命令。
`mjbatch-uni` 0.3.3 已发布 Windows wheel,但 MuJoCo 物理后端尚未形成经过验证的
`mjbatch-uni` 0.3.5 已发布 Windows wheel,但 MuJoCo 物理后端尚未形成经过验证的
Windows 支持通道;纯 `mujoco`(MJCF 转换、其他后端的回放渲染)仍可安装。
如果要使用 Makefile,请另行安装 GNU Make 和 Bash(例如通过 Chocolatey 或 WSL)。

Expand Down
Loading
Loading