unilab.base.reset_selectors¶
Reset row-selector conversion between the public env_ids and mask forms.
The task/manager reset contract speaks IsaacLab/mjlab-style env_ids row
indices. Backend transactions keep consuming fixed-width bool masks
(SimBackend.apply_reset/packed reset). These helpers are the single,
deliberately simple conversion point between the two forms.
Hot reset paths must not allocate a fresh mask per conversion
(roadmap #2461): each conversion site owns a ResetMaskBuffer whose storage
is allocated once on the env/manager/term and rewritten in place per call. The
module-level helpers keep allocating and remain the owned-copy form for
callers without a stable owner (tests, fixtures).
Functions
|
Scatter row indices into a freshly allocated fixed-width bool mask. |
|
Normalize a public reset selector to an int64 row-index tensor. |
|
Resolve a public reset selector to the internal fixed-width bool mask. |
Classes
Reusable fixed-width bool reset mask owned by one conversion site. |
- class unilab.base.reset_selectors.ResetMaskBuffer[source]¶
Bases:
objectReusable fixed-width bool reset mask owned by one conversion site.
scatter/resolverewrite the internal storage in place and return it; the returned tensor aliases that storage and stays valid only until the next call on the same buffer. Every site whose masks may be live at the same time owns a separate instance: the env reset-transaction entry, the env-owned event-term scratch, each manager, and each class-based term. Buffer lifetime follows its owner (the env or manager instance), so separate env instances never share storage.
- unilab.base.reset_selectors.reset_env_ids_mask(env_ids, *, num_envs, device)[source]¶
Scatter row indices into a freshly allocated fixed-width bool mask.
- unilab.base.reset_selectors.resolve_reset_env_ids(selector, *, num_envs, device, owner)[source]¶
Normalize a public reset selector to an int64 row-index tensor.
Noneselects every row; a slice selectsarange(num_envs)[slice]; an integer tensor is validated and moved ontodevice. Fixed-width bool masks are rejected: the v1.4 mask form was removed in v1.5.