Skip to content

Cache scene selections with automatic Torch dispatch - #8087

Merged
StafaH merged 10 commits into
isaac-sim:developfrom
StafaH:perf/scene-indices-proxy
Sep 28, 2026
Merged

StafaH merged 10 commits into
isaac-sim:developfrom
StafaH:perf/scene-indices-proxy

Conversation

@StafaH

@StafaH StafaH commented Sep 27, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Finalize resolved scene-entity selections to device tensors, following Newton's build-then-finalize model. Manager terms index with the existing *_ids fields and no longer upload indices or synchronize CUDA on every call. No second field or helper is needed.

Alternative A to #8088, which adds separate *_ids_torch fields. Related: #8039, #8089.

Design

  • Build: SceneEntityCfg.resolve(scene) is unchanged. It fills joint_ids, body_ids, fixed_tendon_ids, and object_collection_ids with host lists. Class-based terms can read these lists in __init__.
  • Finalize: once every term is constructed, ManagerBase calls the new SceneEntityCfg.finalize(device) on the configurations it resolved. Each list becomes a torch.long tensor on the simulation device, shared by the terms that use it, and slices stay slices. Finalization is one-way, and calling it again does nothing. Configurations resolved outside managers, such as by action or command terms, are left unchanged.
  • Consumers: term calls use data[:, cfg.joint_ids] and pass cfg.joint_ids to asset write methods as before. Tensors compare unequal to slice(None), so the existing ids == slice(None) checks continue to work.
  • No per-step host reads: a scalar selection such as data[:, cfg.body_ids[0]] would read a CUDA tensor back to the host, so these reads become device gathers: data[:, cfg.body_ids][:, 0]. Event terms that previously rebuilt index tensors on each call now use the finalized tensors directly; every backend accepts int64 index tensors.
  • Scope: 13 files, all in isaaclab and isaaclab_tasks. Backend asset APIs, isaaclab_experimental (whose managers are a separate implementation), and serialization helpers are unchanged.

Why tensors rather than ProxyArray or a wrapper

Design Call site joint_pos (µs/call) joint_pos_limits (µs/call) Syncs/call
develop (host lists) data[:, cfg.joint_ids] 383 † 1470–1566 † 1 / 4
Previous revision: IndexSequence wrapper data[:, cfg.joint_ids] 8.45–8.50 64.4–65.7 0
#8088: separate *_ids_torch data[:, cfg.joint_ids_torch] 5.34–5.99 47.95–48.83 0
This PR: finalized tensors data[:, cfg.joint_ids] 5.32–6.38 48.00–49.19 0

Finalized tensors match #8088 with a single field. A finalized ProxyArray was also prototyped. Indexing with it directly cost about 2 µs more per index (7.7 µs vs. 5.3–6.1 µs), because it dispatches through ProxyArray's deprecated Torch bridge, and asset write methods reject it. It would therefore need an explicit accessor at every call site. No consumer used its Warp view.

Benchmark: RTX PRO 6000 Blackwell, PyTorch 2.12.0+cu130. Real joint_pos observation and joint_pos_limits reward, (4096, 32) CUDA data, joints [15, 2, 29, 5, 22, 11, 30, 0]. Each fresh process ran 200 warmup calls, then five blocks of 2,000 calls. Figures are median block times from two or more processes per design, run in alternating order. Synchronizations were counted with PyTorch's sync-debug mode.

† The GPU was fully utilized by unrelated processes during these runs, which inflates develop's synchronizing path. On an idle GPU, the same benchmark previously measured develop at 13.05–13.11 µs. The synchronization-free designs are CPU-bound and are comparable with one another.

Type of change

  • New feature
  • Breaking change: term calls receive finalized torch.long tensors instead of host lists. Migration:
    • Replace per-step scalar reads such as data[:, cfg.body_ids[0]] with data[:, cfg.body_ids][:, 0], or read host values in the term's __init__.
    • Replace torch.tensor(cfg.body_ids) with cfg.body_ids; the finalized selection is already a device tensor.
    • Replace isinstance(ids, list) checks with isinstance(ids, slice).
    • Class terms can still read host lists in __init__.
  • Documentation update

Validation

  • 206 focused tests passed: managers (event, observation, reward, termination, base, scene selection), dict, configclass, wrench composer, gravity observations, and Lift configuration.
  • New tests cover:
    • finalization of ordering, slices, empty selections, and copies;
    • that class terms see host lists while term calls see device tensors, whether the manager is created while the simulation is playing or deferred until physics is ready;
    • a real joint_pos consumer and a device gather under CUDA sync-debug error mode;
    • external-force sizing for a finalized body subset.
  • All six new tests fail when finalize is disabled.
  • Newton/MJWarp runtime smoke tests passed with 64 environments, seed 42, 20 warmup and 100 measured steps, and no renderer, for Isaac-Lift-KukaAllegro, Isaac-Velocity-Flat-AnymalD, and Isaac-Open-Drawer-Franka. The last exercises the changed drawer-joint gather. No implicit ProxyArray deprecation warnings were emitted.
  • uv run --frozen isaaclab -f passed, including changelog checks.
  • Not run: the full documentation build, PhysX/OVPhysX runtime, and test_recorder_manager_integration (requires full Isaac Sim).

Reproduce the smoke test:

uv run --frozen isaaclab benchmark runtime \
  --task Isaac-Lift-KukaAllegro --num_envs 64 --num_steps 100 \
  --warmup_steps 20 --seed 42 --device cuda:0 --visualizer none \
  --output_path /tmp/scene-selector-smoke physics=newton_mjwarp

Known limitations

  • Serializing a finalized configuration emits tensors for its selections, following the existing class_to_dict tensor handling. No code in this repository serializes term configurations after finalization.
  • Finalized tensors are read-only by convention. Calling resolve() after finalize() is unsupported.
  • A few class terms copy selection fields in __init__ and therefore keep the host list or their own tensor. Two of these, NIST reset_end_effector_around_asset and PhysX randomize_rigid_body_material, keep host lists: the first can adopt the finalized tensor in a follow-up, while the second iterates backend body IDs on the CPU and should stay on the host.

Release backport

  • Backport this pull request to the active release branch after it merges into develop

Checklist

  • I have read and understood the contribution guidelines.
  • I have run the pre-commit checks with uv run --frozen isaaclab -f.
  • I have made corresponding changes to the documentation.
  • I have added tests that prove the behavior and checked them against the change disabled.
  • I have added a changelog fragment for every touched source package.
  • My name already exists in CONTRIBUTORS.md.

@github-actions github-actions Bot added documentation Improvements or additions to documentation isaac-lab Related to Isaac Lab team labels Sep 27, 2026
Replace the IndexSequence wrapper with a Newton-style build-then-finalize
lifecycle. SceneEntityCfg.resolve keeps host lists for term construction;
managers call SceneEntityCfg.finalize once all terms exist, replacing each
list with an int64 ProxyArray on the device. Slices stay slices. Term calls
index through torch_index, and per-step scalar reads become device gathers.
Store finalized selections as torch.long tensors so term calls and asset
write methods use SceneEntityCfg fields directly. Remove torch_index, and
the ProxyArray serialization and copy support that only it required.
Plain tensors compare unequal to slice(None) and are accepted by asset
write methods, so restore the original call sites and only switch
per-call torch.tensor copies to torch.as_tensor. Inline the finalized
field list and simplify the selection tests.
@StafaH StafaH changed the title Cache scene selections with automatic Torch dispatch (alternative A) Finalize scene-entity selections to device tensors (alternative A) Sep 27, 2026
@StafaH StafaH changed the title Finalize scene-entity selections to device tensors (alternative A) Cache scene selections with automatic Torch dispatch Sep 27, 2026
@StafaH
StafaH marked this pull request as ready for review September 27, 2026 23:20
@StafaH
StafaH requested a review from a team September 27, 2026 23:20
@StafaH

