Add an option to capture true terminal observations under auto-reset.#1030
Open
kevinzakka wants to merge 1 commit into
Open
Add an option to capture true terminal observations under auto-reset.#1030kevinzakka wants to merge 1 commit into
kevinzakka wants to merge 1 commit into
Conversation
With auto-reset, step() returns the post-reset observation for done environments, losing the true terminal state. Add an opt-in capture_terminal_observations flag that stashes it in extras["terminal"] before reset. Fixes #1026
Collaborator
Author
|
Cool! Right now |
|
Hi @realquantumcookie, before this PR is landed, for auto reset |
|
@zhuoqun-chen Before this PR lands, I disabled auto-reset so when one of the environment terminates it gives the correct |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Some algorithms need the true terminal state at episode boundaries: value bootstrapping at truncation needs the real next state to bootstrap from (the original ask in #900), and AMP-style rewards need it because the discriminator scores
(s_t, s_{t+1})transitions, so a wrong final state means scoring a transition into the next episode's initial state instead of the actual one (#1026). Our current auto-reset returns the post-reset observation for done environments, so that terminal state is lost.This PR adds an opt-in
capture_terminal_observationsflag. When it's on and an environment resets,step()stashes that environment's true terminal observation inextras["terminal"]before the reset. It's off by default and the key is only present on reset steps, so existing setups are unchanged.The snapshot is read-only (it never touches the live history/delay buffers or the RNG), so the terminal observation is the noise-free terminal state with delay and history applied. To turn it into a full next observation:
Fixes #1026