Skip to content

Allow explicit step overrides and move recording into workflows - #9121

Open
ooctipus wants to merge 11 commits into
isaac-sim:mainfrom
ooctipus:configurable-step-function
Open

ooctipus wants to merge 11 commits into
isaac-sim:mainfrom
ooctipus:configurable-step-function

Conversation

@ooctipus

@ooctipus ooctipus commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Manager-based RL environments can take a complete custom step function through env_cfg.step_fn. The default step keeps the decimation loop, rewards, terminations, resets, commands, events, and observations visible in one function.

Recording workflows define their own step in the script or entry point that runs them. Each owns its decimation loop and makes direct capture calls where the workflow needs them. Teleoperation evaluates success over consecutive control steps. Mimic owns generation and annotation boundaries. The locomanipulation scripts export on task termination. The shared capture module reads fields and metadata, and EpisodeRecorder owns batched storage and HDF5 export.

Removed RecorderManager, its term and configuration classes, and environment-owned recording from step, reset, reset-to-state, and close. The architecture test guards both the environment and capture module boundaries. The documentation shows the actual teleoperation step and where a script can insert per-physics-step capture.

No unmerged dependencies.

Migration

This removes env.recorder_manager and env_cfg.recorders. Instantiate EpisodeRecorder and import DatasetExportMode from isaaclab.utils.datasets. Define the step in your script and call the capture functions at your chosen points. For an explicit decimation loop, set backend decimation to one before the first environment step. Mimic generation APIs receive the recorder directly. Task image exports use the global step in filenames.

Validation

  • 22 focused tests passed across episode storage and architecture, physics action eligibility, manager-based RL, and Mimic generation failure limits.
  • Newton XPBD CPU verified the existing observation history, partial reset, and policy RNG assertions.
  • An isolated Newton MuJoCo CPU harness exercised all six script-local functions on a moving rigid body. It checked simulation duration, task and visualizer resets, export classification, and initial-state capture. It also compared task-terminating paths against the default step at an absolute tolerance of 1e-7.
  • The default step matched the original implementation exactly over 12 transitions with two autoresets. The empty-scene Newton CPU timing was about 92.4 µs before and 91.3 µs after.
  • Repository formatting, lint, changelog checks, and the clean documentation build passed.

Full Kit/PhysX, teleoperation CLI, XR, and GPU coverage remains for CI. Local Kit bootstrap requires interactive license acceptance.

Type of change

  • Breaking change
  • New feature
  • Documentation update

@github-actions github-actions Bot added documentation Improvements or additions to documentation isaac-lab Related to Isaac Lab team labels Nov 20, 2026
@ooctipus ooctipus changed the title Allow configuring the manager-based RL step function Simplify step overrides and make episode recording explicit Nov 20, 2026
@github-actions github-actions Bot added the isaac-mimic Related to Isaac Mimic team label Nov 20, 2026
@ooctipus ooctipus changed the title Simplify step overrides and make episode recording explicit Allow explicit step overrides and move recording into workflows Nov 20, 2026
@ooctipus
ooctipus marked this pull request as ready for review November 20, 2026 21:12
@ooctipus
ooctipus requested a review from a team November 20, 2026 21:12

@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

Needs attention: Design and architecture (1), Compatibility and deprecation (10), Implementation (3), Style consistency (5), Test quality (2). Other reviewed categories look good.

  • PR description: Qualify default-step parity as recorder-free; make the quoted timing reproducible with baseline/candidate revisions, command, hardware, backend, environment count, warmup, and metric, while preserving the template sections.
  • Design and architecture: The locomanipulation payload schema has one script consumer but remains in the environment module; move its conversion beside generate_data.py's capture call.
  • Scope and over-engineering: No over-engineering issues.
  • API: API changes look good.
  • Compatibility and deprecation: Breaking changes: recording configuration, hooks, imports, extensions, Mimic construction and setup, teleoperation returns, and image filenames change without functional deprecation bridges; retain old behavior with targeted warnings, migration/removal guidance, and transition coverage.
  • Implementation: Mimic metadata now reads raw actions before processing rather than the manager-owned action buffer, changing captured targets; process actions before deriving metadata.
  • Style consistency: Several changed signatures add required recorder arguments without documenting them in existing Args sections; document each argument's storage and capture responsibility.
  • Test quality: The new structural test requires legacy APIs to disappear and constrains private syntax, obstructing deprecation bridges and harmless reorganization; replace those assertions with transition behavior and independent storage-boundary checks.

