Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a823a25
Share success-guided reset-state sampling across tasks
maxkra15 Oct 29, 2026
45002e1
chore: Merge main into PR #8872
maxkra15 Oct 29, 2026
f7d1c09
chore: Merge main into PR #8872
maxkra15 Oct 30, 2026
fcfee1f
chore: Merge main into PR #8872
maxkra15 Nov 2, 2026
97f93b2
chore: Merge main into PR #8872
maxkra15 Nov 3, 2026
e28a794
chore: Merge main into PR #8872
maxkra15 Nov 4, 2026
51fc7f6
chore: Merge main into PR #8872
maxkra15 Nov 5, 2026
ea99b61
chore: Merge main into PR #8872
maxkra15 Nov 6, 2026
f0b3a15
Merge shared reset sampler foundation
maxkra15 Nov 6, 2026
f394085
Add validated reset buffers and sparse pickup
maxkra15 Nov 6, 2026
327d911
Merge existing reset sampler PR history
maxkra15 Nov 6, 2026
d6a30b1
Address reset buffer and pickup review findings
maxkra15 Nov 7, 2026
64f67b6
Fix cube pickup configuration and smoke collection
maxkra15 Nov 9, 2026
92d6968
chore: Merge main into PR #8872
maxkra15 Nov 9, 2026
97715ea
Fix reset catalog persistence and replay validation
maxkra15 Nov 9, 2026
0ec4a73
Fix seeded pickup resets and catalog ownership
maxkra15 Nov 9, 2026
e9f4eb8
Respect the robot frame in scripted pickup goals
maxkra15 Nov 10, 2026
f05f816
Fix reset diagnostics and simplify pickup sampling
maxkra15 Nov 10, 2026
e6d93ec
chore: Merge main into PR #8872
maxkra15 Nov 10, 2026
0dd6ec5
chore: Merge main into PR #8872
maxkra15 Nov 11, 2026
a17f7e0
Simplify reset sampling configuration and verify pickup goals
maxkra15 Nov 11, 2026
e4b4b1b
chore: Merge main into PR #8872
maxkra15 Nov 12, 2026
8d7bb85
chore: Merge main into PR #8872
maxkra15 Nov 13, 2026
cf0f8a5
chore: Merge main into PR #8872
maxkra15 Nov 16, 2026
04c220c
Add illustrated sparse pickup walkthrough
maxkra15 Nov 16, 2026
90779d9
Separate reset storage from collection and scoring
maxkra15 Nov 16, 2026
e6b5b9c
Make reset replay native and reuse existing task events
maxkra15 Nov 16, 2026
d42f0a2
chore: Merge main into PR #8872
maxkra15 Nov 17, 2026
93c9f61
Clarify reset flow and scoring names
maxkra15 Nov 17, 2026
f18c092
Clarify reset selection and fix outcome attribution
maxkra15 Nov 17, 2026
3c6aad3
chore: Merge main into PR #8872
maxkra15 Nov 18, 2026
446bbcc
Address reset sampler review feedback
maxkra15 Nov 18, 2026
b34bf37
chore: Merge main into PR #8872
maxkra15 Nov 19, 2026
7fb6908
Address reset sampler ownership and naming review
maxkra15 Nov 19, 2026
ae85da7
Illustrate success-guided reset sampling
maxkra15 Nov 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,9 @@ source/_isaaclab_testing/test/rendering/golden_images/**/*.png filter=lfs diff=l
# Generated actuator plots are reviewed as rendered images rather than XML.
docs/source/_static/actuators/*.png binary linguist-generated

# The docs builds check out these small animations without Git LFS.
docs/source/_static/how-to/reset_states/sgs-method-dark.gif binary -filter
docs/source/_static/how-to/reset_states/sgs-method-light.gif binary -filter

*.bat text eol=crlf
*.sh text eol=lf
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/source/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ The following modules are available in the ``isaaclab`` extension:
:hidden:

lab/isaaclab.envs.mdp
lab/isaaclab.envs.reset
lab/isaaclab.envs.ui
lab/isaaclab.sensors.patterns
lab/isaaclab.sim.converters
Expand Down
37 changes: 37 additions & 0 deletions docs/source/api/lab/isaaclab.envs.reset.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
.. currentmodule:: isaaclab.envs.reset

isaaclab.envs.reset
===================

Native storage and mask-based selection for prepared reset catalogs. All shared
reset utilities live here; tasks own collection criteria and physical restoration.
See :doc:`/source/how-to/reset_state_buffers` for graph capture, default-state
broadcasting, custom metrics, and the existing Lift event integration.

.. autosummary::

ResetStateBuffer
ResetStateSampler
ResetStateSamplerCfg
SamplingScoreCfg
BetaSamplingScoreCfg

.. autoclass:: ResetStateBuffer
:members:
:exclude-members: __init__

.. autoclass:: ResetStateSampler
:members:
:exclude-members: __init__

.. autoclass:: ResetStateSamplerCfg
:members:
:exclude-members: __init__

.. autoclass:: SamplingScoreCfg
:members:
:exclude-members: __init__

.. autoclass:: BetaSamplingScoreCfg
:members:
:exclude-members: __init__
1 change: 1 addition & 0 deletions docs/source/api/lab/isaaclab.envs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
.. autosummary::

mdp
reset
ui

.. rubric:: Classes
Expand Down
10 changes: 10 additions & 0 deletions docs/source/how-to/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,16 @@ How-to Guides

.. rubric:: Environments and Training

.. container:: guide-entry

:doc:`Native reset-state buffers </source/how-to/reset_state_buffers>`

Create native state banks and sample useful starts through the existing Lift reset event.

.. container:: guide-metadata

:guide-tag:`PhysX` :guide-tag-newton:`Newton`

.. container:: guide-entry

:doc:`Creating a manager-based base environment </source/how-to/create_manager_base_env>`
Expand Down
213 changes: 213 additions & 0 deletions docs/source/how-to/reset_state_buffers.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
:orphan:

Native reset-state buffers
==========================

A reset bank separates prepared starting states from the policy that selects them.
The shared API lives in :mod:`isaaclab.envs.reset`: :class:`~isaaclab.envs.reset.ResetStateBuffer`
owns Warp snapshots, and :class:`~isaaclab.envs.reset.ResetStateSampler` records outcomes
and selects entries. Tasks own generation, physical validity, and restoration through
public asset writers. The existing core Lift task demonstrates this as a reset event.

Prepare storage
---------------

Construct a buffer from a nested dictionary of Warp arrays. Every leaf has the same
leading state count and device. :class:`~isaaclab.utils.warp.ProxyArray` and same-device
Torch inputs are accepted at the boundary; storage and runtime operations use Warp.
Construction copies the inputs.

.. code-block:: python

import warp as wp
from isaaclab.envs.reset import ResetStateBuffer

empty = ResetStateBuffer({})
assert empty.num_states == 0

# A single, task-validated default row can populate the whole bank.
defaults = {"joint_pos": robot.data.default_joint_pos.warp[:1]}
buffer = ResetStateBuffer(defaults, num_states=1024)

An empty dictionary has no schema and contains zero states. A tree of zero-row arrays
also represents an empty buffer, retaining its schema. Nonempty reads and sampling
require prepared entries. An empty schema cannot allocate populated states without
being given their fields.

The ``states`` property returns copied ``ProxyArray`` snapshots for inspection or
persistence. Compatible saved tensors can also initialize a bank:

.. code-block:: python

import torch

saved_states = torch.load("reset_states.pt", map_location=device, weights_only=True)
buffer = ResetStateBuffer(saved_states)

The task must establish asset, backend, field, unit, and controller compatibility.
Store positions relative to environment origins when sharing starts across worlds.
Storage does not perform collision checks or manage a disk cache.

Select and restore with masks
------------------------------

The native interface uses full-environment arrays and a Boolean mask. Allocate output
storage before capture, then reuse it:

.. code-block:: python

from isaaclab.envs.reset import ResetStateSampler, ResetStateSamplerCfg

sampler = ResetStateSampler(ResetStateSamplerCfg(seed=42), num_envs, buffer.num_states, device)
mask = wp.ones(num_envs, dtype=wp.bool, device=device)
restored = {"joint_pos": wp.empty((num_envs, robot.num_joints), dtype=float, device=device)}

# Record the episodes that ended before assigning their replacement starts.
sampler.reset(mask, success=episode_success, valid=completed_episode)
buffer.get_state(sampler.indices, out=restored, mask=mask)
robot.write_joint_position_to_sim_mask(position=restored["joint_pos"], env_mask=mask)

Only masked environments receive new assignments, random draws, or restored values.
Omit outcomes on the initial draw, and exclude manual or zero-step resets with
``valid``. Record the previous episode before clearing its success flag. Simultaneous
outcomes for the same entry are recorded in environment-index order; each entry
retains its latest ``history_length`` outcomes.

Pass a full-environment ``state_ids`` array to ``sampler.reset`` for explicit starts.
Optional constructor ``state_ids`` gives entries stable integer labels, such as
procedural recipe seeds. ``sampler.indices`` gives dense storage positions for
``buffer.get_state`` and ``sampler.state_ids`` gives the corresponding labels.
Catalog labels reserve ``-1`` for an unassigned environment. Assignments, rates, counts, and probabilities
are borrowed ``ProxyArray`` outputs: treat them as read-only and use explicit requests
to change assignments. Invalid requested IDs are reported in ``invalid_requests``
on the device, so inspection can happen outside capture.

For catalogs partitioned by asset combination, use ``group_ids`` and ``num_groups``.
Partitions contain equal contiguous ranges; each environment draws within its group.
The buffer itself has no group metadata. Legacy manager terms can pass ``env_ids=``
to the sampler; that shim populates a preallocated mask.

.. figure:: ../_static/how-to/reset_states/reset_lifecycle.jpg
:width: 100%
:alt: Initialization prepares validated states once. Runtime selects IDs, gathers snapshots, and restores masked worlds. Completed episode outcomes feed back into sampling.

Generation and validation run during initialization. Runtime uses fixed storage and masks.

Capture the runtime
-------------------

Warm the configured path before capture. The sampler and ``get_state(..., out=...)``
can run in a CUDA graph. Lift's ``newton_mjwarp`` preset supports capturing both
operations and the asset writes together. With OvPhysX or Kit-based PhysX, run Lift's
asset writes outside capture.

Update the contents of the bound arrays in place between graph replays. The choice to
provide outcomes or explicit IDs is fixed at capture time.

.. code-block:: python

def reset_selected():
sampler.reset(mask, success=episode_success, valid=completed_episode)
buffer.get_state(sampler.indices, out=restored, mask=mask)
robot.write_joint_position_to_sim_mask(position=restored["joint_pos"], env_mask=mask)

reset_selected()
with wp.ScopedCapture(device=device) as capture:
reset_selected()
wp.capture_launch(capture.graph)

Run prefill, rejection loops, loading, inspection, and logging outside capture. Use
``get_state(ids)`` to allocate a snapshot for inspection. The example captures only
the reset operations.

Set ``ResetStateSamplerCfg.seed`` to initialize the sampler's per-environment random streams.
Use ``sampler.reseed(seed)`` between rollouts to restart those streams while retaining
history and assignments. A captured graph observes the new streams.

Configure useful practice
--------------------------

The default adds uniform weight to a Beta kernel score that peaks at 50 percent recent
success. This favors starts of intermediate difficulty while giving every entry a
chance to be drawn. Concentration narrows the score's peak while keeping its height
fixed at one.
When all success rates are zero, the default draws uniformly. Include valid starts
the policy can solve early so that the scores can begin to distinguish entries.

.. code-block:: python

from isaaclab.envs.reset import BetaSamplingScoreCfg

adaptive = ResetStateSamplerCfg(
history_length=50,
scores=[BetaSamplingScoreCfg(target=0.5, kappa=2.0, weight=0.25)],
uniform_weight=0.0501,
)
uniform = ResetStateSamplerCfg(scores=[])

.. figure:: ../_static/how-to/reset_states/success_sampling.jpg
:width: 100%
:alt: An illustrative five-entry bank gives its largest sampling probability to the entry with 50 percent success, retaining coverage at both extremes.

Example probabilities for five states with different success rates. The sampler
adds ``0.0501`` to each score, then normalizes the weights within each asset group.

.. image:: ../_static/how-to/reset_states/sgs-method-light.gif
:class: only-light
:width: 100%
:alt: An animation shows the policy training loop and the Beta score peaking at 50 percent success.

.. image:: ../_static/how-to/reset_states/sgs-method-dark.gif
:class: only-dark
:width: 100%
:alt: An animation shows the policy training loop and the Beta score peaking at 50 percent success.

The animation illustrates how rollouts and training change which starts are most useful.
As the policy revisits starts, their estimated success rates shift along the Beta
score curve. The curve shows the score before adding uniform weight.
Animation courtesy of Octi Zhang.

Custom configurations derive from :class:`~isaaclab.envs.reset.SamplingScoreCfg`.
Their scorer implements ``score(metrics, out)`` with Warp operations on preallocated
storage. Borrow additional per-entry metric arrays through ``metrics=`` at sampler
construction and update them in place. The sampler supplies ``success_rate`` and
``episode_counts`` so a score can account for both difficulty and how much evidence
it has. Tasks can supply other signals, such as learning progress or staleness.

The sampler uses a fixed catalog and weighted draws with replacement. Tasks that
generate new entries during training or require scheduled coverage, such as visiting
each row once per cycle, own that scheduling policy.
The assignment must match the state actually played. When restoring a snapshot from
outside the catalog, exclude the resulting episode from catalog outcome tracking.

Use the existing Lift reset event
---------------------------------

``Isaac-Lift-Franka`` already uses ``core/lift/mdp/events.py::conditional_reset``.
Its ordinary reset terms generate candidate starts, its criteria reject invalid
states, and its optional diversity descriptor spreads the retained starts. Prefill
runs once per asset-combination group before replay begins. The event now uses the
shared buffer and sampler; no additional task or environment subclass is required.

Configure its existing ``events.conditional_reset.params`` entries:

* ``buffer_size_per_group`` controls retained starts per asset combination.
* ``valid_criteria`` and ``max_prefill_iters`` control acceptance and the attempt budget.
* ``diversity_feature`` optionally spreads starts over a task-defined descriptor.
* ``reset_sampler`` configures history, scores, and independent random streams;
``None`` selects uniformly without recording outcomes.

After ordinary initialization, the event's ``reset_mask(mask, state_ids=ids)`` method
replays explicit starts. With adaptive sampling enabled, supply
``completed=natural_episode_mask`` to record outcomes for completed natural episodes
that took at least one step. The event credits the existing success reward's sticky
flag before the reward manager clears it and restores root-link poses, COM velocities,
joints, and controller targets through public mask writers.

Migrating existing reset configurations
---------------------------------------

Lift's ``success_monitor`` event parameter is replaced by ``reset_sampler``.
NIST's ``sampling`` parameter takes ``ResetStateSamplerCfg`` with core score
configurations. Its separate ``success_monitor_cfg`` still configures outcome
history. Set ``metric="monitor_success_rate"`` on a score to use those rates.
5 changes: 5 additions & 0 deletions source/isaaclab/changelog.d/reset-state-buffer.added.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* Added Warp-native ``ResetStateBuffer`` and ``ResetStateSampler`` in ``isaaclab.envs.reset``
with preallocated masked replay, explicit catalog IDs, deterministic recent-outcome tracking,
and CUDA graph capture. Buffers supported empty state trees and broadcasting one default state.
* Added metric-based sampling scores with a unit-peak Beta kernel and
uniform coverage. Torch inputs and environment IDs were boundary shims into native arrays and masks.
Empty file.
3 changes: 2 additions & 1 deletion source/isaaclab/isaaclab/envs/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

__all__ = [
"mdp",
"reset",
"ui",
"VecEnvObs",
"VecEnvStepReturn",
Expand All @@ -30,7 +31,7 @@ __all__ = [
"MimicEnvCfg",
]

from . import mdp, ui
from . import mdp, reset, ui
from .common import VecEnvObs, VecEnvStepReturn, ViewerCfg
from .utils.video_recorder_cfg import VideoRecorderCfg
from .direct_marl_env import DirectMARLEnv
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#
# SPDX-License-Identifier: BSD-3-Clause

"""Sampling strategies for multi-task curriculum selection."""
"""Native state banks and outcome-guided reset selection."""

from isaaclab.utils.module import lazy_export
from ...utils.module import lazy_export

lazy_export()
22 changes: 22 additions & 0 deletions source/isaaclab/isaaclab/envs/reset/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright (c) 2022-2026, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md).
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause

__all__ = [
"BetaSamplingScore",
"BetaSamplingScoreCfg",
"ResetStateBuffer",
"ResetStateSampler",
"ResetStateSamplerCfg",
"SamplingScore",
"SamplingScoreCfg",
"beta_sampling_score",
"sample_cdf",
]

from .reset_state_buffer import ResetStateBuffer
from .reset_state_sampler import ResetStateSampler, sample_cdf
from .reset_state_sampler_cfg import ResetStateSamplerCfg
from .sampling_scores import BetaSamplingScore, SamplingScore, beta_sampling_score
from .sampling_scores_cfg import BetaSamplingScoreCfg, SamplingScoreCfg
Loading
Loading