Skip to content

Clear stale terminal observations and copy them before resets - #9103

Merged
AntoineRichard merged 5 commits into
isaac-sim:mainfrom
lgulich:lgulich/final-obs-small-fixes
Nov 20, 2026
Merged

AntoineRichard merged 5 commits into
isaac-sim:mainfrom
lgulich:lgulich/final-obs-small-fixes

Conversation

@lgulich

@lgulich lgulich commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Three small fixes around terminal observations, split out of #8868 so that PR only changes how stateful observations are captured.

extras["final_obs"] was only written on steps with resets and never removed. A later step without resets still carried the terminal observations of an earlier step, and wrappers that check for the key would pick them up again. Manager-based, direct and multi-agent environments now drop it at the start of every step and in explicit reset() calls, and manager-based environments also in reset_to().

Direct and multi-agent environments stored the tensors returned by _get_observations() as terminal observations. Tasks may return views of their own buffers, which the following _reset_idx() overwrites, so the terminal observation could end up holding the reset state. They are now copied before the reset. Manager-based environments already return owned tensors.

The Humanoid AMP environment assigned self.extras = {"amp_obs": ...} while computing observations, which replaced the whole dict and dropped time-outs, episode logs and terminal observations set earlier in the step. It now only sets its own key.

The env unit test steps a manager-based, a direct and a multi-agent environment with stubbed physics through an autoreset step, a step without reset, and an explicit reset (plus reset_to() for the manager-based one). It checks that the terminal observation is the pre-reset state, that the key is gone after the step without reset and after the explicit resets, and that an unrelated extras entry survives throughout. The AMP test calls the real _get_observations() with stubbed robot data and checks that final_obs and time_outs are kept. Both fail on main.

Co-authored with Rafael Cathomen and Antoine Richard, who wrote these changes in #8868.

To run the tests:

./isaaclab.sh -p -m pytest source/isaaclab/test/envs/test_manager_based_rl_env_unit.py \
    source/isaaclab_tasks/test/test_humanoid_amp_extras.py

🤖 Generated with Claude Code

extras["final_obs"] was only set on steps with resets and never removed,
so a later step without resets still carried the terminal observations
of an earlier step. Every step now drops it before stepping.

Direct and multi-agent environments stored the observation tensors
returned by the task, which may borrow task buffers that the following
reset overwrites. They now copy them first.

The Humanoid AMP environment replaced the whole extras dict while
computing observations, dropping time-outs, episode logs and terminal
observations set earlier in the step. It now only sets its own key.

These fixes come from isaac-sim#8868, split out so that PR only changes how
stateful observations are captured.

Co-authored-by: Rafael Cathomen <[email protected]>
Co-authored-by: Antoine Richard <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added bug Something isn't working isaac-lab Related to Isaac Lab team labels Nov 19, 2026

@AntoineRichard AntoineRichard left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The step-level fixes address the stale key and buffer aliasing. Please also clear terminal observations on explicit reset and cover the Humanoid AMP data-loss regression at the task boundary.

I ran the changed unit test file on this commit. All five tests passed. The three new cases failed on the PR base for the expected stale-key or tensor-aliasing bugs.

self.amp_observation_buffer[:, 0] = obs.clone()
self.extras = {"amp_obs": self.amp_observation_buffer.view(-1, self.amp_observation_size)}
# keep the other extras of this step, e.g. time-outs, episode logs and terminal observations
self.extras["amp_obs"] = self.amp_observation_buffer.view(-1, self.amp_observation_size)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Cover the Humanoid AMP extras regression at the task boundary.

The generic direct-env test substitutes _get_observations(), so it passes if this method goes back to replacing extras. A small CPU test can call the real AMP observation method with a preexisting final_obs entry and assert that it survives alongside amp_obs. I tried that check with stubbed robot data. It passes here and fails on the base with KeyError: 'final_obs'.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added test_humanoid_amp_extras.py. It calls the real HumanoidAmpEnv._get_observations with stubbed robot data and a final_obs already in extras, and checks it survives next to amp_obs. Fails on the base with KeyError: 'final_obs'.

A reset() right after an autoreset step returned the new initial
observation together with the previous step's final_obs. The public
reset of manager-based, direct and multi-agent environments now drops it
and keeps the other reset extras.

The step test now runs an autoreset step, a normal step and an explicit
reset, without pre-seeding stale entries, and checks the terminal values
of both agents of the multi-agent environment. A separate test calls the
real Humanoid AMP observation method and checks that a terminal
observation set earlier in the step survives next to amp_obs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@lgulich
lgulich marked this pull request as ready for review November 20, 2026 12:33
@lgulich
lgulich requested a review from a team November 20, 2026 12:33

@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: Style consistency (4), Test quality (2). Other reviewed categories look good.

  • PR description: Update stale validation paths, include AMP coverage, narrow unsupported interval/stability claims, supply baseline-failure evidence, and compare cloning revisions, command/workload, hardware, backend, software environment, environment count, warmup, throughput, and peak memory.
  • Design and architecture: Architecture looks good.
  • Scope and over-engineering: No over-engineering issues.
  • API: API changes look good.
  • Compatibility and deprecation: No breaking changes identified.
  • Implementation: Implementation looks good.
  • Style consistency: The AMP fixture retrieves compute_obs through method globals, coupling setup to implementation structure; import the known function directly.
  • Test quality: The reset stub recreates log, so wholesale extras deletion would escape the environment regression; seed an unrelated sentinel and assert preservation through stepping and explicit reset.

Minor fixes needed. Posted 6 inline findings.

Automated review; human maintainers own approval decisions.

@greptile-apps

greptile-apps Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The changes affect terminal data returned by three common environment styles and one task-specific extras path.

The PR appears safe to merge, with a non-blocking gap in terminal observation cleanup for reset_to().

Findings

  1. P2 `reset_to()` retains old terminal observations ▶

Summary

This PR fixes terminal observations across manager-based, direct, and multi-agent environments.

  • Terminal observations are cleared when a new step or reset begins.
  • Direct and multi-agent environments keep terminal observations separate from task buffers.
  • Humanoid AMP adds its observation history without replacing other step extras.

Reviews (1) · Last reviewed commit: "Clear terminal observations on explicit ..." · Reviewed by Greptile

@AntoineRichard

Copy link
Copy Markdown
Collaborator

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
reset_to() is another explicit reset, so it drops extras["final_obs"]
like reset() does. Comment placement in the direct env resets now
matches the code it describes.

The tests check key absence instead of a None helper, keep an
unrelated extras entry across steps and resets, and import their
dependencies at module scope.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

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

Could you mark the new env and AMP tests kitless? Both pass without Isaac Sim, but pytest -m kitless skips them.

Both run without Isaac Sim, so the Kit-less CI job should pick them up.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@lgulich

lgulich commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

@maxkra15 done in 478e8d0. Both tests are marked kitless now (the env test via a decorator since the older tests in that file aren't part of this PR) and pytest -m kitless runs them.

@maxkra15

Copy link
Copy Markdown
Contributor

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

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

lgtm

@AntoineRichard AntoineRichard left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@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
@AntoineRichard
AntoineRichard enabled auto-merge (squash) November 20, 2026 16:34
@AntoineRichard
AntoineRichard merged commit fe51ca8 into isaac-sim:main Nov 20, 2026
63 of 91 checks passed
@lgulich lgulich mentioned this pull request Nov 21, 2026
7 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants