Skip to content

Preserve slices through environment resets and their consumers - #8030

Merged
ooctipus merged 14 commits into
isaac-sim:developfrom
ooctipus:fix/reset-env-selector-contract
Sep 26, 2026
Merged

ooctipus merged 14 commits into
isaac-sim:developfrom
ooctipus:fix/reset-env-selector-contract

Conversation

@ooctipus

@ooctipus ooctipus commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Environment resets expanded slices into tensor indices before dispatch, forcing ordinary buffer operations and callbacks to use advanced indexing. Preserve the original slice through scenes, managers, reset events, curricula, and commands, and update the existing consumers to index directly or derive sample counts from slice bounds or selected data.

env.reset()                       # env_ids=slice(None)
env.reset(None)                   # same; None is normalized to slice(None)
env.reset(slice(1, None, 2))       # a subset
env.reset(env_ids=device_indices) # existing int32/int64 indices on env.device
env.reset(seed=42)                # seed and options are keyword-only

Native indexed operations reuse their existing device-index caches. OVPhysX deformable writers make strided selections contiguous on the device only where required by the native binding. Mask consumers fill slices directly. Cooldown and probabilistic filtering still produce indices for irregular selections. Host-only PhysX property setters construct the CPU indices required by their native API; recorders iterate host ranges.

Migration: custom reset callbacks must accept slices as well as device indices. Index buffers with the selector directly; use selected data shapes or len(range(env.num_envs)[env_ids]) for slice counts. The environment reset API trusts this contract and does not validate or transfer index tensors. None is still accepted and normalized to slice(None) (the default); Python sequences are outside the entry-point contract.

Also keep Newton gravity reset slices within the environment rows, excluding its trailing global-world entry. Fix partial camera/visual and OVPhysX asset resets, and remove the pour curriculum's selector-normalization helper. Native actuator masks retain the existing Warp kernel for device indices to avoid Torch indexed scalar uploads. These changes stay in existing consumers, with no new production modules or test files.

Related to #7975 and #8015.

Performance

Preserving a slice lets buffer owners use basic indexing and lets native consumers recognize a full reset. Expanding it to an index tensor at the environment boundary loses both opportunities. On the stock task below, full resets have 27–38% lower latency, saving 1.26–1.54 ms per call. Half resets improve by 18–28% across contiguous and strided selections. These are reset-path gains; the measurements do not establish a training-throughput improvement.

Measured IsaacContrib-Velocity-Rough-AnymalC on an RTX 5090 / Threadripper PRO 7965WX, with rendering disabled. Same seed and shared environment: Python 3.12.12, PyTorch 2.11.0, Warp 1.17.0, Newton 1.6.0rc1. Base: 9c7cfc643. PR: 66b13f79f, with the OVPhysX partial-slice fix at 4353a4b4d and final indexed-mask correction at dd0fa9730. Newton 8,192, Kit PhysX 4,096, and OVPhysX 1,024 were remeasured on the final head; the other rows use earlier measurements of the unchanged full/slice reset paths.

Warm public reset latency, milliseconds: base → PR (latency reduction). Includes scene writes, forward kinematics, and observation computation.

Backend Environments Full reset Contiguous 50% reset Strided 50% reset
Newton/MJWarp 128 3.83 → 2.41 (37%) 3.86 → 2.78 (28%) 3.78 → 2.83 (25%)
Newton/MJWarp 1,024 3.72 → 2.40 (36%) 3.68 → 2.79 (24%) 3.65 → 2.82 (23%)
Newton/MJWarp 4,096 3.76 → 2.35 (38%) — 3.73 → 2.81 (25%)
Newton/MJWarp 8,192 3.84 → 2.56 (33%) 3.86 → 2.77 (28%) 3.71 → 2.82 (24%)
Kit PhysX 1,024 5.01 → 3.55 (29%) 5.11 → 3.91 (24%) 5.12 → 3.89 (24%)
Kit PhysX 4,096 5.28 → 3.74 (29%) 5.33 → 4.26 (20%) 5.38 → 4.31 (20%)
OVPhysX 1,024 4.59 → 3.33 (27%) 4.64 → 3.80 (18%) 4.64 → 3.75 (19%)
Newton/MJWarp + history/delay 4,096 5.51 → 3.70 (33%) 5.43 → 4.14 (24%) 5.49 → 4.12 (25%)

The original 4,096-environment Newton run did not measure contiguous half resets (—).

The observation-buffer variant sets policy history_length=8 and delay_max_lag=3 on all eight observation terms. Its full reset saves 1.82 ms (33%).

The final consumer migration contributes a measurable additional gain: at 4,096 Newton environments, the preceding revision 3b4e893a0 took 3.17 ms for a full reset versus 2.35 ms with the consumers updated, a further 26% reduction. The corresponding half reset drops from 3.24 to 2.81 ms.

Control measurements: GPU-index resets and simulation steps

All values below are milliseconds, base → final PR head (dd0fa9730). Irregular resets use a fixed, preallocated GPU selection containing 12.5% of environments. The forced-reset step sets those environments' episode counters to time out through the normal termination path; it does not replace termination indices with slices. Every batch recorded exactly the requested reset count; ordinary-step batches had zero terminations. No policy inference or learner update is included.

Backend Environments Irregular public reset Ordinary step Step with 12.5% resets
Newton/MJWarp 8,192 3.78 → 3.83 22.89 → 22.83 26.52 → 26.59
Kit PhysX 4,096 5.18 → 5.35 42.07 → 41.47 66.12 → 65.29
OVPhysX 1,024 4.55 → 4.60 21.29 → 21.02 24.49 → 24.31

