Skip to main content

Unified Functional Interface for RL Environments

PyPI version License: MIT Documentation Code Style: Black

gxm aims to be the gym-equivalent for JAX-based RL Environments. It normalizes different environment backends behind one tiny, purely functional API that is jit, vmap and scan friendly and explicit about randomness. For a more detailed description please refer to the documentation.

Features

  • 🤝Unified Functional Interface: gxm unifies different environment libraries behind one tiny API. This eases development and experimentation with different environments.
  • 🌐Broad Environment Support: gxm supports a wide range of environments from different libraries. A complete list of supported environments can be found below.
  • 💻CPU based Enironments: Run your favorite CPU based environments directly in JAX via callbacks. These wrappers also support vmap and behave (almost) exactly like the other JAX-native environments!
  • Handling Truncation: gxm handles truncation and termination in a unified way across all environments. Note that handling trunctation in JAX adds a slight memory overhead but can be disabled if not needed.

API

Environments in gxm can be created in the standardized way by using a make function. The identifier strings are of the form <Library>/<Environment-Name>.

import gxm
env = gxm.make("Gymnasium/LunarLander-v3")

Alternatively you can also be explicit about the environment creation and import the corresponding environment for instantiation. In both cases environment parameters will be passed to the underlying environment library.

from gxm.environments import GymnasiumEnvironment
env = GymnasiumEnvironment("LunarLander-v3", gravity=-10.0, wind_power=15.0)

The returned environment object exposes the methods init, step and reset. Note that there is a clear distinction between reset and init. init is used to create a new environment state from scratch while reset is used to reset an existing environment state. For fully functional environments there is no difference between the two, but for CPU based environments reset will reuse the existing environment instance while init will create a new one. In addition this conforms to the common JAX pattern of having an init function to create an initial state.

env_state, timestep = env.init(key)
for _ in range(1e3):
    env_state, timestep = env.step(key, env_state, action)
env_state, timestep = env.reset(key, env_state)

As a reminder, you should never use for loops for environment rollouts in JAX. This is just for demonstration purposes. A single timestep has the following signature in gxm. Here true_obs stores the observation that would have been observed if there was no truncation. Hence obs and true_obs only differ whenever truncated is true.

class Timestep:
    reward: jax.Array
    terminated: jax.Array
    truncated: jax.Array
    next_obs: jax.Array
    next_true_obs: jax.Array
    info: dict[str, Any]

Supported Environments

Currently gxm supports the following Libraries.

  • Gymnax (Classic Control, bsuite and MinAtar)
  • Pgx (Boardgames and MinAtar)
  • Navix (Minigrid in JAX)
  • Envpool (Vectorized Gymnasium Environements)
  • Craftax (Crafter in JAX)
  • Gymnasium (Classic Control, Atari, Box2D, MuJoCo, etc.)

The following environments are planned to be supported in the future.

Installation

gxm can be installed directly from PyPI.

pip install gxm

By default Gxm comes without any of the underlying environment libraries. You can install any combination of them by using optional dependencies or all of the at once using all.

pip install gxm[gymnax, pgx, navix, envpool, craftax, gymnasium]

Citation

If you use gxm in your research, please cite it as follows. Please also cite the underlying environment libraries that you used. Their Githubs are linked above.

@software{gxm2026github,
  author = {Henrik Metternich},
  title = {{gxm}: Unified Functional Interface for RL Environments in JAX},
  url = {https://github.com/huterguier/gxm},
  version = {0.4.0},
  year = {2026},
}

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gxm-0.4.0.tar.gz (24.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gxm-0.4.0-py3-none-any.whl (34.0 kB view details)

Uploaded Python 3

File details

Details for the file gxm-0.4.0.tar.gz.

File metadata

  • Download URL: gxm-0.4.0.tar.gz
  • Upload date:
  • Size: 24.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for gxm-0.4.0.tar.gz
Algorithm Hash digest
SHA256 2b0d5cb0da307f83223733da4cfd35eaf5fd96304420044d38e581edf776d0df
MD5 0d10f6c1f0fe5e0d0e011b6d4f7c2271
BLAKE2b-256 11651be30ab390876f8198737da76a6d1c6621d8416238da4a4defffb038fe24

See more details on using hashes here.

File details

Details for the file gxm-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: gxm-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 34.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for gxm-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b90f1d0155a9189f2e5eb1dd78865fcad8dbe9b395ddd3bfa6379280b01b66d6
MD5 dd57f988173cb7d28c2855ad53a7bd34
BLAKE2b-256 cf92769948f30e90918cd5889fe83dd7fe7c0a6ede13227247c9ceda22adab8c

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page