Repository navigation
Conversation
BraxAutoResetWrapper replaced state.obs with the reset observation on done
and kept no copy, so a learner had no way to reach s_{t+1} when an episode
was truncated. wrap_for_brax_training already reports the distinction in
info['truncation'], but bootstrapping it needs the observation as well, and
V(s_reset) was being used instead - on locomotion tasks that is an upright
pose rather than whatever the agent was doing when the time limit hit.
Put it in info['AutoResetWrapper_final_obs'], set in reset as well as step
so the info structure is the same either way. Fixes google-deepmind#305.
Signed-off-by: Shubh <shubh@shubhxho.com>
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
This branch has not been deployed
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.
Fixes #305.
Problem
BraxAutoResetWrapper.stepreplacesstate.obswith the reset observation ondoneand keeps no copy of what the step actually produced.wrap_for_brax_trainingalready exposes the termination/truncation distinction throughinfo['truncation'](set by brax'sEpisodeWrapper), but computing the truncation bootstrap needsV(s_{t+1})as well, ands_{t+1}is gone by the time the learner sees the state.Every actor-critic built on Playground therefore bootstraps
V(s_reset)at each truncation. On locomotion taskss_resetis an upright starting pose rather than whatever the agent was doing when the time limit hit, and the bias grows with episode length and gamma.Reproduced on
CartpoleBalancewithepisode_length=4:Fix
Store the pre-reset observation in
info['AutoResetWrapper_final_obs']. Two details beyond the one-liner suggested in the issue:resetas well asstep, otherwise the info pytree structure differs between the two and they cannot be used together underscan.full_resetit is written after thejax.tree.map(where_done, reset_state.info, state.info)merge, otherwise the reset state's copy wins on exactly the steps where the value matters.The extra memory is one observation, which is what
AutoResetWrapper_first_obsalready keeps, so this does not change the wrapper's footprint profile.Testing
New
test_auto_reset_wrapper_keeps_final_obs, parameterised overfull_reset, asserts the kept observation is the one the step produced, thatstate.obsis still the reset observation, and thatresetandstepproduce the same info treedef. Both parameterisations fail without the change towrapper.py.