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_concurrencytoAsyncVectorEnvto cap how many sub-environments runreset/stepat once, reducing CPU oversubscription when the number of environments exceeds the number of cores. Also usable viagym.make_vec(..., vectorization_mode="async", vector_kwargs={"max_concurrency": N})by @lawliet206 (#1673) Graphspaces now acceptDictandTuplespaces for their node and edge spaces, enabling heterogeneous graphs and named node/edge features by @2ToTheNthPower (#1514)- Added a keyword-only
sort_keysargument toDictspaces. It defaults toTrue(existing behaviour), whilesort_keys=Falsepreserves the insertion order of the keys, including through wrappers such asFrameStackObservationby @quinnarnold (#1675) VectorEnv, its subclasses and the vector wrappers are now generic types by @pseudo-rnd-thoughts (#1752)- The environment checkers (
check_envand the passive checker run bymake) now verify thatresetandstepreturn distinct observation and info objects each timestep, preventing buffers being silently overwritten in replay/rollout buffers. This found and fixed twoinfoelements inHumanoidandHumanoidStandupthat 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.containsandBox.containsraisingOverflowErrorfor integers outside the space's dtype range, they now returnFalseby @nikolauspschuetz (#1648, #1663) - Fixed integer overflow in
MultiDiscrete.containsfor negativestartvalues and small dtypes by @teddytennant (#1622) - Fixed
Box.samplenever returning values near the limits of signed integer dtypes by @shoutoutuoadi325 (#1666) - Fixed
Textspace charset ordering being non-deterministic under Python hash randomization, making seeded samples reproducible across processes by @teddytennant (#1626) Textspaces now reject charset elements that are more than one character long by @adarshsm (#1653)- Fixed
flattenandflatten_spacedisagreeing on the dtype ofOneOfspaces, soFlattenObservationobservations are contained in its observation space, andOneOfspaces containingTextcan be flattened by @teddytennant (#1674) is_space_dtype_shape_equivnow requiresTuplespaces to have equal lengths, previously a shorterTuplecould be accepted (or anIndexErrorraised) by @Doribelove (#1694)
Wrappers
- Fixed several wrappers not recording all of their constructor arguments, meaning environments rebuilt with
gym.make(env.spec)either raised aTypeErroror silently used default arguments:AddRenderObservationrecorded stale argument names fromPixelObservationWrapperby @uttam12331 (#1658)DiscretizeAction,DiscretizeObservation,RecordEpisodeStatistics,RecordVideoandStickyActionby @mkzung (#1664)ArrayConversionand itsJaxToNumpy,JaxToTorchandNumpyToTorchsubclasses by @mkzung (#1667)
DiscretizeObservationandDiscretizeActionnow support n-dimensionalBoxspaces by flattening them by @teddytennant (#1691, #1703)DtypeObservationnow keeps aDiscreteobservation space when changing dtype and accepts NumPy dtype descriptors (e.g.np.float32,"float32") by @teddytennant and @NaCr05 (#1688, #1706)ResizeObservationnow preserves singleton channel dimensions (e.g.(H, W, 1)observations) by @NaCr05 (#1704)RescaleActionnow raises anInvalidBounderror when a min action equals the max action, rather than producingnanactions by @mkzung (#1665)NormalizeObservationandNormalizeReward(including the vector versions) now reject invalidgammaandepsilonvalues, which previously producednanor diverging outputs by @DenisDrobyshev (#1669)RecordVideonow reports a single clear error when the environment's render mode is incompatible, instead of three by @DenisDrobyshev (#1671)
VectorEnv
- Fixed vector
RecordEpisodeStatisticsreporting incorrect episode statistics withSAME_STEPautoreset by @teddytennant (#1624) - Fixed vector
NormalizeRewardunderSAME_STEPautoreset by @teddytennant (#1668) - Fixed vector environments modifying the sub-environment's class-level
metadatawhen settingautoreset_modeby @teddytennant (#1623) - Fixed
AsyncVectorEnvshared memory for dtypes without anarraymodule typecode, e.g.,float16by @teddytennant (#1632)
Env
- MuJoCo environments'
default_camera_confignow takes effect when nocamera_idorcamera_nameis 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) MujocoEnvno longer shrinks an offscreen framebuffer size declared in the model XML by @midhunxavier (#1642)- Fixed the
CarRacingHUD score overflowing due to float formatting by @Fstarnb (#1639) CliffWalkingnow uses the new Farama pixel art for rendering by @MannXo (#1713)
Utilities
- Fixed
makeandmake_vecrejecting registered environments whose entry point is aWrappersubclass by @tandede (#1672) - Fixed
check_environments_matchcomparingenv_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_determinismby @zjn20030811 and @NaCr05 (#1682, #1705) - Fixed several bugs in
play: window resizing drift and float sizes, a crash onKEYUPevents and validation ofzoomby @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