These controls show no consistent gain comparable to the slice-reset improvement. Repeating Kit PhysX 4,096 in reverse order changed the pre-correction irregular-reset comparison from 5.18 → 5.48 ms to 5.41 → 5.28 ms; the timing variation did not support claiming that 6% difference as a stable regression.

Profiling did reveal one extra scalar upload in the native actuator-mask path. The final correction retains the existing Warp kernel for GPU indices and direct writes for slices. A focused CUDA trace verifies zero copies and zero stream synchronizations in that mask operation for both int32 and int64 strided device indices.

Where the full-reset gain comes from: in five warmed Newton/MJWarp calls at 8,192 environments, the per-call Torch/CUDA event counts changed as follows. Profiling was performed separately from latency measurement.

Operation per full reset Base Final PR
Torch indexed reads (aten::index) 36 1
Torch indexed writes (aten::index_put_) 47 0
Host-to-device copies 32 2
CUDA stream synchronizations 36 6

The final irregular GPU-index path matches the baseline counts: 36 indexed reads, 47 indexed writes, 32 host-to-device copies, and 36 stream synchronizations. This PR does not make the entire reset transfer-free.

Measurement protocol and timing ranges

The expanded matrix ran base/PR sequentially on GPU 1, alternating their order across cases, and monitored for other compute processes on that GPU. One final OVPhysX run overlapped an unrelated process; its timings were discarded and the run was repeated on the idle GPU. Reported values are medians of seven batches of 50 calls, after warmup. The original 4,096-environment Newton row used seven batches of 100 calls. Each timed batch is synchronized at both ends; garbage collection is disabled during measurement. Reset cases have 10 warmup calls. Step batches start from a fresh seeded reset, then 50 warmup steps (20 for forced resets), outside the timer.

