Repository navigation
Clear stale terminal observations and copy them before resets - #9103
Conversation
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]>
AntoineRichard
left a comment
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
[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'.
There was a problem hiding this comment.
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]>
There was a problem hiding this comment.
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.
[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 Findings
SummaryThis PR fixes terminal observations across manager-based, direct, and multi-agent environments.
Reviews (1) · Last reviewed commit: "Clear terminal observations on explicit ..." · Reviewed by Greptile |
|
run-ci |
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
left a comment
There was a problem hiding this comment.
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]>
|
run-ci |
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 explicitreset()calls, and manager-based environments also inreset_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 thatfinal_obsandtime_outsare kept. Both fail on main.Co-authored with Rafael Cathomen and Antoine Richard, who wrote these changes in #8868.
To run the tests:
🤖 Generated with Claude Code