NAVIX: Scaling MiniGrid Environments with JAX

Eduardo Pignatelli, Jarek Liesen, Robert Tjarko Lange, Chris Lu, Pablo Samuel Castro, Laura Toni

TL;DR

NAVIX is a high-performance re-implementation of the popular MiniGrid reinforcement learning (RL) suite using JAX. By migrating environment simulations from the CPU to accelerators like GPUs and TPUs, it achieves throughput speedups of over 200,000x, effectively turning week-long experiments into 15-minute iterations.

What Problem Does This Paper Address?

Deep Reinforcement Learning is notoriously sample-inefficient, often requiring millions or billions of interactions to learn effective policies. While neural network training has moved to GPUs, the environment simulations themselves—like the widely used MiniGrid—typically remain stuck on the CPU.

This creates a massive "CPU-bound" bottleneck: the GPU sits idle waiting for the CPU to compute the next state, and scaling to thousands of parallel agents requires complex, overhead-heavy distributed systems. The authors address this by re-building MiniGrid from the ground up to run natively on hardware accelerators.

Methods

The core of NAVIX is its implementation in JAX, which allows the entire environment logic to be compiled into highly efficient machine code (via XLA) and run in parallel across thousands of GPU cores.

Key technical choices include:

  • Entity-Component-System Model (ECSM): Instead of traditional object-oriented programming, NAVIX uses ECSM. Entities (like players or doors) are composed of data-only components (like position or color), which are then processed by pure functions called "Systems." This functional approach is a perfect fit for JAX’s stateless requirements.
  • Full "Jittability": Every part of the environment—transitions, observations, and rewards—is designed to be compatible with JAX’s jit (Just-In-Time) compilation.
  • Stateful Timesteps: To maintain JAX compatibility, the environment state is encapsulated in a single "timestep" object, allowing for seamless auto-resetting and vectorization without side effects.
Information flow of the ECSM in NAVIX.

Datasets

The authors evaluated NAVIX against the original MiniGrid suite. They implemented and benchmarked 30 different environment configurations, including:

  • Empty: Basic navigation tasks.
  • DoorKey: Tasks requiring object interaction (picking up keys, opening doors).
  • Dynamic-Obstacles: Environments with moving hazards.
  • KeyCorridor & LavaGap: Complex layouts testing exploration and hazard avoidance.

Key Insights and Ideas

  • The Power of vmap: While standard MiniGrid uses Python’s multiprocessing to parallelize environments (which is limited by RAM and CPU cores), NAVIX uses JAX’s native vmap. This allows it to run over 2 million environments in parallel on a single machine.
  • Eliminating the Bottleneck: By keeping both the agent (the neural network) and the environment on the GPU, NAVIX eliminates the costly communication overhead of moving data back and forth between the CPU and GPU.
  • Markovian Rewards by Default: The original MiniGrid uses a non-Markovian reward (it depends on the time step $t$). NAVIX defaults to a Markovian reward (0 everywhere, 1 at the goal) to better align with standard RL theory, though it can reproduce the original behavior if needed.

Key Results

The performance gains are transformative for RL research:

  • Raw Speedup: On average, NAVIX is 45x faster than the original implementation for a single environment.
  • Throughput Explosion: In batch mode, NAVIX achieves a speedup of over 200,000x. Specifically, it can process ~670 million steps per second compared to the original's ~3,100 steps per second.
  • Scalability: The authors successfully trained 2,048 PPO agents in parallel on a single Nvidia A100 GPU.
  • Time Savings: Experiments that previously took an entire week can now be completed in just 15 minutes.
Speedups for five NAVIX environments compared to MiniGrid.

Limitations and Future Work

While NAVIX is a powerful tool, the authors note that porting environments to JAX is non-trivial. JAX imposes strict constraints: no side effects (like printing or global state changes) and limited control flow (standard if statements and for loops often need to be replaced with JAX-specific primitives).

Future work includes:

  • Expanding the suite to include even more complex environments.
  • Leveraging NAVIX for large-scale meta-learning and exploration studies that were previously computationally prohibitive.
  • Providing a "scoreboard" of baseline results for the community to reference, reducing redundant computation.

Summary updated

BibTeX
@misc{pignatelli2024navix,
  author = {Eduardo Pignatelli and Jarek Liesen and Robert Tjarko Lange and Chris Lu and Pablo Samuel Castro and Laura Toni},
  title = {{NAVIX: Scaling MiniGrid Environments with JAX}},
  year = {2024},
  eprint = {2407.19396},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2407.19396},
}
Figure