Needs rework. Posted 21 inline findings.

Automated review; human maintainers own approval decisions.


def _step_annotation(env, action: torch.Tensor, *, recorder: EpisodeRecorder):
"""Replay one action and capture the fields used for Mimic annotations."""
recorder.add_to_episodes("obs/datagen_info", get_datagen_info(env, action.to(env.device)))

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 · Implementation — Capture processed Mimic targets

The former pre-step term derived target_eef_pose from action_manager.action after processing; this call uses raw input first. Process the action, then pass the manager's action to get_datagen_info.

Please refer to the :class:`isaaclab.scene.InteractiveSceneCfg` class for more details.
"""

recorders: object = DefaultEmptyRecorderManagerCfg()

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 — Keep configured recording functional

Removing recorders and environment lifecycle dispatch stops existing configured capture, reset, and export. Retain the old manager path, including Warp dispatch, with targeted warnings, migration guidance, and old/new tests through deprecation.

"RewardTermCfg",
"TerminationTermCfg",
"ObservationManager",
"DatasetExportMode",

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 — Retain public recorder import paths

Removing the manager module, types, and DatasetExportMode export breaks existing imports and recorder subclasses. Keep their original paths functional with targeted deprecation warnings, migration guidance, and transition tests.

*manager* objects (``ObservationManager``, ``RewardManager``, ``TerminationManager``,
``EventManager``, ``CurriculumManager``, ``CommandManager``, ``ActionManager``,
``RecorderManager``). Each manager is driven by small, reusable MDP term functions that live
``EventManager``, ``CurriculumManager``, ``CommandManager``, ``ActionManager``). Each manager is driven by small, reusable MDP term functions that live

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 · Style Consistency — Wrap the shortened manager list

The edited list and following sentence now occupy one overlong source line. Break after the list to match the surrounding documentation layout.

from isaaclab.utils.datasets import EpisodeData, EpisodeRecorder, EpisodeRecorderCfg, HDF5DatasetFileHandler

import isaaclab_mimic.envs # noqa: F401
from isaaclab_mimic.datagen.generation import get_datagen_info

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 — Defer Mimic runtime imports

Importing generation before launch imports runtime environment code, contrary to this script's deferred-import boundary. Import it after launch; do the same for consolidated_demo and generate_data's new environment-module import.

}

return "locomanipulation_sdg_output_data", output_data_dict
def locomanipulation_sdg_output_data(output_data: LocomanipulationSDGOutputData) -> tuple[str, dict]:

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 · Design Architecture — Keep the payload in its workflow

Only generate_data.py consumes this dataset payload, yet its schema remains in the environment module. Move the conversion beside that script's capture call.

filename = (
f"{image_path}_{data_type}_trial_{total_successes}_tile_{tile}_step_{env.common_step_counter}.png"
)
filename = f"{image_path}_{data_type}_tile_{tile}_step_{env.common_step_counter}.png"

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 documented image names

Removing the trial component changes filenames produced by save_image_to_file and contradicts its documented format. Keep legacy naming during a warned transition before switching formats.

def create_environment_config(
output_dir: str, output_file_name: str
) -> tuple[ManagerBasedRLEnvCfg | DirectRLEnvCfg, object | None, IsaacTeleopCfg | DeviceCfg]:
) -> tuple[ManagerBasedRLEnvCfg | DirectRLEnvCfg, object | None, IsaacTeleopCfg | DeviceCfg, EpisodeRecorderCfg]:

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 teleop setup return

create_environment_config now returns four values instead of three, breaking existing unpacking callers. Retain the three-value interface through a warned transition and expose recorder settings separately.

env_cfg.recorders.dataset_export_dir_path = output_dir
env_cfg.recorders.dataset_filename = output_file_name
env_cfg.recorders.dataset_export_mode = DatasetExportMode.EXPORT_SUCCEEDED_ONLY
recorder_cfg = load_cfg_from_registry(args_cli.task, "demo_recorder_cfg_entry_point")

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 — Execute registered capture terms

The registered demo recorder configuration can contain custom terms, but the fixed workflow step uses only its output settings. Preserve configured fields during deprecation instead of silently omitting them.



def process_success_condition(
env: gym.Env, recorder: EpisodeRecorder, success_term: object | None, success_step_count: int

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 · Style Consistency — Document teleop recorder arguments

process_success_condition, handle_reset, and run_simulation_loop add recorder arguments but omit them from their Google-style Args sections. Document the shared storage and each function's use.

@greptile-apps

greptile-apps Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[High impact] The PR changes how episode data is collected across several simulation and dataset workflows.

Fix the ignored custom step setting in the Warp frontend before merging.

Findings

  1. P1 Warp ignores custom steps ▶
  2. P2 Recording steps lack regression tests ▶

Summary

Adds ManagerBasedRLEnvCfg.step_fn and moves episode recording out of environments into recording workflows.

  • RL environments can use a custom function for each complete step.
  • Recording workflows choose when episodes are captured and exported.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Environment configuration] --> B{Frontend}
  B -->|Torch| C[Bind custom step when configured]
  B -->|Warp| D[Run Warp step]
  E[Recording workflow] --> F[Apply actions and advance physics]
  F --> G[Capture fields]
  G --> H[EpisodeRecorder]
  H --> I[Export or discard episode]
  I --> J[Reset and capture initial state]
Loading

Reviews (1) · Last reviewed commit: "Keep recording steps in their workflows" · Reviewed by Greptile

Comment on lines +92 to +93
if self.cfg.step_fn is not None:
self.step = MethodType(self.cfg.step_fn, self)

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.

P1 Warp ignores custom steps

With --frontend=warp, step_fn is silently ignored. That frontend creates ManagerBasedRLEnvWarp, which accepts ManagerBasedRLEnvCfg but does not inherit from ManagerBasedRLEnv or run this binding. Tasks therefore run the ordinary Warp step instead of their configured behavior. Bind the function in the Warp constructor too, or reject the setting there with a clear error.

Comment on lines +25 to +26
def test_configured_step_owns_execution_per_environment(monkeypatch):
"""A configured step receives its environment and bypasses the default stepping pipeline."""

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.

P2 Recording steps lack regression tests

The new binding test uses a stub step, and the storage tests never call the six new workflow step functions. Each workflow now owns physics timing, capture, export, and reset ordering. The current tests cannot catch a misplaced capture call, a wrong export flag, or an extra physics step. Preserve the isolated workflow checks described in the PR as repeatable tests.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@ooctipus
ooctipus force-pushed the configurable-step-function branch from b5c110f to 999bfc6 Compare November 20, 2026 21:18
@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 Nov 20, 2026

@rafaelcathomen rafaelcathomen 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.

Read this with #8867 (SuperMimic) and #8868 in mind. Five notes inline; the test one will fail once CI runs on Kit/PhysX.

One non-blocking point for the #8868 follow-up: step_fn alone doesn't make a correct pre-reset observation possible for terms with history or delay. compute(update_history=True) before the reset advances the surviving environments twice, and update_history=False misses the terminal sample. So the per-environment history update (or a preview) is still needed afterwards.

start_time = env.sim.backend_manager.get_simulation_time()
trajectory = [env.step(action)[0]["empty_observation"].clone() for _ in range(4)]
elapsed = env.sim.backend_manager.get_simulation_time() - start_time
assert elapsed == pytest.approx(4 * env.step_dt, rel=1e-5, abs=1e-8)

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.

This will fail on Kit/PhysX, which is what this test runs on by default: PhysxManager.step() never advances _sim_time, so get_simulation_time() stays at 0.0 (only the Newton and OvPhysX managers increment it). Comparing env._sim_step_counter before and after would work on every backend.

recorder = EpisodeRecorder(
recorder_cfg, env.num_envs, env.device, env_name=env_name, env_metadata=get_episode_metadata(env)
)
stack.callback(recorder.close)

@rafaelcathomen rafaelcathomen Nov 24, 2026 •

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.

The last episode is no longer written. Before, the trailing env.reset() exported it through the pre-reset recorder hook. Now reset() doesn't touch the recorder and close() skips the export because export_in_close defaults to False. With the documented --max_steps 32 smoke run the output file ends up with zero demos. Calling recorder.export_episodes() after the loop restores it.

while not env_reset_queue.empty():
env_id_tensor[0] = env_reset_queue.get_nowait()
env.reset(env_ids=env_id_tensor)
record_initial_state(recorder, env, env_id_tensor)

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.

env_loop now records only initial_state. Actions, observations and states are captured by _step_generation in scripts/.../generate_dataset.py, which that script patches onto env.step. Code that calls setup_async_generation / env_loop directly and only adds the new recorder argument gets demos with an initial state and num_samples = 0, with no error. Could the generation step live in isaaclab_mimic next to env_loop, or env_loop fail when the recording step isn't installed?

ui_window_class_type: type | str | None = "isaaclab.envs.ui.manager_based_rl_env_window:ManagerBasedRLEnvWindow"

# general settings
step_fn: Callable[[ManagerBasedRLEnv, torch.Tensor], VecEnvStepReturn] | 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.

Footgun: if the function's first parameter is named self (natural when starting from a copy of ManagerBasedRLEnv.step), step_fn = my_step in a @configclass body is silently dropped. _skippable_class_member treats callables with a self parameter as methods, so the field keeps its None default and the default step runs. Worth a sentence in the docstring or an explicit check.

self.metadata["render_fps"] = 1 / self.step_dt
self.has_rtx_sensors = self.sim.get_setting("/isaaclab/render/rtx_sensors")
if self.cfg.step_fn is not None:
self.step = MethodType(self.cfg.step_fn, self)

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.

Two config paths break here:

  • A Hydra/YAML override such as env.step_fn=pkg.mod:fn stays a plain string, because the default is None and nothing resolves it, so MethodType raises TypeError.
  • step_fn = partial(my_step, recorder=...) works at runtime, but to_dict(env_cfg) (the config dump in the train scripts) raises, because callable_to_string reads __name__.

Resolving strings here and documenting "plain functions only" would cover both.

@ooctipus
ooctipus force-pushed the configurable-step-function branch from 999bfc6 to 3f832b2 Compare November 24, 2026 22:36
@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 Nov 24, 2026
kellyguo11 added a commit that referenced this pull request Nov 25, 2026
# Description

Adds `isaaclab_neural` to run Newton tasks on neural robot dynamics from
[newton-neural](https://github.com/newton-physics/newton-neural). Tasks
record trajectories through the existing RecorderManager, fit dynamics
models offline, and select learned physics through ordinary task
presets.

## Summary of Changes

- Added `NeRDSolverCfg` for standalone dynamics and
`MJWarpNeRDSolverCfg` for free-motion coupling inside MuJoCo Warp. Both
use the existing `NewtonManager`, `NewtonBackend`, and
solver-construction path.
- Standalone task presets explicitly declare one model frame as
`sim.dt`, with `decimation=1` and `num_substeps=1`, preserving the
environment control period. Free-motion coupling retains its numerical
substeps. Native stepping rejects a timestep that differs from the
checkpoint frame.
- Solver adapters load each checkpoint once during construction,
validate its physical model, and consume its declared Newton control
buffers. Physics code does not inspect environment action classes or
consult the simulation singleton.
- Kept model-only `NeRDCfg`, independent `NeRDTrainingCfg`, and separate
recording environment configurations, with independent registry entries.
- Recording uses normal environment stepping, exploration
action/reset/termination terms, RecorderManager episode capture, and a
native trajectory output handler. It needs neither #9121 nor an
intermediate HDF5 conversion.
- Dedicated `scripts/neural/record.py` and `train.py` own dynamics
collection and offline fitting, including early task configuration
resolution. The neural library has no task registry dependency or preset
selection. Policy training and playback use existing RL entrypoints.
Bounded policy scoring uses `isaaclab play --rl_library rsl_rl
--evaluate`; there is no neural-specific policy evaluator or second
preset-resolution path.
- Existing shared physics configurations declare neural solvers
alongside numerical alternatives for Reach, locomotion velocity, and
Allegro. Robot-specific checkpoint settings and standalone timing are
declared in task fields. There are no neural-only physics subclasses or
runtime preset-container reconstruction. The redundant Franka
environment base is removed. Locomotion simulation defaults and sensor
periods are declarative; dependent G1, Digit, and Asimov tasks reuse the
defaults to preserve their behavior. Other robots require explicitly
supplied compatible checkpoints.
- Added neural presets for Franka reach (`newton_nerd`), ANYmal C flat
(`newton_nerd`), and Allegro reorientation (`newton_mjwarp_nerd`).
- Added the optional `newton-neural` extra pinned to
`06da4d2a604f3dbb48127a9010c41511cdd37a32`, dependency licensing, wheel
metadata handling, Docker/CI integration, API reference, how-to
documentation, and package changelog fragments. Task configurations
remain importable without the optional library.

## Configuration layout

```text
isaaclab_neural/
├── nerd_cfg.py
├── physics/                 # Solver adapters and configs
├── rl/nerd_training_cfg.py
└── record/                  # Recorder terms, output handler and configs

<task>/config/<robot>/
├── *_env_cfg.py
├── agents/                  # Action-producing policy configurations
├── dynamics/
│   ├── nerd_cfg.py
│   └── nerd_training_cfg.py
└── record/
    ├── nerd_recording.py
    └── nerd_recording_cfg.py
```

Task composition and its integration tests live in scripts and
`isaaclab_tasks/test/neural`; library unit tests enforce import
isolation and prohibit task resolution. CI includes the relocated
integration tests.

Models do not contain recording, training or inference workflow
configuration. Recorder terms capture complete transitions before
automatic reset; the output handler exports independent episodes with
invalid padding. Checkpoints require Isaac Lab physical-model metadata.
Standalone learned dynamics use the standard Newton collision lifecycle,
including scenes without contact sensors.

## Validation

Latest structural changes:

- Latest shared-configuration update: **42 focused tests passed**,
including configuration isolation, task composition, architecture gates,
and Franka controllers. Earlier recording and offline training checks
also passed.
- Before/after comparisons passed for **34 configurations**: 10
numerical/neural ANYmal and Allegro configurations, eight sibling task
configurations, and 16 Reach numerical/controller configurations.
- Live neural rollouts passed for **all three tasks**, each with four
environments, eight steps, and finite observations using the standard
Newton manager. Standalone tasks retain their model-frame timestep;
Allegro retains numerical substeps.
- The relocated full solver suites were attempted but the processes were
killed under machine memory pressure (exit 137); those full reruns did
not complete. Solver test bodies and native solver implementation are
unchanged in this structural update.
- Repository formatting/lint, changelog validation, and the Sphinx
warning-as-error build passed.

Earlier validated changes:

- Manager removal: neural solver, numerical parity, reset, recording,
training and environment action-lifecycle coverage: **27 passed**.
- Focused Newton construction, reset, pending-model-change and action
handling: **14 passed**.
- Task directory moves: configuration/import isolation, recording on all
three tasks, and offline training: **11 passed**.
- Shared playback evaluation: **96 selected tests passed** with optional
SKRL installed; a real checkpoint evaluation completed all 8 episodes
and closed cleanly.
- Throughput smoke: 256 ANYmal environments, 200 measured steps after
warmup, approximately **44,135 environment transitions/s** (5.800 ms per
vector step) on the available GPU. This is a smoke measurement, not a
before/after speedup claim.
- Full repository formatting/lint and changelog checks passed. Clean
Sphinx HTML build passed with warnings treated as errors.
- Structural audit confirms there is no neural manager, custom solver
factory, physics dependency on environment action classes, neural policy
evaluation path, compatibility shim, or task-root neural workflow
module.
- Large-scale policy learning and learned-model quality benchmarks were
not rerun.

## Checklist

- [x] Read the contribution guidelines
- [x] Run formatting, lint and package changelog checks
- [x] Update documentation and run its warning-as-error build
- [x] Validate the changed behavior and ownership boundaries
- [x] Add package changelog fragments
- [x] Update CONTRIBUTORS.md

---------

Signed-off-by: Mehdi Ataei <mataei@nvidia.com>
Co-authored-by: Octi Zhang <zhengyuz@nvidia.com>
Co-authored-by: Kelly Guo <kellyg@nvidia.com>
@ooctipus
ooctipus force-pushed the configurable-step-function branch from 388bb25 to 058a7d1 Compare November 25, 2026 08:43

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation isaac-lab Related to Isaac Lab team isaac-mimic Related to Isaac Mimic team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants