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 Native reset-state buffers for graph capture, default-state broadcasting, custom metrics, and the existing Lift event integration.

ResetStateBuffer

Own a fixed set of task states independently of their generation and sampling.

ResetStateSampler

Credit completed episodes before assigning starts, using a fixed-size environment mask.

ResetStateSamplerCfg

Configure recent outcomes and weighted selection independently of physical state storage.

SamplingScoreCfg

Configure a scorer accepting this config and implementing score(metrics, out).

BetaSamplingScoreCfg

Configure a Beta kernel score with a peak of one at the target metric value.

class isaaclab.envs.reset.ResetStateBuffer[source]#

Own a fixed set of task states independently of their generation and sampling.

States are nested dictionaries of arrays sharing a leading row dimension and device. Warp composite types, such as transforms, retain their element type. Physical units follow the supplied fields; store positions relative to environment origins when sharing snapshots across environments.

Construction and allocating accessors copy their inputs. For graph capture, allocate an output tree once, warm up get_state(), then pass that tree and a full-size environment mask on every call. This path writes only selected environments and performs no array allocation or host synchronization. The task commits the arrays through its native asset writers.

Parameters:
  • states – Nested Warp, ProxyArray, or Torch arrays, one state per leading row. An empty dictionary or zero-row arrays represent an empty buffer.

  • num_states – Optional buffer size. A single supplied default state is repeated to fill this many rows. Otherwise it must match the supplied row count.

Raises:

ValueError – Arrays lack matching row counts and devices, or the requested size cannot be populated from the supplied states.

Attributes:

State(*args, **kwargs)

alias of dict[str, wp.array | ProxyArray | torch.Tensor | ResetStateBuffer.State]

num_states

Number of stored states; zero for an empty buffer.

states

Copied ProxyArray tree, preserving each field's shape, dtype, device, and units.

Methods:

get_state(state_indices, *[, out, mask])

Copy selected states into the output rows enabled by mask.

State(*args, **kwargs)#

alias of dict[str, wp.array | ProxyArray | torch.Tensor | ResetStateBuffer.State]

property num_states: int[source]#

Number of stored states; zero for an empty buffer.

property states: dict[str, array | ProxyArray | Tensor | dict[str, wp.array | ProxyArray | torch.Tensor | ResetStateBuffer.State]][source]#

Copied ProxyArray tree, preserving each field’s shape, dtype, device, and units.

This allocating export is intended for initialization, inspection, or persistence.

get_state(state_indices: array | ProxyArray | Tensor, *, out: dict[str, array | ProxyArray | Tensor | dict[str, wp.array | ProxyArray | torch.Tensor | ResetStateBuffer.State]] | None = None, mask: array | ProxyArray | Tensor | None = None) → dict[str, array | ProxyArray | Tensor | dict[str, wp.array | ProxyArray | torch.Tensor | ResetStateBuffer.State]][source]#

Copy selected states into the output rows enabled by mask.

Invalid indices leave the corresponding output rows untouched, or zero-filled if allocating.

Parameters:
  • state_indices – Dense int32 or int64 row positions, shape [N], on the buffer device. Only indices of enabled output rows are read.

  • out – Preallocated tree with the stored schema and N leading rows. None allocates a new ProxyArray tree and requires mask to be None.

  • mask – Boolean selection, shape [N]. None copies every output row.

Returns:

The supplied output tree, or a new tree when out is None.

class isaaclab.envs.reset.ResetStateSampler[source]#

Credit completed episodes before assigning starts, using a fixed-size environment mask.

Persistent storage is allocated at construction. Mask selection, history, score composition, and draws use Warp; same-device Torch arrays are zero-copy input shims. Warm the configured kernels and native sort/scan primitives before CUDA graph capture. Masks and array values can then change without dynamic indexing or host data reads; Warp manages the primitives’ temporary storage.

Catalog entries form equal contiguous partitions. Each environment samples only its configured group; the one-group default shares the whole catalog. Optional opaque integer IDs identify procedural recipes or cached states, while history and metric arrays follow catalog order.