StafaH commented Sep 27, 2026

Copy link
Copy Markdown
Collaborator Author

run-ci

@isaaclab-bot isaaclab-bot Bot added ci:run-docker Trigger the on-demand Docker and GPU CI workflow and removed ci:run-docker Trigger the on-demand Docker and GPU CI workflow labels Sep 27, 2026
@greptile-apps

greptile-apps Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[High risk] Changes how scene selections are indexed throughout the codebase.

The PR should not merge until tensor inputs accepted by the new selection types can be resolved without failing manager construction.

Findings

  1. P1 Tensor inputs fail resolution ▶
  2. P2 Existing tensors skip normalization ▶
  3. P2 Index copies remain per call ▶

Summary

The PR finalizes manager-resolved scene selections into device tensors after term construction and updates MDP consumers to gather without scalar host reads.

  • Supports both managers created while physics is playing and those resolved when physics becomes ready.
  • Extends selection types and updates event and task consumers for the new representation.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Resolve scene selections as host lists] --> B[Construct manager terms]
  B --> C[Finalize selections on simulation device]
  C --> D[Term calls index with selections]
Loading

Reviews (1) · Last reviewed commit: "Merge branch 'develop' into perf/scene-i..."

Finalized selections are already int64 device tensors, which every backend
index-kernel dispatcher accepts, so event terms no longer convert them.
The actuator-equivalence helper finalizes its term's selection, matching
the manager lifecycle.

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Isaac Lab Review Bot

The build-then-finalize lifecycle consistently converts manager-resolved scene selections to device tensors after class-term construction. One public contract detail needs correction: finalized tensors are documented as read-only, but the implementation stores ordinary mutable tensors.

  • Design and architecture: ManagerBase finalizes collected SceneEntityCfg instances after term construction in both immediate and deferred resolution paths, preserving host-list access during class-term initialization. No architectural issue was identified with that sequencing.
  • API: The runtime type change is reflected in annotations, API documentation, and migration notes. However, finalize() and the API documentation promise read-only tensors even though PyTorch tensors remain writable; this must be described as a caller convention or enforced by the implementation.
  • Implementation: The updated gather, conversion, and slice-handling paths support finalized tensor selections. Because torch.as_tensor may retain the same tensor object, in-place consumer mutation can alter the shared configuration, directly contradicting the documented read-only guarantee.

Minor fixes needed. Posted 1 actionable finding inline.

Automated review; human maintainers own approval decisions.

Document that finalized selections are shared tensors callers must not
modify, that tensors are not a configuration input, and update the
migration note to use finalized selections directly.
Mass, inertia, and CoM randomization expanded slice(None) into an arange so
env rows could always be broadcast as a column. Broadcast env rows only when
body indices are a tensor, as the joint and tendon terms already do, so
slices index directly and reach the backend setters unchanged.
@StafaH

StafaH commented Sep 28, 2026

Copy link
Copy Markdown
Collaborator Author

run-ci

@isaaclab-bot isaaclab-bot Bot added ci:run-docker Trigger the on-demand Docker and GPU CI workflow and removed ci:run-docker Trigger the on-demand Docker and GPU CI workflow labels Sep 28, 2026
@StafaH
StafaH merged commit 10fdf81 into isaac-sim:develop Sep 28, 2026
53 checks passed
isaaclab-bot Bot pushed a commit that referenced this pull request Sep 28, 2026
# Description

Finalize resolved scene-entity selections to device tensors, following
Newton's build-then-finalize model. Manager terms index with the
existing `*_ids` fields and no longer upload indices or synchronize CUDA
on every call. No second field or helper is needed.

Alternative A to #8088, which adds separate `*_ids_torch` fields.
Related: #8039, #8089.

## Design

- **Build:** `SceneEntityCfg.resolve(scene)` is unchanged. It fills
`joint_ids`, `body_ids`, `fixed_tendon_ids`, and `object_collection_ids`
with host lists. Class-based terms can read these lists in `__init__`.
- **Finalize:** once every term is constructed, `ManagerBase` calls the
new `SceneEntityCfg.finalize(device)` on the configurations it resolved.
Each list becomes a `torch.long` tensor on the simulation device, shared
by the terms that use it, and slices stay slices. Finalization is
one-way, and calling it again does nothing. Configurations resolved
outside managers, such as by action or command terms, are left
unchanged.
- **Consumers:** term calls use `data[:, cfg.joint_ids]` and pass
`cfg.joint_ids` to asset write methods as before. Tensors compare
unequal to `slice(None)`, so the existing `ids == slice(None)` checks
continue to work.
- **No per-step host reads:** a scalar selection such as `data[:,
cfg.body_ids[0]]` would read a CUDA tensor back to the host, so these
reads become device gathers: `data[:, cfg.body_ids][:, 0]`. Event terms
that previously rebuilt index tensors on each call now use the finalized
tensors directly; every backend accepts int64 index tensors.
- **Scope:** 13 files, all in `isaaclab` and `isaaclab_tasks`. Backend
asset APIs, `isaaclab_experimental` (whose managers are a separate
implementation), and serialization helpers are unchanged.

### Why tensors rather than `ProxyArray` or a wrapper

| Design | Call site | `joint_pos` (µs/call) | `joint_pos_limits`
(µs/call) | Syncs/call |
| --- | --- | ---: | ---: | ---: |
| develop (host lists) | `data[:, cfg.joint_ids]` | 383 † | 1470–1566 †
| 1 / 4 |
| Previous revision: `IndexSequence` wrapper | `data[:, cfg.joint_ids]`
| 8.45–8.50 | 64.4–65.7 | 0 |
| #8088: separate `*_ids_torch` | `data[:, cfg.joint_ids_torch]` |
5.34–5.99 | 47.95–48.83 | 0 |
| **This PR: finalized tensors** | `data[:, cfg.joint_ids]` |
**5.32–6.38** | **48.00–49.19** | 0 |

Finalized tensors match #8088 with a single field. A finalized
`ProxyArray` was also prototyped. Indexing with it directly cost about 2
µs more per index (7.7 µs vs. 5.3–6.1 µs), because it dispatches through
`ProxyArray`'s deprecated Torch bridge, and asset write methods reject
it. It would therefore need an explicit accessor at every call site. No
consumer used its Warp view.

Benchmark: RTX PRO 6000 Blackwell, PyTorch 2.12.0+cu130. Real
`joint_pos` observation and `joint_pos_limits` reward, `(4096, 32)` CUDA
data, joints `[15, 2, 29, 5, 22, 11, 30, 0]`. Each fresh process ran 200
warmup calls, then five blocks of 2,000 calls. Figures are median block
times from two or more processes per design, run in alternating order.
Synchronizations were counted with PyTorch's sync-debug mode.

† The GPU was fully utilized by unrelated processes during these runs,
which inflates develop's synchronizing path. On an idle GPU, the same
benchmark previously measured develop at 13.05–13.11 µs. The
synchronization-free designs are CPU-bound and are comparable with one
another.

## Type of change

- New feature
- Breaking change: term calls receive finalized `torch.long` tensors
instead of host lists. Migration:
- Replace per-step scalar reads such as `data[:, cfg.body_ids[0]]` with
`data[:, cfg.body_ids][:, 0]`, or read host values in the term's
`__init__`.
- Replace `torch.tensor(cfg.body_ids)` with `cfg.body_ids`; the
finalized selection is already a device tensor.
- Replace `isinstance(ids, list)` checks with `isinstance(ids, slice)`.
  - Class terms can still read host lists in `__init__`.
