Unit 7 of 12 · about 4 hours · implement

Environment, wrapper and version identity, action repeat and normalization

Wrappers silently change the task: rescaled actions, normalized observations and resolved timeouts all alter what the numbers mean. Identity first, ranking second.

You'll be able to

  • Record environment, wrapper and dependency versions so a run can be rebuilt exactly.
  • Separate termination from truncation and bootstrap only the truncated case.
  • Apply action repeat, observation normalization and reward transforms as declared wrappers, never silent edits.

Covers

Environment, wrapper and dependency version identityAction repeat, observation normalization and reward transformation
1

Read

In this order, only the parts listed

0 of 3 done

  1. Gymnasium time limits: termination versus truncationGymnasium documentation: API, time limits, vector envs and wrappers

    Sections Termination, Truncation and Importance in learning code: terminal states end the MDP while truncation stops it externally, with the rule that termination cuts the bootstrap and truncation keeps it (page read 2026-10-14)

  2. Gymnasium API: Env contract, vector envs and wrappersGymnasium documentation: API, time limits, vector envs and wrappers

    Env reset returning obs and info with seed handling and step returning obs, reward, terminated, truncated and info. The vector and wrapper pages in the API sidebar cover SyncVectorEnv and AsyncVectorEnv with NEXT_STEP autoreset and the wrappers TimeLimit, RecordEpisodeStatistics, ClipAction and NormalizeObservation (page read 2026-10-14)

  3. SB3 tips: custom environments and wrapper hygieneStable-Baselines3 RL Tips and Tricks

    Tips and Tricks when creating a custom environment: normalize observations and rescale continuous actions to [-1, 1], verify with check_env, handle timeout truncation separately, and the evaluation warning that wrappers change measured rewards and lengths (page read 2026-10-14)

2

Focus on

  • terminated ends the MDP and truncated stops it from outside, and only truncation bootstraps the next value.
  • Vector envs default to NEXT_STEP autoreset: the done step returns the true final transition, then the next step ignores its action and returns the reset observation with reward 0 and both flags false.
  • Gaussian policies start centered at 0 with unit width, so unnormalized action spaces harm learning silently; rescale to inside the recorded wrapper.
  • Every wrapper that touches reward, length or observation is part of the env identity: TimeLimit length, action repeat, normalization stats and reward transforms all get versioned.
Common mistakes · 3
  • Reading final_observation on Gymnasium 1.x. Version 1.0 removed that key: same-step mode now writes final_obs and final_info, and the default next-step mode writes neither, so CleanRL-era code that needs final_observation raises KeyError at truncation.
  • Storing the autoreset step as experience. Its action was ignored and its reward is 0 by construction, so training on it teaches a fake transition.
  • Comparing across different wrapper stacks. A normalized versus raw observation run or a different TimeLimit length is a different environment, not a better algorithm.
3

Try it yourself

Closed-book, before checking anything

Closed-book, write the five-tuple step contract and the bootstrap rule for each end flag. For a 2-env vector run with max steps 5, state which step returns the true final transition and why the following autoreset step with reward 0 must never be stored as a transition.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.An episode ends at the TimeLimit with no terminal state. Do you bootstrap the value target?Answer

    Yes. Truncation stops the MDP externally, so the value beyond the boundary still matters. Only true termination cuts the bootstrap.

  2. 2.A vector step returns done flags true and the next step returns reward 0 with flags false. What happened?Answer

    NEXT_STEP autoreset. The done step carried the true final transition; the next step reset the sub-env and ignored its action. Do not store the reset step as a transition.

  3. 3.Old code reads infos["final_observation"] on Gymnasium 1.4 and crashes at truncation. Why?Answer

    Gymnasium 1.0 removed that key. Same-step mode writes final_obs and final_info instead, and the installed default, next-step mode, writes neither because the final observation arrives on the done step itself. Port the code to the mode it runs in.

  4. 4.Two SAC runs differ only in that one normalizes observations. Can you rank the algorithms from them?Answer

    No. Normalization changes the task interface, so the runs measure different setups. Match the full wrapper stack first, then compare.

You're done when

Your manifest rebuilds an env bit-identically, your bootstrap test passes for both end flags, and no comparison you report mixes wrapper stacks.

Only when you can do this without notes.

Leads to

Notes

