github Farama-Foundation/Gymnasium v1.4.0

4 hours ago

Gymnasium v1.4.0

This release adds max_concurrency to AsyncVectorEnv, support for arbitrary node and edge spaces in Graph, optional key sorting for Dict, generic typing for vector environments, and a large number of bug fixes across spaces, wrappers, vector environments and MuJoCo rendering.

New Features

  • Added max_concurrency to AsyncVectorEnv to cap how many sub-environments run reset/step at once, reducing CPU oversubscription when the number of environments exceeds the number of cores. Also usable via gym.make_vec(..., vectorization_mode="async", vector_kwargs={"max_concurrency": N}) by @lawliet206 (#1673)
  • Graph spaces now accept Dict and Tuple spaces for their node and edge spaces, enabling heterogeneous graphs and named node/edge features by @2ToTheNthPower (#1514)
  • Added a keyword-only sort_keys argument to Dict spaces. It defaults to True (existing behaviour), while sort_keys=False preserves the insertion order of the keys, including through wrappers such as FrameStackObservation by @quinnarnold (#1675)
  • VectorEnv, its subclasses and the vector wrappers are now generic types by @pseudo-rnd-thoughts (#1752)
  • The environment checkers (check_env and the passive checker run by make) now verify that reset and step return distinct observation and info objects each timestep, preventing buffers being silently overwritten in replay/rollout buffers. This found and fixed two info elements in Humanoid and HumanoidStandup that reused the same buffer between timesteps by @pseudo-rnd-thoughts (#1683)

Bug Fixes

It seems that the agents have reached Gymnasium, so a large quantity of previously unknown bugs have been reported and resolved.

Spaces

  • Fixed Discrete.contains and Box.contains raising OverflowError for integers outside the space's dtype range, they now return False by @nikolauspschuetz (#1648, #1663)
  • Fixed integer overflow in MultiDiscrete.contains for negative start values and small dtypes by @teddytennant (#1622)
  • Fixed Box.sample never returning values near the limits of signed integer dtypes by @shoutoutuoadi325 (#1666)
  • Fixed Text space charset ordering being non-deterministic under Python hash randomization, making seeded samples reproducible across processes by @teddytennant (#1626)
  • Text spaces now reject charset elements that are more than one character long by @adarshsm (#1653)
  • Fixed flatten and flatten_space disagreeing on the dtype of OneOf spaces, so FlattenObservation observations are contained in its observation space, and OneOf spaces containing Text can be flattened by @teddytennant (#1674)
  • is_space_dtype_shape_equiv now requires Tuple spaces to have equal lengths, previously a shorter Tuple could be accepted (or an IndexError raised) by @Doribelove (#1694)

Wrappers

  • Fixed several wrappers not recording all of their constructor arguments, meaning environments rebuilt with gym.make(env.spec) either raised a TypeError or silently used default arguments:
    • AddRenderObservation recorded stale argument names from PixelObservationWrapper by @uttam12331 (#1658)
    • DiscretizeAction, DiscretizeObservation, RecordEpisodeStatistics, RecordVideo and StickyAction by @mkzung (#1664)
    • ArrayConversion and its JaxToNumpy, JaxToTorch and NumpyToTorch subclasses by @mkzung (#1667)
  • DiscretizeObservation and DiscretizeAction now support n-dimensional Box spaces by flattening them by @teddytennant (#1691, #1703)
  • DtypeObservation now keeps a Discrete observation space when changing dtype and accepts NumPy dtype descriptors (e.g. np.float32, "float32") by @teddytennant and @NaCr05 (#1688, #1706)
  • ResizeObservation now preserves singleton channel dimensions (e.g. (H, W, 1) observations) by @NaCr05 (#1704)
  • RescaleAction now raises an InvalidBound error when a min action equals the max action, rather than producing nan actions by @mkzung (#1665)
  • NormalizeObservation and NormalizeReward (including the vector versions) now reject invalid gamma and epsilon values, which previously produced nan or diverging outputs by @DenisDrobyshev (#1669)
  • RecordVideo now reports a single clear error when the environment's render mode is incompatible, instead of three by @DenisDrobyshev (#1671)

VectorEnv

  • Fixed vector RecordEpisodeStatistics reporting incorrect episode statistics with SAME_STEP autoreset by @teddytennant (#1624)
  • Fixed vector NormalizeReward under SAME_STEP autoreset by @teddytennant (#1668)
  • Fixed vector environments modifying the sub-environment's class-level metadata when setting autoreset_mode by @teddytennant (#1623)
  • Fixed AsyncVectorEnv shared memory for dtypes without an array module typecode, e.g., float16 by @teddytennant (#1632)

Env

  • MuJoCo environments' default_camera_config now takes effect when no camera_id or camera_name is given, previously it was ignored as the fixed "track" camera was always used. Note that this changes the rendered output of MuJoCo environments by @Functionhx (#1618)
  • Fixed mouse and scroll camera controls in human-rendered MuJoCo environments with MuJoCo 3.11+ by @Yuming-Lee24 (#1678)
  • MujocoEnv no longer shrinks an offscreen framebuffer size declared in the model XML by @midhunxavier (#1642)
  • Fixed the CarRacing HUD score overflowing due to float formatting by @Fstarnb (#1639)
  • CliffWalking now uses the new Farama pixel art for rendering by @MannXo (#1713)

Utilities

  • Fixed make and make_vec rejecting registered environments whose entry point is a Wrapper subclass by @tandede (#1672)
  • Fixed check_environments_match comparing env_b's observation space to itself by @betacatsling (#1708)
  • Fixed determinism checks in the environment checker by snapshotting observations that are reused between steps, and comparing the current RNG state in check_step_determinism by @zjn20030811 and @NaCr05 (#1682, #1705)
  • Fixed several bugs in play: window resizing drift and float sizes, a crash on KEYUP events and validation of zoom by @Ankush0077 (#1633)

Third-Party Environments

3 new community environments have been added to the third-party environments list: WireHarness-MultiGripper-RL, Ignis and Kraken Crossing.

Full Changelog: v1.3.0...v1.4.0

Don't miss a new Gymnasium release

NewReleases is sending notifications on new releases.