- Documentation update

## Validation

- 206 focused tests passed: managers (event, observation, reward,
termination, base, scene selection), dict, configclass, wrench composer,
gravity observations, and Lift configuration.
- New tests cover:
  - finalization of ordering, slices, empty selections, and copies;
- that class terms see host lists while term calls see device tensors,
whether the manager is created while the simulation is playing or
deferred until physics is ready;
- a real `joint_pos` consumer and a device gather under CUDA sync-debug
`error` mode;
  - external-force sizing for a finalized body subset.
- All six new tests fail when `finalize` is disabled.
- Newton/MJWarp runtime smoke tests passed with 64 environments, seed
42, 20 warmup and 100 measured steps, and no renderer, for
`Isaac-Lift-KukaAllegro`, `Isaac-Velocity-Flat-AnymalD`, and
`Isaac-Open-Drawer-Franka`. The last exercises the changed drawer-joint
gather. No implicit `ProxyArray` deprecation warnings were emitted.
- `uv run --frozen isaaclab -f` passed, including changelog checks.
- Not run: the full documentation build, PhysX/OVPhysX runtime, and
`test_recorder_manager_integration` (requires full Isaac Sim).

Reproduce the smoke test:

```bash
uv run --frozen isaaclab benchmark runtime \
  --task Isaac-Lift-KukaAllegro --num_envs 64 --num_steps 100 \
  --warmup_steps 20 --seed 42 --device cuda:0 --visualizer none \
  --output_path /tmp/scene-selector-smoke physics=newton_mjwarp
```

## Known limitations

- Serializing a finalized configuration emits tensors for its
selections, following the existing `class_to_dict` tensor handling. No
code in this repository serializes term configurations after
finalization.
- Finalized tensors are read-only by convention. Calling `resolve()`
after `finalize()` is unsupported.
- A few class terms copy selection fields in `__init__` and therefore
keep the host list or their own tensor. Two of these, NIST
`reset_end_effector_around_asset` and PhysX
`randomize_rigid_body_material`, keep host lists: the first can adopt
the finalized tensor in a follow-up, while the second iterates backend
body IDs on the CPU and should stay on the host.

## Release backport

- [x] <!-- backport-active-release --> Backport this pull request to the
active release branch after it merges into `develop`

## Checklist

- [x] I have read and understood the contribution guidelines.
- [x] I have run the pre-commit checks with `uv run --frozen isaaclab
-f`.
- [x] I have made corresponding changes to the documentation.
- [x] I have added tests that prove the behavior and checked them
against the change disabled.
- [x] I have added a changelog fragment for every touched source
package.
- [x] My name already exists in `CONTRIBUTORS.md`.

(cherry picked from commit 10fdf81)
@isaaclab-bot

isaaclab-bot Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Backported to release/3.0.0 as 0abc885.