Parameters:
  • cfg – History, scoring, and random-stream configuration.

  • num_envs – Number of environments.

  • num_states – Number of catalog entries, divisible by num_groups.

  • device – Storage and computation device.

  • group_ids – Fixed per-environment partition indices, shape [num_envs]; defaults to zero.

  • num_groups – Number of equal catalog partitions.

  • state_ids – Unique signed integer catalog labels, shape [num_states]; -1 is reserved for unassigned environments. Defaults to dense indices.

  • metrics – Additional borrowed per-entry arrays. Update them in place. success_rate and episode_counts are supplied by the sampler.

state_ids#

Borrowed catalog labels, shape [num_envs], with -1 for environments not yet assigned.

indices#

Borrowed dense catalog positions, shape [num_envs], with -1 before assignment.

success_rate#

Borrowed recent success rates, shape [num_states].

episode_counts#

Borrowed lifetime counts of completed outcomes, shape [num_states].

probabilities#

Borrowed probabilities, shape [num_states]; each partition sums to one.

invalid_requests#

Borrowed flags for rejected explicit requests in the latest reset, shape [num_envs].

Treat output arrays as read-only. Their storage is reused by subsequent resets.

Methods:

reseed(seed)

Restart each environment's random stream in place, including streams retained by captured graphs.

reset([mask, env_ids, success, valid, state_ids])

Record previous outcomes and assign starts for selected environments.

reseed(seed: int) → None[source]#

Restart each environment’s random stream in place, including streams retained by captured graphs.

Assignments, outcome history, metric values, and the configured initial seed remain unchanged.

reset(mask: array | ProxyArray | Tensor | None = None, *, env_ids: Sequence[int] | slice | array | Tensor | None = None, success: array | ProxyArray | Tensor | None = None, valid: array | ProxyArray | Tensor | None = None, state_ids: array | ProxyArray | Tensor | None = None) → ProxyArray[source]#

Record previous outcomes and assign starts for selected environments.

Assignments and random streams of untouched environments are preserved. Simultaneous outcomes for a state are ordered by environment index.

Explicit requested IDs must belong to each selected environment’s group. Invalid requests set invalid_requests and leave both the assignment and its outcome history unchanged; there is no synchronizing device-value validation. Inspect that flag outside the captured region.

Parameters:
  • mask – Boolean selection with shape [num_envs]. Selects all environments when both selection arguments are omitted.

  • env_ids – Alternative selection using environment indices or a slice.

  • success – Previous episode success flags, shape [num_envs]. Omit at startup.

  • valid – Completed-episode mask, shape [num_envs]. Exclude unfinished manual resets.

  • state_ids – Explicit catalog labels, shape [num_envs]. Omit to sample from scores.

Returns:

Borrowed persistent full-environment ID assignments. Initially unassigned environments contain -1.

class isaaclab.envs.reset.ResetStateSamplerCfg[source]#

Configure recent outcomes and weighted selection independently of physical state storage.

Attributes:

history_length

Completed outcomes retained independently for each catalog entry.

scores

Weighted scorers consuming per-entry metrics.

uniform_weight

Weight added to every entry before normalization.

seed

Initial seed of the independent per-environment random streams.

history_length: int#

Completed outcomes retained independently for each catalog entry.

scores: list[SamplingScoreCfg]#

Weighted scorers consuming per-entry metrics. An empty list selects uniformly.

uniform_weight: float#

Weight added to every entry before normalization. A zero-total group draws uniformly.

seed: int#

Initial seed of the independent per-environment random streams.

class isaaclab.envs.reset.SamplingScoreCfg[source]#

Configure a scorer accepting this config and implementing score(metrics, out).

Attributes:

class_type

Runtime scorer class.

weight

Non-negative contribution before normalization.

class_type: type | str#

Runtime scorer class.

weight: float#

Non-negative contribution before normalization.

class isaaclab.envs.reset.BetaSamplingScoreCfg[source]#

Configure a Beta kernel score with a peak of one at the target metric value.

Attributes:

class_type

Runtime scorer class.

weight

Non-negative contribution before normalization.

metric

Name of the per-entry metric, with values in [0, 1].

target

Metric value where the score is one.

kappa

Concentration; zero gives a constant score, larger values narrow its unit-height peak.

class_type: type | str#

Runtime scorer class.

weight: float#

Non-negative contribution before normalization.

metric: str#

Name of the per-entry metric, with values in [0, 1].

target: float#

Metric value where the score is one.

kappa: float#

Concentration; zero gives a constant score, larger values narrow its unit-height peak.