Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 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
6ec0d7f
Reuse shared reset sampling in Franka Pour
maxkra15 Nov 7, 2026
d6a30b1
Address reset buffer and pickup review findings
maxkra15 Nov 7, 2026
5b83452
Merge reviewed reset utilities into Pour follow-up
maxkra15 Nov 7, 2026
64f67b6
Fix cube pickup configuration and smoke collection
maxkra15 Nov 9, 2026
edb15d5
Merge cube CI fixes into Pour follow-up
maxkra15 Nov 9, 2026
92d6968
chore: Merge main into PR #8872
maxkra15 Nov 9, 2026
3021625
chore: Merge main into PR #8965
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
3a89e38
chore: Merge main into PR #8965
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
0831c95
chore: Merge main and reset dependency into PR #8965
maxkra15 Nov 11, 2026
e61df06
chore: Merge main into PR #8965
maxkra15 Nov 12, 2026
11a902f
chore: Merge main into PR #8965
maxkra15 Nov 13, 2026
39eeb48
chore: Merge main into PR #8965
maxkra15 Nov 16, 2026
db60996
chore: Merge main into PR #8965
maxkra15 Nov 17, 2026
fe9d5e4
chore: Merge main into PR #8965
maxkra15 Nov 18, 2026
bd124ad
chore: Merge main into PR #8965
maxkra15 Nov 19, 2026
dce6bcc
Reuse the shared reset sampler in Franka Pour
maxkra15 Nov 25, 2026
cdb4774
Simplify Franka Pour reset sampling
maxkra15 Nov 25, 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
1 change: 1 addition & 0 deletions source/isaaclab/changelog.d/pour-reset-seed-hook.fixed.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Fixed explicit reset seeding for manager-based tasks that use their own sampler.
19 changes: 8 additions & 11 deletions source/isaaclab/isaaclab/envs/manager_based_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,12 +463,7 @@ def reset(
# trigger recorder terms for pre-reset calls
self.recorder_manager.record_pre_reset(env_ids)

# set the seed
if seed is not None:
self.seed(seed)

# reset state of scene
self._reset_idx(env_ids)
self._reset_with_seed(env_ids, seed)

# update articulation kinematics
self.scene.write_data_to_sim()
Expand Down Expand Up @@ -526,11 +521,7 @@ def reset_to(
# trigger recorder terms for pre-reset calls
self.recorder_manager.record_pre_reset(env_ids)

# set the seed
if seed is not None:
self.seed(seed)

self._reset_idx(env_ids)
self._reset_with_seed(env_ids, seed)
# set the state
self.scene.reset_to(state, env_ids, is_relative=is_relative)

Expand Down Expand Up @@ -671,6 +662,12 @@ def close(self):
Helper functions.
"""

def _reset_with_seed(self, env_ids: torch.Tensor | slice, seed: int | None) -> None:
"""Reset selected environments after applying an optional explicit seed."""
if seed is not None:
self.seed(seed)
self._reset_idx(env_ids)

def _reset_idx(self, env_ids: torch.Tensor | slice):
"""Reset environments based on specified indices.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* Changed Franka Pour to use :class:`~isaaclab.envs.reset.ResetStateSampler` for adaptive reset sampling.
Existing reset datasets, settings, and exact cyclic replay remain supported. The shared sampler
uses a different random stream, so historical seeded runs may draw different rows.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* Deprecated the Franka Pour task-local ``ResetDatasetSampler``. Use
:class:`~isaaclab.envs.reset.ResetStateSampler` and supply complete environment selections
and episode outcomes to its ``reset()`` method. The legacy import and behavior remain available.
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,16 @@ The result latches after a safe milestone crossing and is recorded when that epi
spill, overlap, out-of-bounds, collision, or abnormal terminal transitions cannot create positive
curriculum evidence. This curriculum-only Boolean never contributes policy reward.

Each row retains its exact 50 most recent local-progress outcomes. Adaptive priority is
Isaac Lab's shared reset-state sampler retains each row's 50 most recent completed
local-progress outcomes. Startup and manual resets contribute no outcomes. Adaptive priority is
`sqrt(p * (1 - p)) + epsilon`, so uncertain rows near 50% progress are emphasized without starving
rows at 0% or 100%. A shuffled cyclic stream receives 50% of assignments throughout training,
which keeps persistently difficult reaching and grasp-acquisition rows represented alongside the
adaptive competence frontier. There are no runtime stages or region probabilities.
Warp supplies the adaptive random stream and a seeded task-local stream supplies the shuffled
replay. Rerun with the same seed and reset order to reproduce the new sequence. Existing
datasets and config overrides continue to work, while exact samples from the previous Torch
sampler can differ.

The sampler reports its effective pool size, concentration, and cyclic-replay fraction. Offline
reset regions remain in the artifact as generation provenance, but runtime does not maintain a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
from typing import TYPE_CHECKING

import torch
import warp as wp

from isaaclab.envs.reset import BetaSamplingScoreCfg, ResetStateSampler, ResetStateSamplerCfg
from isaaclab.managers import CurriculumTermCfg
from isaaclab.managers.manager_base import ManagerTermBase
from isaaclab.utils import clone, index_fill_
from isaaclab.utils import index_fill_

from ..reset_sampler import ResetDatasetSampler, ResetDatasetSamplerCfg
from ..reset_sampler import ResetDatasetSamplerCfg, _CyclicReplay, _sampling_metrics

if TYPE_CHECKING:
from ..pour_env import FrankaPourEnv
Expand All @@ -37,13 +39,39 @@ def __init__(self, cfg: CurriculumTermCfg, env: FrankaPourEnv):
self._row_count = int(category.numel())
self._device = category.device

self._sampling_mode = env.cfg.reset_dataset_sampling_mode
if self._sampling_mode not in ("adaptive", "uniform"):
sampling_mode = env.cfg.reset_dataset_sampling_mode
if sampling_mode not in ("adaptive", "uniform"):
raise ValueError("reset_dataset_sampling_mode must be 'adaptive' or 'uniform'.")
sampler_cfg = clone(env.cfg.reset_dataset_sampler)
sampler_cfg = env.cfg.reset_dataset_sampler
if not isinstance(sampler_cfg, ResetDatasetSamplerCfg):
raise TypeError("reset_dataset_sampler must be ResetDatasetSamplerCfg.")
self._sampler = ResetDatasetSampler(self._row_count, self._device, sampler_cfg)
sampler_cfg.validate_values()

self._replay_generator = torch.Generator(device=self._device)
seed = env.cfg.seed if env.cfg.seed is not None else self._replay_generator.seed()
self._replay_fraction = float(sampler_cfg.uniform_fraction) if sampling_mode == "adaptive" else 0.0

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.

🟡 Warning · Compatibility — Preserve the uniform-mode metric

Uniform mode previously reported the configured uniform_fraction through the sampler metric; this sets that metric to zero. Preserve the existing value during deprecation and report effective replay separately.

self._replay_generator.manual_seed(seed)
self._replay = _CyclicReplay(self._row_count, self._device, self._replay_generator)
self._requested_rows = torch.empty_like(env.reset_dataset_row_id)

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.

🟡 Warning · Scope Complexity — Reuse the existing row buffer

_requested_rows duplicates the task’s per-environment row buffer and requires a forwarding helper. Write requested rows into env.reset_dataset_row_id and pass that buffer to the sampler.


# Core's Beta score has unit peak. Restore the raw kernel's scale so its
# weight floor has the same effect as in the original Pour sampler.
target = float(sampler_cfg.target_success_rate)
kappa = float(sampler_cfg.kappa)
peak = target ** (kappa * target) * (1.0 - target) ** (kappa * (1.0 - target))
scores = [BetaSamplingScoreCfg(target=target, kappa=kappa, weight=peak)] if sampling_mode == "adaptive" else []
with self._sampler_stream():
self._sampler = ResetStateSampler(
ResetStateSamplerCfg(
history_length=sampler_cfg.monitored_history_len,
scores=scores,
uniform_weight=float(sampler_cfg.epsilon),
seed=seed,
),
env.num_envs,
self._row_count,
self._device,
)

self._frozen_rows = torch.arange(self._row_count, device=self._device, dtype=torch.long)
top_grasp_count = env.cfg.reset_dataset_top_grasp_count
Expand All @@ -70,36 +98,51 @@ def __call__(
env_ids: Sequence[int] | torch.Tensor | slice,
) -> dict[str, float]:
"""Record completed episodes and assign the next reset rows."""
num_envs = len(range(env.num_envs)[env_ids]) if isinstance(env_ids, slice) else len(env_ids)
if num_envs == 0:
return self._metrics(env)

completed = (env.episode_length_buf[env_ids] > 0) & (env.reset_dataset_row_id[env_ids] >= 0)
if not env.cfg.curriculum_freeze:
rows = env.reset_dataset_row_id[env_ids][completed]
if rows.numel() > 0:
progress = env.termination_manager.get_term_cfg("learning_progress_context").func
self._apply_outcomes(rows, progress.ever_success[env_ids][completed])

if env.cfg.curriculum_freeze:
slots = torch.randint(self._frozen_rows.numel(), (num_envs,), device=self._device)
rows = self._frozen_rows[slots]
elif self._sampling_mode == "uniform":
rows = torch.randint(self._row_count, (num_envs,), device=self._device)
if isinstance(env_ids, slice):
env_ids = torch.arange(env.num_envs, device=self._device)[env_ids]

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.

🟡 Warning · Implementation — Materialize only selected slice indices

A small sliced reset allocates indices for every environment before slicing them. Materialize only the selected range when the sampler needs tensor IDs.

else:
rows = self._sampler._sample_with_uniform_replay(num_envs)
if rows.shape != (num_envs,) or rows.dtype != torch.long:
raise RuntimeError("Adaptive sampler returned invalid reset-row IDs.")
env_ids = torch.as_tensor(env_ids, device=self._device, dtype=torch.long)

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.

🔴 Critical · Compatibility — Preserve Boolean reset selections

Casting a Boolean mask to long turns True into environment ID 1; a one-environment all-True reset becomes out of bounds. Convert masks to selected indices before calling the sampler.

with self._sampler_stream():
if (seed := env._reset_dataset_seed) is not None:
env._reset_dataset_seed = None
self._sampler.reseed(seed)
self._replay_generator.manual_seed(seed)
self._replay.restart(self._replay_generator)

num_envs = env_ids.numel()
if num_envs == 0:
return self._metrics(env)

if env.cfg.curriculum_freeze:
slots = torch.randint(
self._frozen_rows.numel(), (num_envs,), device=self._device, generator=self._replay_generator
)
self._reset_requested_rows(env_ids, self._frozen_rows[slots])
else:
completed = env.reset_buf & (env.episode_length_buf > 0)
progress = env.termination_manager.get_term_cfg("learning_progress_context").func
self._sampler.reset(env_ids=env_ids, success=progress.ever_success, valid=completed)
self._apply_cyclic_replay(env_ids)

env.reset_dataset_row_id[env_ids] = rows
index_fill_(env.pour_target_frac, env_ids, float(env.cfg.pour_target_frac))
env.reset_dataset_row_id[env_ids] = self._sampler.state_ids.torch[env_ids]
index_fill_(env.pour_target_frac, env_ids, float(env.cfg.pour_target_frac))

if not env.cfg.curriculum_freeze:
self._local_reset_assignments_since_metrics += num_envs
if self._local_reset_assignments_since_metrics >= self._local_metrics_refresh_interval:
self._refresh_metrics_cache()
return self._metrics(env)

def _sampler_stream(self) -> wp.ScopedStream:
"""Order resets with Torch request writes and the sampler's persistent Warp state."""
stream = None
if self._device.type == "cuda":
torch_stream = torch.cuda.current_stream(self._device)
stream = wp.get_stream(wp.device_from_torch(self._device))
if stream.cuda_stream != torch_stream.cuda_stream:
stream = wp.stream_from_torch(torch_stream)
return wp.ScopedStream(stream, sync_enter=True, sync_exit=True)

def _metrics(self, env: FrankaPourEnv) -> dict[str, float]:
"""Return playback or adaptive-sampler metrics."""
if env.cfg.curriculum_freeze:
Expand All @@ -109,11 +152,20 @@ def _metrics(self, env: FrankaPourEnv) -> dict[str, float]:
}
return self._metrics_cache

def _apply_outcomes(self, rows: torch.Tensor, learning_progress: torch.Tensor) -> None:
"""Apply completed outcomes to the adaptive sampler."""
self._sampler._record_validated(rows, learning_progress)
def _reset_requested_rows(self, env_ids: torch.Tensor, rows: torch.Tensor) -> None:
self._requested_rows[env_ids] = rows
self._sampler.reset(env_ids=env_ids, state_ids=self._requested_rows)

def _apply_cyclic_replay(self, env_ids: torch.Tensor) -> None:
"""Override the reserved assignments with complete shuffled passes over the dataset."""
count = env_ids.numel()
replay_count = self._replay.reserve(count, self._replay_fraction)
if replay_count:
slots = torch.randperm(count, device=self._device, generator=self._replay_generator)[:replay_count]
self._reset_requested_rows(env_ids[slots], self._replay.take(replay_count, self._replay_generator))

def _refresh_metrics_cache(self) -> None:
"""Refresh host logging metrics after a bounded number of reset assignments."""
self._metrics_cache = self._sampler.metrics()
self._metrics_cache = _sampling_metrics(self._sampler.probabilities.torch, self._replay_fraction)
self._metrics_cache["sampler/uniform_replay_fraction"] = self._replay_fraction
self._local_reset_assignments_since_metrics = 0
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class FrankaPourEnv(ManagerBasedRLEnv):
cfg: FrankaPourResetDatasetEnvCfg

def __init__(self, cfg: FrankaPourResetDatasetEnvCfg, render_mode: str | None = None, **kwargs):
self._reset_dataset_seed: int | None = None
configure_mpm_capacities(cfg)
self._prepare_newton_extras(cfg)
with newton_builder_world_hook(self._add_pour_world_to_builder):
Expand All @@ -119,6 +120,15 @@ def load_managers(self) -> None:
self._setup_after_physics()
super().load_managers()

def _reset_with_seed(self, env_ids: torch.Tensor | slice, seed: int | None) -> None:
"""Offer the resolved seed to the curriculum during an explicit reset."""
previous = self._reset_dataset_seed
self._reset_dataset_seed = self.seed(seed) if seed is not None else None
try:
super()._reset_with_seed(env_ids, None)
finally:
self._reset_dataset_seed = previous

def _prepare_newton_extras(self, cfg: FrankaPourResetDatasetEnvCfg) -> None:
"""Cache task geometry bounds and Newton contact values from the resolved config.

Expand Down
Loading
Loading