For the baseline, half resets use equivalent preallocated GPU indices; no artificial CPU upload is added. The PR uses slice(0, num_envs // 2) or slice(1, None, 2). Full resets call env.reset() on both versions. Irregular GPU indices are identical on both versions.

Full-reset batch ranges below are min–max milliseconds per call, not confidence intervals:

Backend Environments Base range PR range
Newton/MJWarp 128 3.78–3.96 2.37–2.53
Newton/MJWarp 1,024 3.69–3.80 2.36–2.51
Newton/MJWarp 4,096 3.73–3.82 2.35–2.39
Newton/MJWarp 8,192 3.73–3.88 2.55–2.60
Kit PhysX 1,024 4.99–5.08 3.53–3.60
Kit PhysX 4,096 5.24–5.39 3.68–3.80
OVPhysX 1,024 4.51–4.68 3.27–3.50
Newton/MJWarp + history/delay 4,096 5.47–5.70 3.67–3.79

Minimal reset timing loop after constructing the task and warming its simulation:

cfg, _ = resolve_task_config(
    "IsaacContrib-Velocity-Rough-AnymalC", "", overrides=(f"physics={backend}",)
)
cfg.scene.num_envs, cfg.sim.device, cfg.seed = num_envs, "cuda:0", 42
# Launch headless with visualizer=None, visualizer_explicit=True, then construct ManagerBasedRLEnv(cfg).
# Construct indices once, outside measurement; select the same environments on both revisions.
indices = torch.arange(num_envs, dtype=torch.int32, device=env.device)[1::2].contiguous()
operation = lambda: env.reset(env_ids=indices if baseline else slice(1, None, 2))
with torch.inference_mode():
    env.reset(seed=42)
    for _ in range(10):
        operation()
    gc.collect()
    gc.disable()
    samples_ms = []
    for _ in range(7):
        torch.cuda.synchronize()
        start = time.perf_counter()
        for _ in range(50):
            operation()
        torch.cuda.synchronize()
        samples_ms.append((time.perf_counter() - start) * 1000 / 50)
    gc.enable()
print(statistics.median(samples_ms), samples_ms)

Kuka Allegro Lift: aggregate environment-step FPS.

Additional measurements on Isaac-Lift-KukaAllegro, comparing base 9c7cfc643 with corrected PR head 7395df83d on the same hardware and protocol above (seven batches of 50 calls). Rendering is disabled; the default five-frame policy/proprioception/perception histories, point-cloud observations, contact sensors, curriculum, and reset-state bank remain enabled. Bank construction is outside timing. Newton and Kit PhysX use the default shape assortment.

FPS is num_envs / env.step() wall time, including physics, observations, rewards, termination, and any resets. Actions are zero; policy inference and optimizer updates are not included. Ordinary batches in the table recorded zero terminations; forced-reset batches timed out 12.5% of environments each step. Before/after reset counts match in every batch; Kit PhysX additionally recorded three natural terminations across its seven batches on each revision. No competing GPU compute process was observed in the reported Newton/Kit PhysX runs.

Backend Environments Ordinary FPS: base → PR Change FPS with 12.5% resets: base → PR Change
Newton/MJWarp 1,024 92,041 → 94,005 +2.1% 58,015 → 56,981 -1.8%
Newton/MJWarp 4,096 223,415 → 224,655 +0.6% 133,660 → 134,095 +0.3%
Kit PhysX 1,024 20,836 → 20,722 -0.5% 17,859 → 17,545 -1.8%

Full resets improve by 17–24% on these Kuka configurations, while ordinary FPS changes by −0.5% to +2.1% and forced-reset FPS by −1.8% to +0.3%. There is no consistent overall FPS gain, and these runs do not establish a training-throughput improvement.

Warm reset latency in milliseconds (base → PR):

Backend Environments Full reset Contiguous 50% reset Strided 50% reset Irregular 12.5% reset
Newton/MJWarp 1,024 6.35 → 4.92 6.37 → 5.31 6.31 → 5.39 6.42 → 6.28
Newton/MJWarp 4,096 6.31 → 4.82 6.38 → 5.46 6.19 → 5.42 6.15 → 6.38
Kit PhysX 1,024 7.13 → 5.93 7.13 → 6.52 7.51 → 6.30 7.07 → 7.24

Batch timing ranges (min–max milliseconds per step; not confidence intervals):

Backend Environments Ordinary: base / PR With 12.5% resets: base / PR
Newton/MJWarp 1,024 10.93–11.20 / 10.74–10.98 17.40–18.18 / 17.57–18.27
Newton/MJWarp 4,096 18.13–18.50 / 18.05–18.36 30.27–30.82 / 30.25–30.94
Kit PhysX 1,024 48.41–55.77 / 48.85–55.75 56.68–63.34 / 58.05–62.67

The benchmark also exposed a slice regression in Newton gravity randomization: its native gravity array includes a trailing global-world row, which a full slice incorrectly selected. The fix limits the environment-facing view to [:env.num_envs], without copying or converting indices. The existing gravity test file now checks full, strided, negative-bound, empty, and tensor selectors while preserving that global row; the regression fails before the fix and passes after it.

OVPhysX timing remains inconclusive and is excluded from the tables: repeated attempts overlapped unrelated GPU jobs. On the final baseline attempt, a cloner test process was first detected 0.13 seconds after the result file was written, near teardown; the 2-second monitoring interval does not establish an uncontended final batch. Its default task also uses a cube instead of the shape assortment.

Validation

  • Kuka benchmarking exposed the Newton global-world gravity row regression; added coverage in the existing gravity test file, verified failure before the fix, and all three gravity tests passed after it. Full, contiguous, strided, and irregular Kuka resets and normal/forced-reset steps completed on Newton, Kit PhysX, and OVPhysX. Pre-commit passed on 7395df83d.
  • 178 focused cases passed, including CPU/CUDA environment resets, PhysX/Newton cached selector views, actuator parameters, event cooldowns, wrenches, task configuration, camera resets, renderer writes, and a real Anymal strided reset/step.
  • Extended existing tests; 17 regression cases fail on the preceding commit.
  • Expanded benchmarking exposed missing OVPhysX partial-slice support and one scalar upload in the shared native actuator reset path; both were fixed. Extended existing shared selector tests to include OVPhysX: 22 CPU/CUDA selector and binding checks passed, with failures verified before the fixes. All 11 existing native actuator tests also passed; no new test files were added.
  • CUDA profiling of five partial-mask calls: five host-to-device index uploads before, zero after. Native slice selectors share cached device storage, except OVPhysX deformables must provide contiguous indices to their binding. These checks do not claim the entire environment reset is transfer-free.
  • Audited changed files: no new production symbols or test modules. Repository pre-commit and git diff --check passed. Changelog checks used the upstream branch base because the fork's develop ref is stale.

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.
  • I have updated documentation and added migration guidance in changelog fragments.
  • I have verified regression failures before the fix and passes after it.
  • My name already exists in CONTRIBUTORS.md.

@ooctipus
ooctipus requested a review from a team September 25, 2026 12:48
@ooctipus ooctipus self-assigned this Sep 25, 2026
@github-actions github-actions Bot added bug Something isn't working isaac-lab Related to Isaac Lab team labels Sep 25, 2026
@ooctipus ooctipus added this to the Isaac Lab 3.0 GA milestone Sep 25, 2026
@ooctipus ooctipus moved this to In progress in Isaac Lab Sep 25, 2026
@greptile-apps

greptile-apps Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[High risk] Changes the contract for environment reset selectors across the framework.

The PR appears safe to merge; no actionable regression was established.

Summary

The PR defines a device-resident selector contract for environment resets and reset events, resolves slices through the scene’s existing index buffer, and converts PhysX material indices at its native boundary.

  • Updates reset and event-manager documentation, changelog guidance, and selector regression tests.

Reviews (1) · Last reviewed commit: "Define device-resident selectors for env..."

@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 reset-selector resolver consistently normalizes reset paths to device tensors, but EventManager.apply now advertises the reset-only selector restriction for every event mode even though non-reset modes still forward selectors unchanged.

  • Design and architecture: Centralizing reset selector resolution on InteractiveScene._ALL_INDICES is coherent and keeps backend-specific int32 conversion at the PhysX boundary. The mode-independent EventManager.apply signature, however, does not accurately represent the distinct reset and non-reset contracts.
  • API: EventManager.apply is shared by all event modes, but its annotation was narrowed to torch.Tensor | slice | None while only reset mode enforces that contract. Existing sequence-based calls for custom or startup modes remain functional at runtime but are now rejected by static checking; retain the broader annotation or provide mode-specific overloads.
  • Implementation: The reset paths resolve selectors before callbacks and mutation, and cooldown filtering now uniformly operates on tensors. No implementation defect is established beyond the inaccurate mode-wide API annotation.

Minor fixes needed. Posted 1 actionable finding inline.

Automated review; human maintainers own approval decisions.

self,
mode: str,
env_ids: Sequence[int] | None = None,
env_ids: torch.Tensor | slice | None = None,

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.

🔵 Suggestion · Api — Annotation narrows non-reset event modes too

This signature covers every mode, but only "reset" is validated; line 282 still forwards env_ids unchanged for custom/startup modes, where sequences remain functional. Retyping them to torch.Tensor | slice | None breaks static checking for callers such as apply("custom", env_ids=[...]) even though their runtime behavior is unchanged. Keep Sequence[int] in the annotation for non-reset modes (or use overloads) while retaining reset-mode validation.

@ooctipus ooctipus changed the title Define device-resident selectors for environment resets Use slice defaults and device indices for resets Sep 25, 2026
@ooctipus
ooctipus requested a review from hujc7 as a code owner September 25, 2026 20:08
@ooctipus ooctipus changed the title Use slice defaults and device indices for resets Preserve slices through environment buffer resets Sep 25, 2026
@ooctipus ooctipus changed the title Preserve slices through environment buffer resets Preserve slices through environment resets and their consumers Sep 25, 2026
ooctipus and others added 3 commits September 25, 2026 15:01
Warp reset kernels take (env_ids, env_start, env_step): an empty index
array selects start + i * step, so slices launch without materializing
indices and index tensors of either integer dtype pass through without
conversion. Consumers index with the selector directly and build indices
only where they form an irregular subset (probability filters, partition
sampling, buffer-restore splits, partial-view rows).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@isaaclab-bot isaaclab-bot Bot removed the ci:run-docker Trigger the on-demand Docker and GPU CI workflow label Sep 26, 2026
Replace the slice/tensor branches in task reset consumers with a single
env.scene._ALL_INDICES[env_ids] view, which covers both selector kinds.
reset_to_target draws its probability subset as a mask and writes through
the mask APIs instead of materializing indices; ChainedResetTerms forwards
the selector untouched unless it filters by probability.

Isaac-Lift-KukaAllegro (Newton/MJWarp, 1024 envs, two alternating A/B
runs) is unchanged within noise: reset-bank build 1.63-1.65 s, full reset
~4.8 ms, strided half reset ~5.3 ms.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ooctipus

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 26, 2026
- reset_to_target: go back to index writes through a one-line selector
  view. The mask write launched an empty PhysX transform update when no
  environment was picked, and drew a different random stream, which moved
  the Lift/Reorient reset banks and their golden images.
- Camera: fall back to NumPy indices for negative-step slices, which torch
  cannot slice.
- Multirotor/Thruster: accept slices and size thruster resampling from
  the selected slice instead of assuming every slice covers all envs.
- annotate_demos: omit the reset_to selector instead of passing None.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ooctipus

Copy link
Copy Markdown
Collaborator Author

run-ci

@github-actions github-actions Bot added the isaac-mimic Related to Isaac Mimic team label Sep 26, 2026
@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 26, 2026
def reset(
self, seed: int | None = None, env_ids: Sequence[int] | None = None, options: dict[str, Any] | None = None
self,
env_ids: torch.Tensor | slice = slice(None),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We will need to preserve None option everywhere to avoid breaking

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

maybe None turns into slice(None)

ManagerBasedEnv.reset/reset_to and EventManager.reset keep slice(None) as
the default but accept None again, normalizing it to slice(None) on entry
so existing callers keep working; EventManager.apply(mode="reset") does
the same, as it did before this PR. annotate_demos is back to passing None
and covers the path end to end.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ooctipus

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 26, 2026
@ooctipus
ooctipus merged commit 8b29905 into isaac-sim:develop Sep 26, 2026
53 checks passed
@isaaclab-bot

isaaclab-bot Bot commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

Backported to release/3.0.0 as ca821da.

isaaclab-bot Bot pushed a commit that referenced this pull request Sep 26, 2026
## Description

Environment resets expanded slices into tensor indices before dispatch,
forcing ordinary buffer operations and callbacks to use advanced
indexing. Preserve the original slice through scenes, managers, reset
events, curricula, and commands, and update the existing consumers to
index directly or derive sample counts from slice bounds or selected
data.

```python
env.reset()                       # env_ids=slice(None)
env.reset(None)                   # same; None is normalized to slice(None)
env.reset(slice(1, None, 2))       # a subset
env.reset(env_ids=device_indices) # existing int32/int64 indices on env.device
env.reset(seed=42)                # seed and options are keyword-only
```

Native indexed operations reuse their existing device-index caches.
OVPhysX deformable writers make strided selections contiguous on the
device only where required by the native binding. Mask consumers fill
slices directly. Cooldown and probabilistic filtering still produce
indices for irregular selections. Host-only PhysX property setters
construct the CPU indices required by their native API; recorders
iterate host ranges.

**Migration:** custom reset callbacks must accept slices as well as
device indices. Index buffers with the selector directly; use selected
data shapes or `len(range(env.num_envs)[env_ids])` for slice counts. The
environment reset API trusts this contract and does not validate or
transfer index tensors. `None` is still accepted and normalized to
`slice(None)` (the default); Python sequences are outside the
entry-point contract.

Also keep Newton gravity reset slices within the environment rows,
excluding its trailing global-world entry. Fix partial camera/visual and
OVPhysX asset resets, and remove the pour curriculum's
selector-normalization helper. Native actuator masks retain the existing
Warp kernel for device indices to avoid Torch indexed scalar uploads.
These changes stay in existing consumers, with no new production modules
or test files.

Related to #7975 and #8015.

## Performance

Preserving a slice lets buffer owners use basic indexing and lets native
consumers recognize a full reset. Expanding it to an index tensor at the
environment boundary loses both opportunities. On the stock task below,
full resets have **27–38% lower latency**, saving **1.26–1.54 ms per
call**. Half resets improve by **18–28%** across contiguous and strided
selections. These are reset-path gains; the measurements do **not**
establish a training-throughput improvement.

Measured `IsaacContrib-Velocity-Rough-AnymalC` on an RTX 5090 /
Threadripper PRO 7965WX, with rendering disabled. Same seed and shared
environment: Python 3.12.12, PyTorch 2.11.0, Warp 1.17.0, Newton
1.6.0rc1. Base: `9c7cfc643`. PR: `66b13f79f`, with the OVPhysX
partial-slice fix at `4353a4b4d` and final indexed-mask correction at
`dd0fa9730`. Newton 8,192, Kit PhysX 4,096, and OVPhysX 1,024 were
remeasured on the final head; the other rows use earlier measurements of
the unchanged full/slice reset paths.

**Warm public reset latency, milliseconds: base → PR (latency
reduction).** Includes scene writes, forward kinematics, and observation
computation.

| Backend | Environments | Full reset | Contiguous 50% reset | Strided
50% reset |
| --- | ---: | ---: | ---: | ---: |
| Newton/MJWarp | 128 | 3.83 → 2.41 (37%) | 3.86 → 2.78 (28%) | 3.78 →
2.83 (25%) |
| Newton/MJWarp | 1,024 | 3.72 → 2.40 (36%) | 3.68 → 2.79 (24%) | 3.65 →
2.82 (23%) |
| Newton/MJWarp | 4,096 | 3.76 → 2.35 (38%) | — | 3.73 → 2.81 (25%) |
| Newton/MJWarp | 8,192 | 3.84 → 2.56 (33%) | 3.86 → 2.77 (28%) | 3.71 →
2.82 (24%) |
| Kit PhysX | 1,024 | 5.01 → 3.55 (29%) | 5.11 → 3.91 (24%) | 5.12 →
3.89 (24%) |
| Kit PhysX | 4,096 | 5.28 → 3.74 (29%) | 5.33 → 4.26 (20%) | 5.38 →
4.31 (20%) |
| OVPhysX | 1,024 | 4.59 → 3.33 (27%) | 4.64 → 3.80 (18%) | 4.64 → 3.75
(19%) |
| Newton/MJWarp + history/delay | 4,096 | 5.51 → 3.70 (33%) | 5.43 →
4.14 (24%) | 5.49 → 4.12 (25%) |

The original 4,096-environment Newton run did not measure contiguous
half resets (—).

The observation-buffer variant sets policy `history_length=8` and
`delay_max_lag=3` on all eight observation terms. Its full reset saves
**1.82 ms (33%)**.

The final consumer migration contributes a measurable additional gain:
at 4,096 Newton environments, the preceding revision `3b4e893a0` took
**3.17 ms** for a full reset versus **2.35 ms** with the consumers
updated, a further **26% reduction**. The corresponding half reset drops
from 3.24 to 2.81 ms.

<details>
<summary>Control measurements: GPU-index resets and simulation
steps</summary>

All values below are milliseconds, base → final PR head (`dd0fa9730`).
Irregular resets use a fixed, preallocated GPU selection containing
12.5% of environments. The forced-reset step sets those environments'
episode counters to time out through the normal termination path; it
does not replace termination indices with slices. Every batch recorded
exactly the requested reset count; ordinary-step batches had zero
terminations. No policy inference or learner update is included.

| Backend | Environments | Irregular public reset | Ordinary step | Step
with 12.5% resets |
| --- | ---: | ---: | ---: | ---: |
| Newton/MJWarp | 8,192 | 3.78 → 3.83 | 22.89 → 22.83 | 26.52 → 26.59 |
| Kit PhysX | 4,096 | 5.18 → 5.35 | 42.07 → 41.47 | 66.12 → 65.29 |
| OVPhysX | 1,024 | 4.55 → 4.60 | 21.29 → 21.02 | 24.49 → 24.31 |

These controls show no consistent gain comparable to the slice-reset
improvement. Repeating Kit PhysX 4,096 in reverse order changed the
pre-correction irregular-reset comparison from 5.18 → 5.48 ms to 5.41 →
5.28 ms; the timing variation did not support claiming that 6%
difference as a stable regression.

Profiling did reveal one extra scalar upload in the native actuator-mask
path. The final correction retains the existing Warp kernel for GPU
indices and direct writes for slices. A focused CUDA trace verifies zero
copies and zero stream synchronizations in that mask operation for both
int32 and int64 strided device indices.

</details>

**Where the full-reset gain comes from:** in five warmed Newton/MJWarp
calls at 8,192 environments, the per-call Torch/CUDA event counts
changed as follows. Profiling was performed separately from latency
measurement.

| Operation per full reset | Base | Final PR |
| --- | ---: | ---: |
| Torch indexed reads (`aten::index`) | 36 | 1 |
| Torch indexed writes (`aten::index_put_`) | 47 | 0 |
| Host-to-device copies | 32 | 2 |
| CUDA stream synchronizations | 36 | 6 |

The final irregular GPU-index path matches the baseline counts: 36
indexed reads, 47 indexed writes, 32 host-to-device copies, and 36
stream synchronizations. This PR does not make the entire reset
transfer-free.

<details>
<summary>Measurement protocol and timing ranges</summary>

The expanded matrix ran base/PR sequentially on GPU 1, alternating their
order across cases, and monitored for other compute processes on that
GPU. One final OVPhysX run overlapped an unrelated process; its timings
were discarded and the run was repeated on the idle GPU. Reported values
are medians of **seven batches of 50 calls**, after warmup. The original
4,096-environment Newton row used seven batches of 100 calls. Each timed
batch is synchronized at both ends; garbage collection is disabled
during measurement. Reset cases have 10 warmup calls. Step batches start
from a fresh seeded reset, then 50 warmup steps (20 for forced resets),
outside the timer.

For the baseline, half resets use equivalent preallocated GPU indices;
no artificial CPU upload is added. The PR uses `slice(0, num_envs // 2)`
or `slice(1, None, 2)`. Full resets call `env.reset()` on both versions.
Irregular GPU indices are identical on both versions.

Full-reset batch ranges below are min–max milliseconds per call, not
confidence intervals:

| Backend | Environments | Base range | PR range |
| --- | ---: | ---: | ---: |
| Newton/MJWarp | 128 | 3.78–3.96 | 2.37–2.53 |
| Newton/MJWarp | 1,024 | 3.69–3.80 | 2.36–2.51 |
| Newton/MJWarp | 4,096 | 3.73–3.82 | 2.35–2.39 |
| Newton/MJWarp | 8,192 | 3.73–3.88 | 2.55–2.60 |
| Kit PhysX | 1,024 | 4.99–5.08 | 3.53–3.60 |
| Kit PhysX | 4,096 | 5.24–5.39 | 3.68–3.80 |
| OVPhysX | 1,024 | 4.51–4.68 | 3.27–3.50 |
| Newton/MJWarp + history/delay | 4,096 | 5.47–5.70 | 3.67–3.79 |

Minimal reset timing loop after constructing the task and warming its
simulation:

```python
cfg, _ = resolve_task_config(
    "IsaacContrib-Velocity-Rough-AnymalC", "", overrides=(f"physics={backend}",)
)
cfg.scene.num_envs, cfg.sim.device, cfg.seed = num_envs, "cuda:0", 42
# Launch headless with visualizer=None, visualizer_explicit=True, then construct ManagerBasedRLEnv(cfg).
# Construct indices once, outside measurement; select the same environments on both revisions.
indices = torch.arange(num_envs, dtype=torch.int32, device=env.device)[1::2].contiguous()
operation = lambda: env.reset(env_ids=indices if baseline else slice(1, None, 2))
with torch.inference_mode():
    env.reset(seed=42)
    for _ in range(10):
        operation()
    gc.collect()
    gc.disable()
    samples_ms = []
    for _ in range(7):
        torch.cuda.synchronize()
        start = time.perf_counter()
        for _ in range(50):
            operation()
        torch.cuda.synchronize()
        samples_ms.append((time.perf_counter() - start) * 1000 / 50)
    gc.enable()
print(statistics.median(samples_ms), samples_ms)
```

</details>

**Kuka Allegro Lift: aggregate environment-step FPS.**

Additional measurements on `Isaac-Lift-KukaAllegro`, comparing base
`9c7cfc643` with corrected PR head `7395df83d` on the same hardware and
protocol above (seven batches of 50 calls). Rendering is disabled; the
default five-frame policy/proprioception/perception histories,
point-cloud observations, contact sensors, curriculum, and reset-state
bank remain enabled. Bank construction is outside timing. Newton and Kit
PhysX use the default shape assortment.

FPS is `num_envs / env.step()` wall time, including physics,
observations, rewards, termination, and any resets. Actions are zero;
policy inference and optimizer updates are not included. Ordinary
batches in the table recorded zero terminations; forced-reset batches
timed out 12.5% of environments each step. Before/after reset counts
match in every batch; Kit PhysX additionally recorded three natural
terminations across its seven batches on each revision. No competing GPU
compute process was observed in the reported Newton/Kit PhysX runs.

| Backend | Environments | Ordinary FPS: base → PR | Change | FPS with
12.5% resets: base → PR | Change |
| --- | ---: | ---: | ---: | ---: | ---: |
| Newton/MJWarp | 1,024 | 92,041 → 94,005 | +2.1% | 58,015 → 56,981 |
-1.8% |
| Newton/MJWarp | 4,096 | 223,415 → 224,655 | +0.6% | 133,660 → 134,095
| +0.3% |
| Kit PhysX | 1,024 | 20,836 → 20,722 | -0.5% | 17,859 → 17,545 | -1.8%
|

Full resets improve by **17–24%** on these Kuka configurations, while
ordinary FPS changes by **−0.5% to +2.1%** and forced-reset FPS by
**−1.8% to +0.3%**. There is no consistent overall FPS gain, and these
runs do not establish a training-throughput improvement.

Warm reset latency in milliseconds (base → PR):

| Backend | Environments | Full reset | Contiguous 50% reset | Strided
50% reset | Irregular 12.5% reset |
| --- | ---: | ---: | ---: | ---: | ---: |
| Newton/MJWarp | 1,024 | 6.35 → 4.92 | 6.37 → 5.31 | 6.31 → 5.39 | 6.42
→ 6.28 |
| Newton/MJWarp | 4,096 | 6.31 → 4.82 | 6.38 → 5.46 | 6.19 → 5.42 | 6.15
→ 6.38 |
| Kit PhysX | 1,024 | 7.13 → 5.93 | 7.13 → 6.52 | 7.51 → 6.30 | 7.07 →
7.24 |

Batch timing ranges (min–max milliseconds per step; not confidence
intervals):

| Backend | Environments | Ordinary: base / PR | With 12.5% resets: base
/ PR |
| --- | ---: | ---: | ---: |
| Newton/MJWarp | 1,024 | 10.93–11.20 / 10.74–10.98 | 17.40–18.18 /
17.57–18.27 |
| Newton/MJWarp | 4,096 | 18.13–18.50 / 18.05–18.36 | 30.27–30.82 /
30.25–30.94 |
| Kit PhysX | 1,024 | 48.41–55.77 / 48.85–55.75 | 56.68–63.34 /
58.05–62.67 |

The benchmark also exposed a slice regression in Newton gravity
randomization: its native gravity array includes a trailing global-world
row, which a full slice incorrectly selected. The fix limits the
environment-facing view to `[:env.num_envs]`, without copying or
converting indices. The existing gravity test file now checks full,
strided, negative-bound, empty, and tensor selectors while preserving
that global row; the regression fails before the fix and passes after
it.

OVPhysX timing remains inconclusive and is excluded from the tables:
repeated attempts overlapped unrelated GPU jobs. On the final baseline
attempt, a cloner test process was first detected 0.13 seconds after the
result file was written, near teardown; the 2-second monitoring interval
does not establish an uncontended final batch. Its default task also
uses a cube instead of the shape assortment.

## Validation

- Kuka benchmarking exposed the Newton global-world gravity row
regression; added coverage in the existing gravity test file, verified
failure before the fix, and all three gravity tests passed after it.
Full, contiguous, strided, and irregular Kuka resets and
normal/forced-reset steps completed on Newton, Kit PhysX, and OVPhysX.
Pre-commit passed on `7395df83d`.
- 178 focused cases passed, including CPU/CUDA environment resets,
PhysX/Newton cached selector views, actuator parameters, event
cooldowns, wrenches, task configuration, camera resets, renderer writes,
and a real Anymal strided reset/step.
- Extended existing tests; 17 regression cases fail on the preceding
commit.
- Expanded benchmarking exposed missing OVPhysX partial-slice support
and one scalar upload in the shared native actuator reset path; both
were fixed. Extended existing shared selector tests to include OVPhysX:
22 CPU/CUDA selector and binding checks passed, with failures verified
before the fixes. All 11 existing native actuator tests also passed; no
new test files were added.
- CUDA profiling of five partial-mask calls: five host-to-device index
uploads before, zero after. Native slice selectors share cached device
storage, except OVPhysX deformables must provide contiguous indices to
their binding. These checks do not claim the entire environment reset is
transfer-free.
- Audited changed files: no new production symbols or test modules.
Repository pre-commit and `git diff --check` passed. Changelog checks
used the upstream branch base because the fork's `develop` ref is stale.

## 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.
- [x] I have updated documentation and added migration guidance in
changelog fragments.
- [x] I have verified regression failures before the fix and passes
after it.
- [x] My name already exists in CONTRIBUTORS.md.

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>

(cherry picked from commit 8b29905)
ooctipus added a commit that referenced this pull request Sep 26, 2026
## Description

With #8030 merged, this PR now extends the existing reset-event test
instead of adding selector conversion or a separate test module.

Two cases add coverage:
- Reset one environment first, then reset a group containing both
cooling-down and never-reset environments.
- Pass `None` directly to `EventManager.apply("reset", ...)` and verify
it becomes a full slice.

The test change is **+9 / -3 lines (net +6)**. It reuses the existing
fixture, callbacks, and reference calculation. There are no production
changes or new test files. The original contributor entry is retained,
and the changelog is a test-only skip fragment.

## Validation

- Existing event-manager test module: **19 CPU/CUDA cases passed**.
- Removing `None` normalization makes the new selector case fail.
- Replacing per-environment first-trigger eligibility with a group-wide
check makes the extended reset cases fail; the previous reset test did
not catch this.
- `uv run isaaclab -f`, including the changelog check, and `git diff
--check` passed.

Related to #7975 and #8030. This PR does not restore list/tuple
selectors, which are outside the new reset contract.

## Release backport

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

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

With #8030 merged, this PR now extends the existing reset-event test
instead of adding selector conversion or a separate test module.

Two cases add coverage:
- Reset one environment first, then reset a group containing both
cooling-down and never-reset environments.
- Pass `None` directly to `EventManager.apply("reset", ...)` and verify
it becomes a full slice.

The test change is **+9 / -3 lines (net +6)**. It reuses the existing
fixture, callbacks, and reference calculation. There are no production
changes or new test files. The original contributor entry is retained,
and the changelog is a test-only skip fragment.

## Validation

- Existing event-manager test module: **19 CPU/CUDA cases passed**.
- Removing `None` normalization makes the new selector case fail.
- Replacing per-environment first-trigger eligibility with a group-wide
check makes the extended reset cases fail; the previous reset test did
not catch this.
- `uv run isaaclab -f`, including the changelog check, and `git diff
--check` passed.

Related to #7975 and #8030. This PR does not restore list/tuple
selectors, which are outside the new reset contract.

## Release backport

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

Signed-off-by: Yuguo Shan <[email protected]>
Co-authored-by: Yuguo Shan <[email protected]>
Co-authored-by: Octi Zhang <[email protected]>

(cherry picked from commit ec7d35b)
@ooctipus
ooctipus deleted the fix/reset-env-selector-contract branch October 14, 2026 14:28
qianl-nv added a commit to isaac-sim/IsaacLab-Arena that referenced this pull request Oct 23, 2026
Update Arena to the Isaac Lab 3.0.0 GA pin and Isaac Sim 6.2. Keep the
Isaac Sim base image while installing the pinned Lab and Arena source
trees from their frozen uv locks.

## Why this change?

Arena was on Lab 3.0 EA and Isaac Sim 6.1. Update to the [Isaac Lab
v3.0.0
release](https://github.com/isaac-sim/IsaacLab/releases/tag/v3.0.0),
pinned at
[`e3f7d9ff1f5d7f8280de3ece9000b7117f66bcf4`](isaac-sim/IsaacLab@e3f7d9f),
and adapt Arena to its released APIs and dependencies.

## What changes?

### Docker and uv workflow

- Follow the uv-based Docker installation introduced by Isaac Lab [PR
#7405](isaac-sim/IsaacLab#7405) and [commit
`eed50f77c53`](isaac-sim/IsaacLab@eed50f77c53),
while retaining Arena's Isaac Sim base-image stages and editable Lab
source.
- Interactive container shells alias `python` and `python3` to
`isaaclab.sh -p`, and `pytest` to `isaaclab.sh -p -m pytest`, so
commands initialize Isaac Sim and execute from `/opt/isaaclab-venv`.
- Non-interactive runtime and CI commands invoke `isaaclab.sh -p`
explicitly; build-time package operations use `uv pip` or
`/opt/isaaclab-venv/bin/python`. `/isaac-sim/python.sh` is no longer a
supported Arena entry point because it bypasses the Lab launcher and the
locked Lab virtual environment.
- Continue building from the Isaac Sim 6.2 image. Copy in uv 0.12.9 and
create `/opt/isaaclab-venv` with Isaac Sim's Kit Python.
- Sync third-party dependencies from the pinned Isaac Lab submodule's
frozen `uv.lock`. The metadata-only stage skips all local path packages;
after the complete submodule is copied, a second sync installs its
editable packages.
- Overlay Arena's non-Lab dependencies from Arena's frozen lock with `uv
sync --inexact`, then install Arena editable into the same environment.
- Pin uv 0.12.9 in Docker and native CI. Regenerating the lockfile with
the newer serializer puts Arena's Linux x86_64 constraint in top-level
`resolution-markers` and `supported-markers` and remove it from uv lock
edges.

### Torch 2.11 and CUDA 13 handling

- Isaac Lab [PR #8372](isaac-sim/IsaacLab#8372)
deliberately selects Torch 2.11.0 on CUDA 13.0. Torch 2.12's CUDA 13
NCCL 2.29 can fail beside Kit RTX or OVRTX on Blackwell because of a
driver shared-memory accounting issue. Torch 2.11 uses NCCL 2.28.9 and
avoids that failure while retaining Isaac Lab's
deferred-CUDA-initialization workaround.
- Native uv routes `torch==2.11.0` and `torchvision==0.26.0` to the
`cu130` PyTorch index. Docker takes those versions from Lab's frozen
lock instead of duplicating them in a hand-written constraint list.
Arena drops its direct `torchaudio` dependency, matching Lab.
- Build cuRobo with the CUDA 13.0 toolkit and
`CUDA_HOME=/usr/local/cuda-13.0`, matching PyTorch's CUDA major version.

### Other API and released-stack changes

- **Environment reset selectors — Lab [PR
#8030](isaac-sim/IsaacLab#8030) and [PR
#8015](isaac-sim/IsaacLab#8015 accept Lab's
tensor, slice, and `None` environment selections in Arena's environment
and recorder reset paths. This is API compatibility, no behavior change.
- **Camera observations — Lab [PR
#8051](isaac-sim/IsaacLab#8051 replace the
removed generic `mdp.image` term with the RGB, depth, normals, or
segmentation observation function selected for each modality.
Unsupported data types now fail explicitly.
- **Newton camera pose propagation — Lab [issue
#7676](isaac-sim/IsaacLab#7676), [PR
#7691](isaac-sim/IsaacLab#7691), and release
backport [PR #7935](isaac-sim/IsaacLab#7935
Lab 3.0 now mirrors Newton `FrameView` pose writes into Fabric so RTX
sees camera movement. Remove Arena [PR
#1196](#1196) and its
`CameraPoseWriter` USD workaround. Camera-extrinsics variations now use
Lab `set_local_poses()` directly; retained tests cover rendered images
and reported poses under PhysX and Newton with Fabric enabled and
disabled.
- **Runtime camera intrinsics — Lab [PR
#7916](isaac-sim/IsaacLab#7916 replace
private USD sensor access and `_update_intrinsic_matrices()` with
`Camera.set_intrinsic_matrices()`. Lab's ordinary pinhole runtime API
enforces square pixels, so Arena now samples one focal-length delta and
applies it to both `fx` and `fy`. **Note:** intrinsics variation has an
pre-existing bug before this Lab upgrade which results in env_0 camera
params being used for all parallel envs. Fix will go in a separate PR.
- **Clone-plan topology — Lab [PR
#8045](isaac-sim/IsaacLab#8045), backported in
[PR #8073](isaac-sim/IsaacLab#8073 resolve
representative scene geometry through asset-prototype IDs, prototype
paths, and clone-plan topology instead of the removed
`cloner.query.iter_sources()` helper. arena_world_scene_access.py was
updated to essentially re-implement the removed helper.
- **Franka presets — Lab [PR
#8169](isaac-sim/IsaacLab#8169) and [PR
#8170](isaac-sim/IsaacLab#8170 select
`FRANKA_PANDA_LEGACY_CFG` and `FRANKA_PANDA_LEGACY_HIGH_PD_CFG`
explicitly after Lab made the flat Franka asset the default and
introduced shared minimal presets. This keeps Arena's nested `/panda`
hierarchy, legacy joint names, and existing actuator grouping.
- **Replicator kitchen USD — Isaac Sim 6.2 asset update:** update tests
for `kitchen_peninsula.usda`, which now exposes 50 physics roots instead
of 56. Its `_OnlineVisual` physics roots decrease from 24 to 18, and the
previously discovered `_OnlineVisual` articulation is no longer present.
- Unit test pick and place success speed thresholds were relax due to
large observed residual speed. Root cause unknown yet.

## Validation

Passing local checks:

- `uv lock --check --no-python-downloads` with uv 0.12.9
- Docker build and Isaac Sim startup/import smoke checks with Torch
2.11.0+cu130 and NCCL 2.28.9
- All RL and IL sample workflow replay and inference commands are
validated and producing expected success rate.

---------

Signed-off-by: Qian Lin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working isaac-lab Related to Isaac Lab team isaac-mimic Related to Isaac Mimic team

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants