Skip to main content
QUICK REVIEW

[Paper Review] Pgx: Hardware-Accelerated Parallel Game Simulators for Reinforcement Learning

Sotetsu Koyamada, Shinri Okano|arXiv (Cornell University)|Mar 29, 2023
Artificial Intelligence in GamesComputer Science5 citations
TL;DR

Pgx is a JAX-based suite of hardware-accelerated, parallel game simulators for reinforcement learning, optimized for GPU/TPU acceleration. By leveraging JAX's auto-vectorization and JIT compilation, Pgx achieves 10–100× faster simulation throughput than existing Python-based libraries like OpenSpiel and PettingZoo, enabling rapid training of RL algorithms such as Gumbel AlphaZero and PPO on complex board games including Go, chess, and shogi.

ABSTRACT

We propose Pgx, a suite of board game reinforcement learning (RL) environments written in JAX and optimized for GPU/TPU accelerators. By leveraging JAX's auto-vectorization and parallelization over accelerators, Pgx can efficiently scale to thousands of simultaneous simulations over accelerators. In our experiments on a DGX-A100 workstation, we discovered that Pgx can simulate RL environments 10-100x faster than existing implementations available in Python. Pgx includes RL environments commonly used as benchmarks in RL research, such as backgammon, chess, shogi, and Go. Additionally, Pgx offers miniature game sets and baseline models to facilitate rapid research cycles. We demonstrate the efficient training of the Gumbel AlphaZero algorithm with Pgx environments. Overall, Pgx provides high-performance environment simulators for researchers to accelerate their RL experiments. Pgx is available at http://github.com/sotetsuk/pgx.

Motivation & Objective

  • To address the performance bottleneck in RL research caused by slow, CPU-bound game simulators that hinder large-scale self-play and data collection.
  • To enable high-throughput, parallel simulation of complex board games—especially those with large discrete state spaces—on accelerators like GPUs and TPUs.
  • To eliminate data transfer overhead between CPUs and accelerators by co-locating simulation and learning on the same hardware.
  • To provide a unified, accessible Python API for high-performance game environments that supports rapid prototyping and benchmarking in RL research.
  • To offer standardized, open-sourced environments with built-in baseline models and miniature variants to accelerate research cycles and enable reproducible evaluation.

Proposed method

  • Implementing game simulators in JAX to exploit automatic vectorization and hardware-specific JIT compilation for GPU/TPU execution.
  • Designing environments to support batched, parallel simulation of thousands of game instances using JAX's functional programming paradigm and automatic differentiation.
  • Optimizing state and action representations for efficient memory access and computation on accelerators, minimizing latency and maximizing throughput.
  • Integrating the simulators with standard RL training pipelines by ensuring compatibility with common algorithms like PPO and AlphaZero.
  • Providing miniature versions of games (e.g., 5x5 chess) and pre-trained baseline models to reduce training time and facilitate ablation studies.
  • Open-sourcing the full suite at https://github.com/sotetsuk/pgx to ensure reproducibility and community adoption.
Figure 1: Example games included in Pgx.
Figure 1: Example games included in Pgx.

Experimental results

Research questions

  • RQ1Can JAX-based, hardware-accelerated simulators achieve significantly higher simulation throughput than traditional Python-based game environments?
  • RQ2How does the integration of simulation and learning on the same accelerator (GPU/TPU) impact training efficiency and data transfer costs in RL?
  • RQ3To what extent can Pgx accelerate the training of sample-intensive RL algorithms like AlphaZero and PPO on complex board games?
  • RQ4Can miniature game variants and built-in baseline models effectively reduce the time and effort required for rapid experimentation and evaluation in RL research?
  • RQ5What is the performance gain of Pgx over existing libraries like OpenSpiel and PettingZoo when running on high-end hardware such as the DGX-A100?

Key findings

  • Pgx achieves 10–100× faster simulation throughput compared to existing Python-based libraries like OpenSpiel and PettingZoo on a DGX-A100 workstation.
  • PPO training on MinAtar environments with a batch size of 4096 completed in under a minute per game, with the exception of Seaquest, which took over 80 seconds to train 20M frames.
  • Gumbel AlphaZero training on 9x9 Go, Othello, and other games completed in under 18 hours on a single A4000 GPU, demonstrating efficient scaling with hardware.
  • The use of JAX’s auto-vectorization and JIT compilation enabled efficient parallel execution across thousands of simultaneous game environments without manual threading or data transfer bottlenecks.
  • The inclusion of miniature game environments and pre-trained baseline models significantly reduced the time required for hyperparameter tuning and evaluation in RL experiments.
  • Pgx’s integration with accelerators eliminated CPU-GPU data transfer overhead, resulting in end-to-end training pipelines that are both faster and more scalable.
Figure 2: Basic usage of Pgx. The init function generates the initial state object. The state object has an attribute current player that indicates the agent which acts next. In this case, since we are using a batch size of 1024 for a 2-player game, current player is a binary vector whose size is 10
Figure 2: Basic usage of Pgx. The init function generates the initial state object. The state object has an attribute current player that indicates the agent which acts next. In this case, since we are using a batch size of 1024 for a 2-player game, current player is a binary vector whose size is 10

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.