Repository navigation
Return clean FIRST timesteps after random no-op starts - #386
Open
sylvesterkaczmarek wants to merge 1 commit into
Open
sylvesterkaczmarek wants to merge 1 commit into
sylvesterkaczmarek wants to merge 1 commit into
Conversation
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 #385.
Problem
NoopStartsWrapper.reset() executes a random number of no-op actions to randomize the initial state of an otherwise deterministic environment. It currently takes the final timestep and replaces only its step_type with FIRST.
When the final no-op action produces an ordinary MID timestep, its reward and discount remain populated. The synthetic FIRST is therefore internally inconsistent: it carries a reward and discount for an initialization-only step. Agents or episode collectors treating FIRST as the beginning of a fresh episode may incorrectly consume those fields. The same situation arises after the wrapper resets an episode that terminated during the no-op sequence and then continues stepping.
Fix
Return dm_env.restart(timestep.observation) after the initialization steps. This preserves the actual final observation, including the updated state reached after the no-op actions, but correctly returns reward=None and discount=None on FIRST. The number of no-ops sampled, their action values and handling of early terminal timesteps are unchanged.
Reproduction and testing
Scope and limitations
The change only corrects the synthetic FIRST timestep returned by reset(). No-op selection, random seeds and underlying episode control are unchanged. The complete TensorFlow/Reverb-based Acme integration environment is not installed locally; the focused regression was run using an isolated import harness to avoid those unrelated legacy dependencies. This is independent of the DelayedRewardWrapper fix in #384.