Resources · 2 for this unit, 12 more in the section
  • Gymnasium documentation: API, time limits, vector envs and wrappersFarama Foundation · reference

    Use the Env API page for the reset and step contract, the handling-time-limits tutorial for termination versus truncation bootstrapping, the vector env pages for SyncVectorEnv and AsyncVectorEnv autoreset modes, and the wrappers table for RecordEpisodeStatistics, ClipAction, NormalizeObservation and TimeLimit.

  • Stable-Baselines3 RL Tips and TricksStable-Baselines3 · reference

    Use How to evaluate an RL algorithm for separate test envs, EvalCallback and deterministic eval; Which algorithm should I use for the discrete/continuous/goal picker and HER pointer; the custom-environment section for Markov, normalization and TimeLimit handling; and the seed-variance and RL-zoo tuning advice. Treat SOTA and speedup claims as pointers, not targets.

Also in this section

  • Berkeley CS 185/285 Deep Reinforcement Learning (Spring 2026) - Exploration and Off-Policy Actor-CriticUC Berkeley · primary

    Slides are public at https://rail.eecs.berkeley.edu/deeprlcourse/static/slides/lec-N.pdf; current videos are not, and the public Fall 2023 playlist numbers lectures differently. Study Lecture 19 (exploration) and Lecture 23 (advanced exploration), and the SAC part of Homework 3 (src/agents/sac_agent.py on InvertedPendulum and Hopper; HalfCheetah needs hours on a GPU). The homework pins gym==0.25.2, which fails on NumPy 2, so port it to Gymnasium (terminated and truncated) or pin numpy<2 in its own environment, and turn off its forced WandB logging.

  • Stanford CS234 Winter 2026 - Bandits and ExplorationStanford University · required

    Study Lectures 9 to 12 (bandits, optimism and upper confidence bounds, exploration in MDPs). Rebuild one exploration comparison with matched information, interaction, update and tuning budgets.

  • Stanford CS224R Spring 2026 - Off-Policy and Goal-Conditioned RLStanford University · required

    Study Lecture 05 (off-policy actor-critic) and Lecture 12 (multi-task and goal-conditioned RL) and their DDPG and HER readings. Implement one goal relabeling test on a small task.

  • Soft Actor-Critic Algorithms and ApplicationsBerkeley AI Research · required

    Read the maximum-entropy objective, the soft policy iteration and the actor and critic targets, then the automatic temperature adjustment (this version adds it; the first SAC paper used a fixed temperature). Implement or audit a compact SAC path and compare sample efficiency and wall time with PPO under a matched protocol.

  • Addressing Function Approximation Error in Actor-Critic Methods (TD3)Fujimoto, van Hoof and Meger (ICML 2018) · required

    Read the overestimation analysis for actor-critic methods, clipped double Q-learning, delayed policy updates and target policy smoothing. Ablate one of the three changes on a small continuous task with matched seeds.

  • Hindsight Experience ReplayAndrychowicz et al. (NeurIPS 2017) · required

    Read the goal-conditioned setup and the relabeling strategies (final, future, episode). Implement relabeling on a sparse-reward bit-flipping or goal task and test that relabeled transitions carry the substituted goal and its recomputed reward.

  • Exploration by Random Network DistillationBurda et al. (ICLR 2019) · support

    Read the prediction-error bonus, the separate intrinsic and extrinsic value heads and the non-episodic intrinsic return. Use it to explain why a novelty bonus depends on the representation and how it can reward noise.

  • Unifying Count-Based Exploration and Intrinsic MotivationBellemare et al. (NeurIPS 2016) · support

    Read the pseudocount derivation from a density model and the exploration bonus built on it. Compare a tabular count bonus with its pseudocount form on a small grid.

  • Deep Reinforcement Learning at the Edge of the Statistical PrecipiceDeepMind and Google Research · required

    Study the failure of common point estimates and small-seed comparisons. Report interval estimates, aggregate-score sensitivity and performance profiles with the underlying per-run data retained.

  • What Matters in On-Policy Reinforcement Learning? A Large-Scale Empirical StudyAndrychowicz et al. (2020) · support

    Read the experimental protocol and the recommendations on normalization, initialization and hyperparameter sensitivity. Use it to set a tuning budget that is the same for every method you compare.

  • rliableGoogle Research · support

    Use the official repository to compute interquartile means, stratified bootstrap intervals and performance profiles for the track experiments. Verify the input run and task axes and keep plots reproducible from raw run records; check the pandas version it needs in your environment.

  • Hands-on Modern RL - DDPG, TD3, SAC and Intrinsic MotivationWalking Labs · support

    Use the DDPG and TD3 and SAC pages for vocabulary and the intrinsic-motivation page for concepts only. Its displayed TD3 target omits the terminal mask (the code has it), its SAC chart is author-reported, and its multi-agent demo does not learn; do not use those as practice. Pin commit 9231bab of walkinglabs/hands-on-modern-rl; its code/chapterNN folders do not follow the site chapter numbers.