Skip to main content

gymnasium-mjx

Reproduces Gymnasium's v5 MuJoCo tasks in pure JAX, on MJX, so that training runs end to end on the GPU: environment and agent compile into one program, and thousands of environments step at once.

This is not a Farama Foundation project. The model files are Gymnasium's, under its MIT licence (LICENSES/Gymnasium.txt).

Why

  • End-to-end JAX. With a JAX agent, one jitted program steps the environments and updates the agent: no Python between steps, no copies between host and device, and vmap runs thousands of environments, or several seeds, at once. A Python environment stops a JAX agent at every step.
  • The same tasks as the papers. JAX training so far meant look-alike tasks (Brax's, MuJoCo Playground's) with other models, rewards and observations, whose returns cannot be compared with published Gymnasium results. Here the model files are Gymnasium's, byte for byte, and the task code is Gymnasium's, translated line by line.

Install

pip install gymnasium-mjx                 # jax, mujoco and mujoco-mjx only
pip install "gymnasium-mjx[playground]"   # and the mujoco_playground adapter
pip install "gymnasium-mjx[warp]"         # and MuJoCo Warp, on an NVIDIA GPU

Python 3.12 or newer, MuJoCo 3.7 to 3.15 (3.14 or newer for Ant and the Humanoids on MuJoCo Warp).

Use it as Gymnasium

The same task ids and keyword arguments as gymnasium.make. The state is passed in and returned, as JAX needs:

# doc: skip (two columns side by side)
# Gymnasium                                   # gymnasium-mjx
env = gymnasium.make("Hopper-v5")             task = gymnasium_mjx.make("Hopper-v5")
obs, info = env.reset(seed=0)                 state = task.reset(jax.random.key(0))
obs, reward, terminated, truncated, info = \  state = task.step(state, action)
    env.step(action)                          # state.obs, state.reward, state.done

state.done is the termination; the time limit, task.episode_length, is the caller's to apply, as Gymnasium's TimeLimit wrapper does. Many environments at once are a vmap, and the whole step can be jitted:

import jax
import gymnasium_mjx

task = gymnasium_mjx.make("Hopper-v5")
states = jax.vmap(task.reset)(jax.random.split(jax.random.key(0), 4096))
actions = jax.numpy.zeros((4096, task.action_size))
states = jax.jit(jax.vmap(task.step))(states, actions)

Tasks

Id Contacts Id Contacts
InvertedPendulum-v5 no Hopper-v5 yes
InvertedDoublePendulum-v5 no Walker2d-v5 yes
Reacher-v5 no Pusher-v5 yes
Swimmer-v5 no Ant-v5 yes
HalfCheetah-v5 yes Humanoid-v5 yes
HumanoidStandup-v5 yes

How close to Gymnasium, and how fast

  • One step from the same state gives Gymnasium's observation, reward and termination to 1e-8 in float64, on every task.
  • The same trained policy, and the same agent trained from scratch, score the same on both sides, on the tasks measured so far (learning curves in docs/checks.md).
  • Where MJX and C MuJoCo still differ, and by how much: docs/differences.md.

All checks, the learning curves, the speed method and the tools: docs/checks.md.

Development

uv sync
uv run pre-commit run --all-files
uv run pytest

Licence

MIT (LICENSE). The model files in src/gymnasium_mjx/assets/ are Gymnasium's, MIT, copyright OpenAI and the Farama Foundation (LICENSES/Gymnasium.txt).

Metadata

Release files for gymnasium-mjx 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gymnasium-mjx 0.3.0
File Size Uploaded Provenance Actions
gymnasium_mjx-0.3.0.tar.gz 27.0 kB Without provenance Details for gymnasium_mjx-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gymnasium-mjx 0.3.0
File Interpreter ABI Platform Actions
gymnasium_mjx-0.3.0-py3-none-any.whl Python 3 none any Details for gymnasium_mjx-0.3.0-py3-none-any.whl

Total release size: 63.1 kB

Release files / gymnasium_mjx-0.3.0.tar.gz

Download URL gymnasium_mjx-0.3.0.tar.gz
Size 27.0 kB
Tags Source
SHA-256 checksum
How to use checksums
72a29fd12b039390cd5ce48f2cd124e47b8f096cdbc12cca8726b47602371b4e
BLAKE2b-256 checksum
How to use checksums
b9d63bda7dbcf3844c569e9ed12fa1772c2db778c3237c0fdf00e914c1c910fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / gymnasium_mjx-0.3.0-py3-none-any.whl

Download URL gymnasium_mjx-0.3.0-py3-none-any.whl
Size 36.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ae72eac0ecb6d1c5de454b53ba4de750db88ac840f03ce71e9af26655da74c5f
BLAKE2b-256 checksum
How to use checksums
abda09653f8931afa669b0ec837f40ef431ea67a99f226d1413498e163a0b1f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for gymnasium-mjx 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page