Reinforcement Learning Environemts in JAX.
Project description
Unified Functional Interface for RL Environments
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:
gxmunifies different environment libraries behind one tiny API. This eases development and experimentation with different environments. - 🌐Broad Environment Support:
gxmsupports 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
vmapand behave (almost) exactly like the other JAX-native environments! - ✅Handling Truncation:
gxmhandles 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, turbulence_power=1.5)
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
obs: jax.Array
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.
- Brax (Physics-based Environments in JAX)
- DeepMind Control Suite (Physics-based Environments in Python)
- Jumanji (Various RL Environments in JAX)
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{gxm2025github,
author = {Henrik Metternich},
title = {{gxm}: Unified Functional Interface for RL Environments in JAX},
url = {https://github.com/huterguier/gxm},
version = {0.1.1},
year = {2025},
}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gxm-0.1.3.tar.gz.
File metadata
- Download URL: gxm-0.1.3.tar.gz
- Upload date:
- Size: 25.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
421aeb7a1be6fe11b7a0ba4649f35159bc24f8709542277c32dc13a92d5b2a3b
|
|
| MD5 |
eefe521d7ebb397ea71d607991e0cc0b
|
|
| BLAKE2b-256 |
bc1578272751a8bfc7b38f489284ab3cb9a8f4b7ea70b1f79f697ea48aa6b307
|
File details
Details for the file gxm-0.1.3-py3-none-any.whl.
File metadata
- Download URL: gxm-0.1.3-py3-none-any.whl
- Upload date:
- Size: 37.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
951a68bfda753bd0742bc219cfd7a538349300d5b291c4e4a98ff22335657770
|
|
| MD5 |
fceb5b56267fa1f023bf76583b180d65
|
|
| BLAKE2b-256 |
ac2e2398c51fb53d1cb79fb6afa2f25a22f0c843df6f524eefe6ae48d2cfc36c
|