arXiv:2610.36075cs.LGOct 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2610.36075

Jaxnasium: Embracing PyTrees For Any-Agent, Cross-Suite Reinforcement Learning

Koen Ponse, Aske Plaat, Thomas M. Moerland

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ABSTRACT

Hardware-accelerated reinforcement learning in JAX has gained rapid popularity in recent years and has proven to be a successful method of scaling online reinforcement learning. The resulting ecosystem, however, is fragmented: environment suites define their own interfaces, and algorithm implementations are typically written for a single suite, a single type of space, and either JAX-native or host-based environments. Here we present Jaxnasium, a library for JAX-based reinforcement learning, aiming to make the field more accessible. Jaxnasium represents observation and action spaces as PyTrees, and uses this structure to build networks and support multi-agent processing. Through this, its near-single-file implementations run on discrete, continuous, image, and composite spaces, as well as in multi-agent environments, without any changes to the algorithm code. The same files serve as readable, research-friendly algorithms, as well as importable algorithms for more applied workloads. Through a minimal Gymnasium-style interface and wrappers for 11 suites, over 300 environments are available on which a small PPO implementation with default hyperparameters is able to run. Additionally, through a simple wrapper, we can run Gymnasium and EnvPool environments with the same algorithm and training loop, with no performance loss compared to architectures specifically built for training JAX algorithms on host-based environments. Jaxnasium further provides tools for multi-seed evaluation, hyperparameter sweeps, and project scaffolding. Jaxnasium is open-sourced at https://github.com/ponseko/jaxnasium.

1 INTRODUCTION

Running the entire reinforcement learning loop on the accelerator has reshaped what is possible for many researchers. When both the environment and the agent are written in JAX (Bradbury et al., 2018), rollouts and updates can together be compiled and vectorized without host (CPU) round-trips, which can yield speed-ups of several orders of magnitude (Hessel et al., 2021; Lu et al., 2022). A broad ecosystem of JAX-native environments has emerged, including Gymnax (Lange, 2022), Brax (Freeman et al., 2021), Jumanji (Bonnet et al., 2024), Pgx (Koyamada et al., 2023), JaxMARL (Rutherford et al., 2024), XLand-MiniGrid (Nikulin et al., 2023), and Craftax (Matthews et al., 2024), each with its own interface and conventions for state, time steps and spaces. This expansion added to the already large landscape of reinforcement learning.

Algorithm implementations, however, have not kept pace with this breadth. They tend to be written for a specific environment suite and/or space type. As a result, even within the same library, an algorithm is often re-implemented for discrete and continuous actions, for image and vector observations, for single- and multi-agent settings. Libraries serve different users in different ways: research-oriented libraries provide readable single- or near-single-file implementations that are easy to modify (Huang et al., 2022; Lu et al., 2022), while production-oriented libraries (Raffin et al., 2021; Liang et al., 2018) offer a single importable algorithm that handles many environments, at the cost of spreading the implementation over many interacting and inherited components, making them less accessible for researchers who want to adapt the underlying algorithms.

A new divide now separates JAX-native environments from the many environments that still run on the host CPU, such as those in Gymnasium (Towers et al., 2025) and EnvPool (Weng et al., 2022). For the former, the entire training loop can run on the accelerator; for the latter, the environment steps on the host and only the network runs on the accelerator. These two settings call for different training architectures (originally proposed as Anakin and Sebulba in Hessel et al. (2021)), and different implementations are then again written for each of them. As a result, the starting point for researchers is typically an implementation that supports a subset of tasks or is difficult to modify.

We introduce Jaxnasium, a lightweight RL library built on Equinox (Kidger & Garcia, 2021), with the aim of making JAX-based RL more accessible. At its core are near-single-file algorithm implementations that operates many environments. They build on PyTrees, JAX's notion of arbitrarily nested structures (including structures built with standard Python containers such as dictionaries, tuples and lists). In Jaxnasium, observation and action spaces are PyTrees of primitive spaces, and each algorithm constructs its networks from the structure of these spaces without any complicated machinery. A single implementation trains on discrete, continuous, image and composite spaces alike, and even seamlessly extends to multi-agent settings, where each agent simply has its own entry in the space PyTree. Because JAX provides simple operations on PyTrees, this generally requires little special-case code, and our implementations remain readable and modifiable for algorithm researchers.

Building on Equinox further lets us write algorithms as classes while respecting JAX's functional requirements, giving practitioners the familiar interface of libraries such as Stable-Baselines3. To let these algorithms run on many environments, Jaxnasium defines a minimal, Gymnasium-style environment interface and currently wraps over 300 environments from different domains into it, on which a single small PPO implementation can operate (Figure 1). Although the algorithms target end-to-end JAX training for maximum performance, host-based environments (like Gymnasium and EnvPool) run within the same compiled training loop through a wrapper rather than a separate implementation, matching or exceeding the throughput of implementations built specifically for host-based environments (Section 5).

Concretely, our contributions are:

• Space-agnostic algorithms. Near-single-file implementations whose networks are constructed from the space PyTrees, so that each algorithm supports arbitrary observation and action spaces and extends to multi-agent settings without code changes. The same code serves as a readable reference for researchers and as an importable, Stable-Baselines-style algorithm for practitioners.

• One implementation for JAX-native and host environments. Gymnasium and EnvPool environments run inside the same compiled training loop as JAX-native ones. We show that this loses no throughput compared to implementations dedicated to either setting.

• A common environment interface. A minimal, Gymnasium-style functional interface with PyTree spaces, and wrappers that bring 11 existing JAX environment suites under it.

• Research tooling. A command-line interface that scaffolds new projects, and utilities for multi-seed evaluation and hyperparameter sweeps (grid, random, Sobol and one-at-a-time), and a small tree package for convenience operations over PyTrees.

References (52)