StafaH added a commit to StafaH/IsaacLab that referenced this pull request Sep 28, 2026
Managers now finalize scene-entity selections to device tensors (isaac-sim#8087), so
the cached device-ID helper is redundant; iterating a finalized tensor to
build its cache key would also read indices back from the device.
ooctipus added a commit that referenced this pull request Sep 28, 2026
# Description

Part 4 of the camera performance series. Based on the latest `develop`,
including #8084 and #8087. Supersedes #7495.

Profiling the camera and direct tasks found host-device synchronizations
in every step: the CPU blocked on the GPU, then ran Python code while
the GPU sat idle. This PR removes them from termination tracking, the
Lift rewards and success monitoring, marker validation, camera updates,
and the Cartpole and Pendulum direct tasks. It also incorporates the
hot-path fixes from #6492 (by @kellyguo11) that still apply to current
`develop`.

- `torch.where` replaces `nonzero` in the termination manager and
replaces boolean-mask writes in the Lift progress rewards.
- `SuccessMonitor` updates no longer synchronize. They rank outcomes
with fixed-size scatters instead of `unique_consecutive`,
`repeat_interleave`, and boolean masks. Masked or overflowing outcomes
go to an internal scratch row. A new `valid` argument lets the Lift
reset hook pass a mask instead of filtering.
- `SuccessMonitor.get_mean_success_rate()` returns a 0-d tensor, so
logging it does not synchronize. The Cartpole direct and Pendulum MARL
success rates are logged as tensors for the same reason. Call `.item()`
where a Python float is needed.
- Cartpole direct and Pendulum MARL store their joint indices as device
tensors. Observations, rewards, terminations, resets, and effort writes
no longer upload host lists each step.
- Marker index validation runs only when a backend consumes the IDs, and
once per ID tensor.
- Cameras with `update_period == 0` skip the outdated-mask readback.
- Zero-width uniform `add` noise returns its input.
- `object_point_cloud_b` defaults to `visualize=False`. Drawing 262k
markers every step cost a sync, and with RTX the markers appeared in
camera images. The Kuka rendering test already disabled them for that
reason.
- `ActionManager` caches its term dimensions, which are fixed after
construction but were recomputed on every action step (from #6492).
- The Cartpole and Reorient direct tasks drop redundant action copies
(from #6492).

With #8087, managers finalize scene-entity selections to device tensors.
`object_ee_distance` therefore indexes with `asset_cfg.body_ids`
directly, and this PR's earlier cached device-ID helper was removed.
After #8087 it would have iterated the finalized tensor to build its
cache key, reading indices back from the device.

### Changes from #6492

Each #6492 change was checked against current `develop`:

| #6492 change | Decision |
| --- | --- |
| Skip observation-term clones | Not taken: `develop` already provides
this through #8038. |
| Cabinet direct `actions.clone()` | Not taken: the line no longer
exists. |
| `ActionManager` caches term dimensions | **Taken.** |
| Cartpole direct index cleanup | **Taken and extended.** #6492 fixed 1
of the 9 synchronizations caused by host-list joint indexing. Storing
the joint indices as device tensors removes all 9. |
| Drop `actions.clone()` in the Cartpole and Reorient direct tasks |
**Taken.** Neither task modifies the stored actions in place. |
| Drop `actions.clone()` in the Locomotion direct task | **Not taken.**
Its reset zeroes `self.actions` in place, which would zero the policy's
own action tensor, e.g. the one held in RL rollout storage. |

### Investigated and dropped: Newton sensor-graph flag cache

An earlier revision cached the Newton sensor graph's task flags and
skipped the upload when they were unchanged, on the premise that each
upload synchronized the stream. That premise does not hold for the
current Warp (1.17), so the change was reverted and `develop`'s per-call
upload is kept:

- Warp uploads the flags with a single `cudaMemcpyAsync` from pageable
memory, which CUDA stages on the host without waiting for the stream.
- Behind about 455 ms of Warp kernels queued on the same stream, ten
uploads return in 0.07–0.13 ms.
- An Nsight Systems trace of the Kuka camera task shows each flag
upload's `cudaMemcpyAsync` returning in 5.9 µs on average, 35.6 µs at
most.
- End to end (Kuka camera task, 256 environments), `develop`'s upload,
the cache, and device-side flag writes measured 12.53, 12.50, and 12.47
ms per step. That spread is within run-to-run noise (12.45–12.58 ms).

## Series

1. #8036: Read camera outputs through `ProxyArray.torch` (bug fix)
(base: develop)
2. #8037: Fused normalization for strided camera images (base: #8036)
3. #8038: Skip redundant observation copies (base: #8037)
4. #8039: Remove per-step host synchronizations (base: develop)
5. #8040: Newton `render_batch` in one sensor-graph launch (base:
develop)
6. #8041: RSL-RL cuDNN benchmark, mixed precision and compile settings
(base: develop)
7. #8042: Kuka Allegro camera tasks on the shared image observation
(base: #8038)

The series is split from #7440, which remains the combined reference
branch.

## Type of change

- Bug fix (non-breaking change which fixes an issue)
- Changes to `SuccessMonitor`: `get_mean_success_rate()` returns a 0-d
tensor instead of a float, and `success_update()` gains a `valid`
argument. The changelog includes migration guidance.

## Performance

RTX PRO 6000 Blackwell Workstation Edition (driver 595.91.07); PyTorch
2.12.0+cu130; Warp 1.17.0; Newton 1.6.0; GPU otherwise idle. `develop`
at `10fdf81d9` compared with this PR (`b2727a0f2`; later commits only
trim comments and revert the Newton change above), with the same
`uv.lock`. Runtime benchmark (`isaaclab benchmark runtime`),
Newton/MJWarp, seed 42, no visualizer. Three fresh processes per
revision, run in alternating order. Figures are the mean step time
across processes.

| Workload | `develop` | This PR | Change |
| --- | ---: | ---: | ---: |
| `Isaac-Lift-KukaAllegro-Camera`, 256 envs,
`presets=duo_camera,rgb128`, Newton renderer (500 steps) | 14.44 ms |
12.62 ms | **−12.6%** (+14.4% throughput) |
| `Isaac-Cartpole-Direct`, 4096 envs (2,000 steps) | 1.674 ms | 1.441 ms
| **−13.9%** (+16.2% throughput) |
| `Isaac-Pendulum-MARL-Direct`, 4096 envs (2,000 steps) | 2.144 ms |
1.862 ms | **−13.2%** (+15.2% throughput) |

Per-process step times (`develop` → PR):
- Camera: `14.44, 14.48, 14.40` → `12.67, 12.63, 12.57` ms.
- Cartpole: `1.680, 1.685, 1.657` → `1.446, 1.438, 1.439` ms.
- Pendulum: `2.137, 2.158, 2.137` → `1.827, 1.863, 1.895` ms.

Host synchronizations per `env.step()`, attributed to call sites with
PyTorch sync-debug mode over 170 steps (4096 envs):

| Task | `develop` | This PR | Remaining |
| --- | ---: | ---: | --- |
| `Isaac-Lift-KukaAllegro-Camera` (`presets=cube`, Newton renderer) |
21.3 | 4.2 | step reset and command-resample `nonzero`; curriculum,
command-metric, and termination logging reads |
| `Isaac-Cartpole-Direct` | 10.3 | 1.0 | step reset `nonzero` |
| `Isaac-Pendulum-MARL-Direct` | 10.0 | 1.0 | step reset `nonzero` |

PyTorch labels sync-debug mode a prototype that does not detect every
synchronization, and it does not see synchronizations issued by Warp, so
these counts are lower bounds.

Reproduce with:

```bash
uv run --frozen isaaclab benchmark runtime \
  --task Isaac-Lift-KukaAllegro-Camera --num_envs 256 --num_steps 500 \
  --warmup_steps 100 --seed 42 --device cuda:0 --visualizer none \
  --output_path /tmp/pr8039 physics=newton_mjwarp renderer=newton_renderer presets=duo_camera,rgb128
```

### Not addressed

- **Step reset and command resampling:** both still call `nonzero` once
per step. Both convert a mask into variable-length environment IDs, and
the reset and command pipelines consume those IDs throughout. Removing
these synchronizations means moving those pipelines to masks or padded
IDs, which is out of scope here.
- **Warp-side synchronizations:** the Nsight trace above also records
many `cudaStreamSynchronize` calls outside the flag uploads, which
PyTorch's sync-debug mode cannot attribute. Their sources are not yet
identified.

## Validation

- Cartpole direct produces bit-identical observation and reward
checksums to `develop` after 150 seeded steps, including resets.
- Pendulum MARL is not run-to-run deterministic on MJWarp. Its
observations and rewards were instead compared on identical state
against `develop`'s host-index formulas for 150 steps, with a maximum
difference of 0.0. Reorient direct is also non-deterministic; its change
only removes a copy of an action tensor that is never modified in place.
- `test_circular_buffer.py`, `test_noise.py`, `test_curriculum.py`, the
manager tests (including `test_event_manager.py`,
`test_reward_manager.py`, `test_termination_manager.py`, and
`test_scene_entity_cfg.py`), `test_lift_env_cfg.py`,
`test_sensor_base.py`, `test_visualization_markers.py`, and
`test_kit_visualizer_scene_partitioning.py` pass.
- `test_rendering_lift_kuka_homo_kitless.py` passes for the Newton
renderer and legacy OVRTX cases. The two `ovstage` OVRTX cases fail
identically on `develop`.
- `uv run --frozen isaaclab -f` passes, including changelog checks.

## Release backport

- [x] <!-- backport-active-release --> Backport this pull request to the
active release branch after it merges into `develop`

---------

Co-authored-by: Octi Zhang <[email protected]>
isaaclab-bot Bot pushed a commit that referenced this pull request Sep 28, 2026
# Description

Part 4 of the camera performance series. Based on the latest `develop`,
including #8084 and #8087. Supersedes #7495.

Profiling the camera and direct tasks found host-device synchronizations
in every step: the CPU blocked on the GPU, then ran Python code while
the GPU sat idle. This PR removes them from termination tracking, the
Lift rewards and success monitoring, marker validation, camera updates,
and the Cartpole and Pendulum direct tasks. It also incorporates the
hot-path fixes from #6492 (by @kellyguo11) that still apply to current
`develop`.

- `torch.where` replaces `nonzero` in the termination manager and
replaces boolean-mask writes in the Lift progress rewards.
- `SuccessMonitor` updates no longer synchronize. They rank outcomes
with fixed-size scatters instead of `unique_consecutive`,
`repeat_interleave`, and boolean masks. Masked or overflowing outcomes
go to an internal scratch row. A new `valid` argument lets the Lift
reset hook pass a mask instead of filtering.
- `SuccessMonitor.get_mean_success_rate()` returns a 0-d tensor, so
logging it does not synchronize. The Cartpole direct and Pendulum MARL
success rates are logged as tensors for the same reason. Call `.item()`
where a Python float is needed.
- Cartpole direct and Pendulum MARL store their joint indices as device
tensors. Observations, rewards, terminations, resets, and effort writes
no longer upload host lists each step.
- Marker index validation runs only when a backend consumes the IDs, and
once per ID tensor.
- Cameras with `update_period == 0` skip the outdated-mask readback.
- Zero-width uniform `add` noise returns its input.
- `object_point_cloud_b` defaults to `visualize=False`. Drawing 262k
markers every step cost a sync, and with RTX the markers appeared in
camera images. The Kuka rendering test already disabled them for that
reason.
- `ActionManager` caches its term dimensions, which are fixed after
construction but were recomputed on every action step (from #6492).
- The Cartpole and Reorient direct tasks drop redundant action copies
(from #6492).

With #8087, managers finalize scene-entity selections to device tensors.
`object_ee_distance` therefore indexes with `asset_cfg.body_ids`
directly, and this PR's earlier cached device-ID helper was removed.
After #8087 it would have iterated the finalized tensor to build its
cache key, reading indices back from the device.

### Changes from #6492

Each #6492 change was checked against current `develop`:

| #6492 change | Decision |
| --- | --- |
| Skip observation-term clones | Not taken: `develop` already provides
this through #8038. |
| Cabinet direct `actions.clone()` | Not taken: the line no longer
exists. |
| `ActionManager` caches term dimensions | **Taken.** |
| Cartpole direct index cleanup | **Taken and extended.** #6492 fixed 1
of the 9 synchronizations caused by host-list joint indexing. Storing
the joint indices as device tensors removes all 9. |
| Drop `actions.clone()` in the Cartpole and Reorient direct tasks |
**Taken.** Neither task modifies the stored actions in place. |
| Drop `actions.clone()` in the Locomotion direct task | **Not taken.**
Its reset zeroes `self.actions` in place, which would zero the policy's
own action tensor, e.g. the one held in RL rollout storage. |

### Investigated and dropped: Newton sensor-graph flag cache

An earlier revision cached the Newton sensor graph's task flags and
skipped the upload when they were unchanged, on the premise that each
upload synchronized the stream. That premise does not hold for the
current Warp (1.17), so the change was reverted and `develop`'s per-call
upload is kept:

- Warp uploads the flags with a single `cudaMemcpyAsync` from pageable
memory, which CUDA stages on the host without waiting for the stream.
- Behind about 455 ms of Warp kernels queued on the same stream, ten
uploads return in 0.07–0.13 ms.
- An Nsight Systems trace of the Kuka camera task shows each flag
upload's `cudaMemcpyAsync` returning in 5.9 µs on average, 35.6 µs at
most.
- End to end (Kuka camera task, 256 environments), `develop`'s upload,
the cache, and device-side flag writes measured 12.53, 12.50, and 12.47
ms per step. That spread is within run-to-run noise (12.45–12.58 ms).

## Series

1. #8036: Read camera outputs through `ProxyArray.torch` (bug fix)
(base: develop)
2. #8037: Fused normalization for strided camera images (base: #8036)
3. #8038: Skip redundant observation copies (base: #8037)
4. #8039: Remove per-step host synchronizations (base: develop)
5. #8040: Newton `render_batch` in one sensor-graph launch (base:
develop)
6. #8041: RSL-RL cuDNN benchmark, mixed precision and compile settings
(base: develop)
7. #8042: Kuka Allegro camera tasks on the shared image observation
(base: #8038)

The series is split from #7440, which remains the combined reference
branch.

## Type of change

- Bug fix (non-breaking change which fixes an issue)
- Changes to `SuccessMonitor`: `get_mean_success_rate()` returns a 0-d
tensor instead of a float, and `success_update()` gains a `valid`
argument. The changelog includes migration guidance.

## Performance

RTX PRO 6000 Blackwell Workstation Edition (driver 595.91.07); PyTorch
2.12.0+cu130; Warp 1.17.0; Newton 1.6.0; GPU otherwise idle. `develop`
at `10fdf81d9` compared with this PR (`b2727a0f2`; later commits only
trim comments and revert the Newton change above), with the same
`uv.lock`. Runtime benchmark (`isaaclab benchmark runtime`),
Newton/MJWarp, seed 42, no visualizer. Three fresh processes per
revision, run in alternating order. Figures are the mean step time
across processes.

| Workload | `develop` | This PR | Change |
| --- | ---: | ---: | ---: |
| `Isaac-Lift-KukaAllegro-Camera`, 256 envs,
`presets=duo_camera,rgb128`, Newton renderer (500 steps) | 14.44 ms |
12.62 ms | **−12.6%** (+14.4% throughput) |
| `Isaac-Cartpole-Direct`, 4096 envs (2,000 steps) | 1.674 ms | 1.441 ms
| **−13.9%** (+16.2% throughput) |
| `Isaac-Pendulum-MARL-Direct`, 4096 envs (2,000 steps) | 2.144 ms |
1.862 ms | **−13.2%** (+15.2% throughput) |

Per-process step times (`develop` → PR):
- Camera: `14.44, 14.48, 14.40` → `12.67, 12.63, 12.57` ms.
- Cartpole: `1.680, 1.685, 1.657` → `1.446, 1.438, 1.439` ms.
- Pendulum: `2.137, 2.158, 2.137` → `1.827, 1.863, 1.895` ms.

Host synchronizations per `env.step()`, attributed to call sites with
PyTorch sync-debug mode over 170 steps (4096 envs):

| Task | `develop` | This PR | Remaining |
| --- | ---: | ---: | --- |
| `Isaac-Lift-KukaAllegro-Camera` (`presets=cube`, Newton renderer) |
21.3 | 4.2 | step reset and command-resample `nonzero`; curriculum,
command-metric, and termination logging reads |
| `Isaac-Cartpole-Direct` | 10.3 | 1.0 | step reset `nonzero` |
| `Isaac-Pendulum-MARL-Direct` | 10.0 | 1.0 | step reset `nonzero` |

PyTorch labels sync-debug mode a prototype that does not detect every
synchronization, and it does not see synchronizations issued by Warp, so
these counts are lower bounds.

Reproduce with:

```bash
uv run --frozen isaaclab benchmark runtime \
  --task Isaac-Lift-KukaAllegro-Camera --num_envs 256 --num_steps 500 \
  --warmup_steps 100 --seed 42 --device cuda:0 --visualizer none \
  --output_path /tmp/pr8039 physics=newton_mjwarp renderer=newton_renderer presets=duo_camera,rgb128
```

### Not addressed

- **Step reset and command resampling:** both still call `nonzero` once
per step. Both convert a mask into variable-length environment IDs, and
the reset and command pipelines consume those IDs throughout. Removing
these synchronizations means moving those pipelines to masks or padded
IDs, which is out of scope here.
- **Warp-side synchronizations:** the Nsight trace above also records
many `cudaStreamSynchronize` calls outside the flag uploads, which
PyTorch's sync-debug mode cannot attribute. Their sources are not yet
identified.

## Validation

- Cartpole direct produces bit-identical observation and reward
checksums to `develop` after 150 seeded steps, including resets.
- Pendulum MARL is not run-to-run deterministic on MJWarp. Its
observations and rewards were instead compared on identical state
against `develop`'s host-index formulas for 150 steps, with a maximum
difference of 0.0. Reorient direct is also non-deterministic; its change
only removes a copy of an action tensor that is never modified in place.
- `test_circular_buffer.py`, `test_noise.py`, `test_curriculum.py`, the
manager tests (including `test_event_manager.py`,
`test_reward_manager.py`, `test_termination_manager.py`, and
`test_scene_entity_cfg.py`), `test_lift_env_cfg.py`,
`test_sensor_base.py`, `test_visualization_markers.py`, and
`test_kit_visualizer_scene_partitioning.py` pass.
- `test_rendering_lift_kuka_homo_kitless.py` passes for the Newton
renderer and legacy OVRTX cases. The two `ovstage` OVRTX cases fail
identically on `develop`.
- `uv run --frozen isaaclab -f` passes, including changelog checks.

## Release backport

- [x] <!-- backport-active-release --> Backport this pull request to the
active release branch after it merges into `develop`

---------

Co-authored-by: Octi Zhang <[email protected]>

(cherry picked from commit 60bc09f)
ooctipus pushed a commit that referenced this pull request Sep 28, 2026
# Description

Part 7 of the camera performance series. Based on the latest `develop`,
which now includes the rest of the series (#8036–#8041), #8051, and
#8087.

The Kuka Allegro Lift camera tasks move from the task-specific
`vision_camera` term to the shared `mdp.image_rgb`, `mdp.image_depth`,
and `mdp.image_segmentation` terms. Images stay raw in the environment,
and the policy normalizes them:

- Each camera's image term is a preset named like the camera presets
(`rgb128`, `depth64`, `raycaster_depth256`, ...), so one preset such as
`presets=duo_camera,rgb128` selects both the camera and its matching
term. The terms use `normalize=False, channel_first=True` and emit raw
images. RGB terms drop albedo's unused alpha channel.
- The observation manager's copy skipping from #8038 applies
automatically: `image_rgb` writes into a manager-owned output, so each
image is copied once per step and not cloned again.
- `SpatialSoftmaxCNNModel` applies the fixed-range normalization the
task used before: `x / 255 - 0.5` for color, and `tanh(depth / 2) - 0.5`
with NaN treated as far for depth.
- A single `addcmul` pass does the conversion; separate cast, scale, and
shift passes made the PPO update slower than the float32 baseline.
- Image groups that are neither uint8 nor floating point, such as
non-colorized segmentation labels, raise an error when the model is
built instead of being normalized as depth.
- The JIT and ONNX exports take raw images: uint8 for color. The
normalizer has no state-dict entries, so existing RGB and depth
checkpoints load unchanged. Keep the compatibility `vision_camera` term
for existing four-channel albedo policies, or retrain with three-channel
albedo observations.
- Color images stay uint8 in rollout storage, which cuts rollout image
memory 4x and makes minibatch gathers cheaper.
- The spatial soft-argmax uses one matmul instead of two broadcast
products and sums. It keeps the `pos_x`/`pos_y` buffers for checkpoint
compatibility.
- The camera runners set `check_for_nan=False`. RSL-RL's per-group NaN
scan reads every image and synchronizes with the host each step, and
uint8 images cannot be NaN.

Updated for the merged series: the earlier `clone_output` term setting
was removed, because #8038 landed with automatic copy skipping instead
of a configuration flag.

## Series

1. #8036: Read camera outputs through `ProxyArray.torch` (bug fix) —
merged
2. #8037: Fused normalization for strided camera images — merged
3. #8038: Skip redundant observation copies — merged
4. #8039: Remove per-step host synchronizations — merged
5. #8040: Newton `render_batch` in one sensor-graph launch — merged
6. #8041: RSL-RL cuDNN benchmark, mixed precision and compile settings —
merged
7. #8042: Kuka Allegro camera tasks on the shared image observation
(this PR, base: develop)

The series is split from #7440, which remains the combined reference
branch.

## Type of change

- Breaking change (existing functionality will not work without user
modification). Exported Kuka camera policies now take raw images, and
albedo observations have three channels. See the changelog for
migration.

## Performance

RTX PRO 6000 Blackwell Workstation Edition (driver 595.91.07); PyTorch
2.12.0+cu130; Warp 1.17.0; Newton 1.6.0; GPU otherwise idle. `develop`
at `60bc09f17` compared with this PR (`bb10c5e0b`), with the same
`uv.lock`. `isaaclab benchmark training --rl_library rsl_rl`,
`Isaac-Lift-KukaAllegro-Camera`, 256 environments,
`presets=duo_camera,rgb128`, `physics=newton_mjwarp`,
`renderer=newton_renderer`, 24 PPO iterations, seed 42, no visualizer.
Three fresh processes per revision, run in alternating order; figures
are means across processes.

| Metric | `develop` | This PR | Change |
| --- | ---: | ---: | ---: |
| Training throughput (higher is better) | 11,020 steps/s | 11,191
steps/s | +1.6% |
| PPO iteration (lower is better) | 0.795 s | 0.775 s | −2.5% |
| Environment step (lower is better) | 14.03 ms | 13.84 ms | −1.4% |
| Peak GPU memory, whole device (lower is better) | 7.12 GB | 4.73 GB |
**−34%** |

Per-process iteration times (`develop` → PR): `0.804, 0.790, 0.792` →
`0.772, 0.776, 0.777` s.

The iteration means include PPO warmup, and GPU memory is the
device-level figure, including Warp and Newton allocations. This is a
short steady-state check, not a convergence test.

## Validation

- `test_lift_env_cfg.py`: 13 passed. These include the configured RGB,
depth, albedo, and semantic-segmentation terms for both cameras, with
the model's fixed normalization.
- RSL-RL training smoke tests, Newton/MJWarp with the Newton renderer,
64 environments: `duo_camera,rgb128` (3 iterations) and
`duo_camera,depth128` (2 iterations) train without errors.
- Export check on the RGB checkpoint: `isaaclab play` writes `policy.pt`
and `policy.onnx`. The ONNX graph declares both images as `uint8 [1, 3,
128, 128]`. The JIT export accepts raw uint8 images and returns finite
actions, and ONNX Runtime matches the JIT export within `1.2e-6`.
- `uv run --frozen isaaclab -f` passes, including changelog checks.

## Release backport

- [x] <!-- backport-active-release --> Backport this pull request to the
active release branch after it merges into `develop`
isaaclab-bot Bot pushed a commit that referenced this pull request Sep 28, 2026
# Description

Part 7 of the camera performance series. Based on the latest `develop`,
which now includes the rest of the series (#8036–#8041), #8051, and
#8087.

The Kuka Allegro Lift camera tasks move from the task-specific
`vision_camera` term to the shared `mdp.image_rgb`, `mdp.image_depth`,
and `mdp.image_segmentation` terms. Images stay raw in the environment,
and the policy normalizes them:

- Each camera's image term is a preset named like the camera presets
(`rgb128`, `depth64`, `raycaster_depth256`, ...), so one preset such as
`presets=duo_camera,rgb128` selects both the camera and its matching
term. The terms use `normalize=False, channel_first=True` and emit raw
images. RGB terms drop albedo's unused alpha channel.
- The observation manager's copy skipping from #8038 applies
automatically: `image_rgb` writes into a manager-owned output, so each
image is copied once per step and not cloned again.
- `SpatialSoftmaxCNNModel` applies the fixed-range normalization the
task used before: `x / 255 - 0.5` for color, and `tanh(depth / 2) - 0.5`
with NaN treated as far for depth.
- A single `addcmul` pass does the conversion; separate cast, scale, and
shift passes made the PPO update slower than the float32 baseline.
- Image groups that are neither uint8 nor floating point, such as
non-colorized segmentation labels, raise an error when the model is
built instead of being normalized as depth.
- The JIT and ONNX exports take raw images: uint8 for color. The
normalizer has no state-dict entries, so existing RGB and depth
checkpoints load unchanged. Keep the compatibility `vision_camera` term
for existing four-channel albedo policies, or retrain with three-channel
albedo observations.
- Color images stay uint8 in rollout storage, which cuts rollout image
memory 4x and makes minibatch gathers cheaper.
- The spatial soft-argmax uses one matmul instead of two broadcast
products and sums. It keeps the `pos_x`/`pos_y` buffers for checkpoint
compatibility.
- The camera runners set `check_for_nan=False`. RSL-RL's per-group NaN
scan reads every image and synchronizes with the host each step, and
uint8 images cannot be NaN.

Updated for the merged series: the earlier `clone_output` term setting
was removed, because #8038 landed with automatic copy skipping instead
of a configuration flag.

## Series

1. #8036: Read camera outputs through `ProxyArray.torch` (bug fix) —
merged
2. #8037: Fused normalization for strided camera images — merged
3. #8038: Skip redundant observation copies — merged
4. #8039: Remove per-step host synchronizations — merged
5. #8040: Newton `render_batch` in one sensor-graph launch — merged
6. #8041: RSL-RL cuDNN benchmark, mixed precision and compile settings —
merged
7. #8042: Kuka Allegro camera tasks on the shared image observation
(this PR, base: develop)

The series is split from #7440, which remains the combined reference
branch.

## Type of change

- Breaking change (existing functionality will not work without user
modification). Exported Kuka camera policies now take raw images, and
albedo observations have three channels. See the changelog for
migration.

## Performance

RTX PRO 6000 Blackwell Workstation Edition (driver 595.91.07); PyTorch
2.12.0+cu130; Warp 1.17.0; Newton 1.6.0; GPU otherwise idle. `develop`
at `60bc09f17` compared with this PR (`bb10c5e0b`), with the same
`uv.lock`. `isaaclab benchmark training --rl_library rsl_rl`,
`Isaac-Lift-KukaAllegro-Camera`, 256 environments,
`presets=duo_camera,rgb128`, `physics=newton_mjwarp`,
`renderer=newton_renderer`, 24 PPO iterations, seed 42, no visualizer.
Three fresh processes per revision, run in alternating order; figures
are means across processes.

| Metric | `develop` | This PR | Change |
| --- | ---: | ---: | ---: |
| Training throughput (higher is better) | 11,020 steps/s | 11,191
steps/s | +1.6% |
| PPO iteration (lower is better) | 0.795 s | 0.775 s | −2.5% |
| Environment step (lower is better) | 14.03 ms | 13.84 ms | −1.4% |
| Peak GPU memory, whole device (lower is better) | 7.12 GB | 4.73 GB |
**−34%** |

Per-process iteration times (`develop` → PR): `0.804, 0.790, 0.792` →
`0.772, 0.776, 0.777` s.

The iteration means include PPO warmup, and GPU memory is the
device-level figure, including Warp and Newton allocations. This is a
short steady-state check, not a convergence test.

## Validation

- `test_lift_env_cfg.py`: 13 passed. These include the configured RGB,
depth, albedo, and semantic-segmentation terms for both cameras, with
the model's fixed normalization.
- RSL-RL training smoke tests, Newton/MJWarp with the Newton renderer,
64 environments: `duo_camera,rgb128` (3 iterations) and
`duo_camera,depth128` (2 iterations) train without errors.
- Export check on the RGB checkpoint: `isaaclab play` writes `policy.pt`
and `policy.onnx`. The ONNX graph declares both images as `uint8 [1, 3,
128, 128]`. The JIT export accepts raw uint8 images and returns finite
actions, and ONNX Runtime matches the JIT export within `1.2e-6`.
- `uv run --frozen isaaclab -f` passes, including changelog checks.

## Release backport

- [x] <!-- backport-active-release --> Backport this pull request to the
active release branch after it merges into `develop`

(cherry picked from commit f25d3f0)
ooctipus pushed a commit that referenced this pull request Sep 30, 2026
)

# Description

Part 7B of the camera performance series, based on the latest `develop`
(including #8039, #8042, and #8087). A sweep of the per-step hot path
found remaining host-device synchronizations and code that costs more
than it gives. This PR fixes the verified findings: it removes the
synchronizations, launch overhead, and dead or over-defensive code, and
fixes the verified bugs.

Profiling on `develop` motivated this. The GPU sat idle 20–27% of each
step, because the CPU blocked on synchronizations and then launched
hundreds of small kernels. On `Isaac-Velocity-Rough-AnymalD` (4096
environments), for example, the CPU was blocked 12.8 ms of a 25.4 ms
step.

## Changes

### Host synchronizations removed
- **Episode logging:** the command, termination, and curriculum
managers, `survival_success_rate`, the pose commands, and task success
rates (Cabinet, Locomotion, Lift deformable/cable, Fourbar) log 0-d
device tensors instead of reading back `.item()`/`.cpu()` on every
reset. `RewardManager` already logged tensors, and the RL wrappers
accept them. Curriculum states are logged as copies, because rsl_rl
keeps episode infos for a whole rollout. The inspection accessor
`get_active_iterable_terms()` still returns Python scalars.
- **Velocity command:** heading control is branchless (`torch.where`)
instead of `is_heading_env.nonzero()` every step. Output is identical.
- **Event ranges:** core and Lift event terms use
`sample_uniform_from_ranges()` to draw named components directly. One
private, bounded bounds cache replaces both sets of tensor-building
helpers; it is keyed by values, resolved device, and dtype. Curriculum
edits take effect on the next call, and every call draws fresh samples
in the existing order.
- **Ray caster:** `reset()` no longer uploads its range tensor or
samples drift when the drift ranges are zero (the default). In rough
locomotion this reset runs almost every step. When drift is disabled
after sampling, reset clears the selected environments’ old drift.
- **DiffIK:** the `if ee_quat.norm() != 0` guard in `apply_actions`,
which synchronized every physics substep, is now a `torch.where` with
the same all-or-nothing behavior.
- **Direct tasks:** Reorient (about 14 host-list indexes per substep),
Cabinet, and Locomotion store joint and body indices as device tensors,
precompute static joint limits and default positions, and use the
non-deprecated `actuators.target_command` API.
- **Other task terms:**
- Locomotion `walk_target_w` caches its device target (it synchronized 4
times per step).
- Reorient's `EpisodeErrorRecorder` uses `torch.where` with NaN
reductions instead of boolean masks.
- Lift reset events share the named-range sampler with the core event
terms.
- **Joint limits:** Newton, PhysX, and OvPhysX position-limit writes
reuse the clamping counter and read it back only when the resulting
message would be logged.

### Launch overhead
- **`RewardManager`:** each term writes its weighted value into a
step-reward matrix column, followed by one sum and one batched
episode-sum update. Reset is one mean and one fill. With 20 terms at
4096 environments, compute drops from 121 to 23 kernels (471 → 152 µs)
and reset from 80 to 4 kernels (504 → 49 µs).
- **`ObservationManager`:** the built-in noise functions
(`constant_noise`, `gaussian_noise`, `uniform_noise`) are out-of-place,
so the pre-noise clone and the second clone are skipped. Safe built-in
noise functions are identified during `_prepare_terms`; custom noise
functions, noise models, and modifiers still clone, including when a
caller replaces a noise function after setup. The noise sampling order
is unchanged.
- **`CircularBuffer`:** one staged shift replaces K−1 slot copies for
frames up to 2 MiB. Image-sized frames keep the slot loop, which is
faster for them.
- **Lift contacts:** one stacked norm replaces per-sensor norms.
`contacts()` runs 5 times per step in Kuka Allegro, and this removes
about 80 kernels per step.
- **ANYmal symmetry augmentation:** one cached permutation and sign
tensor per transform, bitwise-equal to the original, is 1.56 → 0.15 ms
per call at 4096 environments.
- **RTX renderer:** normals, motion vectors, `rgb_hdr`, and simple
shading no longer copy each frame into a contiguous channel slice before
reshaping.
- **Smaller changes:**
- Reorient reads its command slices directly instead of concatenating
them.
  - sb3 computes `dones` on the host side.

### Overengineered code removed
- **`NewtonManager.step()`** ran the solver-internals reset every
physics step. `forward()` already performs it when kinematics are dirty,
so the extra call only launched with an all-False mask.
- **`WrenchComposer.reset()`** returns early when inactive. Its buffers
are already zero, and this removes about 7 memsets per rigid object per
physics step (21 µs → 0.07 µs per call).
- **`SensorBase`:** sensors with `debug_vis=True` no longer refresh on
every physics substep. That refresh existed because debug callbacks once
read private data. The callbacks now refresh the outdated buffers
themselves. The original eager update was introduced in commit
`4565902f5` to make visualization work without a `data` read; it did not
pump rendering.
- **`VisualizationMarkers.visualize()`** returns early when no backend
is active.
- **Dead code:** removed the Newton Warp renderer's output copy loop
(every output is a zero-copy alias), the impossible PhysX ray-caster
guard, and the redundant Lift `body_state_b` index conversion (redundant
since #8087).

### Bug fixes
- **Newton `body_com_acc_w`:** the finite difference divided by the
physics timestep even when an update spans several physics steps (Newton
owning the decimation loop). That made the acceleration, and
`body_lin_acc_l2`, `decimation`× too large. It now uses the elapsed
time, matching `joint_acc`. The OvPhysX rigid-object implementation uses
the same elapsed-time formula. PhysX and OvPhysX articulations read
acceleration from the backend, so they do not need this
finite-difference change.
- **`reset_root_state_uniform`** built its range tensors in `__init__`
and ignored call-time `pose_range`/`velocity_range`, so curriculum
updates were silently dropped.

### Investigated and not included
- **Step reset, command resample, and interval-event `nonzero`:** these
are now the only synchronizations left in
`Isaac-Velocity-Rough-AnymalD`. Each converts a mask into
variable-length environment IDs consumed across the reset, command, and
event APIs. Removing them requires a mask-based API redesign and is left
for a separate design.
- **Needs a Kit trace before changing:** the PhysX IMU/PVA per-update
COM upload, PhysX contact-sensor per-substep fetches, and the Fabric
render synchronizations. They rely on PhysX/Fabric semantics we have not
measured. A similar "pageable upload synchronizes" assumption proved
false for the Newton sensor flags.
- **Deferring the MPM sparse-grid status check:** a solver reset clears
the status, so a deferred check could lose capacity errors, and no test
covers this path.
- **RMPflow guard:** it already runs on the host, so removing the guard
gains nothing. The `joint_actions` allocation is needed for LEAPP export
tracing.
- **Lower confidence, left out:** collection mask-write kernels and
batching model-change notifications.

## Type of change

- Bug fix (non-breaking change which fixes an issue)
- Behavior changes with migration notes in the changelog fragments:
- Episode log values are 0-d tensors; use `float()` or `.item()` where a
Python number is needed.
- Reorient direct index attributes (`actuated_dof_indices`,
`finger_bodies`, `finger_wrench_bodies`) and `resolve_actuated_tendons`
ids are tensors.
- `EpisodeErrorRecorder` reports NaN for an empty selection after its
first update.
- Custom sensors should refresh their buffers inside
`_debug_vis_callback`.

## Performance

RTX PRO 6000 Blackwell Workstation Edition (driver 595.91.07); PyTorch
2.12.0+cu130; Warp 1.17.0; Newton 1.6.0; GPU otherwise idle. `develop`
at `60bc09f17` compared with this PR on that base, with the same
`uv.lock`. The branch has since merged `develop` at `f25d3f09b` (#8042,
#8090, #8102). The numbers below were measured before that merge; #8042
changes the Kuka camera observations and #8090 touches the simulation
context, so they have not been re-measured on the merged branch or after
review fixes. Static Lift success markers now resend positions to
support late backend activation; the earlier marker-index-only
optimization is not included. Runtime benchmark (`isaaclab benchmark
runtime`), Newton/MJWarp, seed 42, no visualizer. Three fresh processes
per revision, run in alternating order. Figures are the mean step time
across processes; every workload's per-process ranges are disjoint.

| Workload | `develop` | This PR | Change |
| --- | ---: | ---: | ---: |
| `Isaac-Ant`, 4096 envs | 3.369 ms | 2.629 ms | **−22.0%** (+28.1%
throughput) |
| `Isaac-Open-Drawer-Franka-Direct`, 4096 envs | 11.106 ms | 10.100 ms |
**−9.1%** (+10.0%) |
| `Isaac-Reorient-Cube-Allegro-Direct`, 4096 envs | 27.114 ms | 25.221
ms | **−7.0%** (+7.5%) |
| `Isaac-Velocity-Rough-AnymalD`, 4096 envs | 23.078 ms | 22.573 ms |
−2.2% (+2.2%) |
| `Isaac-Lift-KukaAllegro-Camera`, 256 envs,
`presets=duo_camera,rgb128`, Newton renderer | 12.396 ms | 12.202 ms |
−1.6% (+1.6%) |

Per-process step times (`develop` → PR):
- Ant: `3.367, 3.359, 3.382` → `2.639, 2.638, 2.611` ms.
- Drawer: `11.113, 11.102, 11.104` → `10.099, 10.100, 10.100` ms.
- Reorient: `27.136, 27.136, 27.070` → `25.217, 25.250, 25.197` ms.
- AnymalD: `23.081, 23.050, 23.103` → `22.551, 22.568, 22.599` ms.
- Camera: `12.389, 12.374, 12.424` → `12.373, 12.119, 12.113` ms.

Host synchronizations per `env.step()`, attributed to call sites with
PyTorch sync-debug mode over 170 steps:

| Task | `develop` | This PR | Remaining |
| --- | ---: | ---: | --- |
| `Isaac-Velocity-Rough-AnymalD` | 6.75 | 3.00 | step reset, command
resample, and interval-event `nonzero` |
| `Isaac-Lift-KukaAllegro-Camera` | 2.11 | 2.04 | step reset and command
resample `nonzero`; curriculum difficulty `.item()` (0.04 per step) |

PyTorch labels sync-debug mode a prototype that does not detect every
synchronization, and it does not see synchronizations issued by Warp, so
these counts are lower bounds.

## Validation

- The shared sampling refactor passed 257 tests across the existing
math, root-state event, and Lift configuration suites. The existing
event test now checks exact seeded samples, key order, missing axes,
fresh draws, range edits, and warm-cache CUDA synchronization. Eight
standalone equivalence checks also passed across CPU/CUDA,
float32/float64, and flat/nodal batch shapes. No new tests or test files
were added.
- Before the shared-sampler refactor, 205 focused tests passed, with
each file run in its own process: curriculum, observation, reward, and
termination managers; heading commands and mutable event ranges; DiffIK;
wrench composition; ray-caster and sensor-base behavior; marker
visualization; Lift and reorientation helpers; and the existing
joint-limit tests on both PhysX and OvPhysX, on CPU and CUDA. Kit tests
used the `isaacsim` extra, and OvPhysX used `ovphysx` with separate
CPU/GPU processes.
- Regression checks fail with the old curriculum accessor, stale drift,
and static marker behavior restored. Mutations also turn the retained
tests red for custom-noise aliasing, eager debug-visualization
refreshes, partial reward reset corruption, and missing reorientation
NaN statistics.
- Applied the test-audit skill: seven standalone tests were consolidated
into existing reward, wrench, reorientation, marker, ray-caster,
sensor-update, and Lift tests. Synchronization tests run on CUDA instead
of repeating the same bookkeeping on CPU. No new test functions or files
were added in the review-fix commit.
- Retained unique heading, curriculum snapshot, mutable-range, and
ANYmal symmetry coverage: there is no equivalent existing owner test.
The symmetry test checks the new permutation tables against the previous
independent index-assignment formulation.
- `uv run isaaclab -f` passed, including changelog checks against the
actual PR base, and `git diff --check` passed.
- The full test suite and training smoke runs have not been repeated on
this revision; benchmark figures above describe the earlier measured
revision.

## Release backport

- [x] <!-- backport-active-release --> Backport this pull request to the
active release branch after it merges into `develop`

## Checklist

- [x] I have read and understood the contribution guidelines.
- [x] I have run the pre-commit checks with `uv run --frozen isaaclab
-f`.
- [x] I have made corresponding changes to the documentation.
- [x] I have added tests that prove the behavior and checked the
regressions against the unfixed code.
- [x] I have added a changelog fragment for every touched source
package.
- [x] My name already exists in `CONTRIBUTORS.md`.
@StafaH
StafaH deleted the perf/scene-indices-proxy branch October 10, 2026 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation infrastructure isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants