kevinzakka/mjbatch

A Python library for running thousands of MuJoCo simulations in parallel on CPU

What it solves

mjbatch provides a way to run thousands of MuJoCo physics simulations in parallel on a CPU. This is essential for tasks like Reinforcement Learning (RL), Model Predictive Control (MPC), and system identification, where running many simulations concurrently significantly speeds up training and optimization.

How it works

The library uses a C++ thread pool to execute simulations in parallel, bypassing the Python Global Interpreter Lock (GIL). It allows users to bind simulation state variables (like positions or controls) directly to NumPy arrays, enabling efficient, bulk updates across the entire batch of simulations. It also provides tools to expand model parameters so that each simulation in the batch can have unique physical properties.

Who it’s for

This tool is designed for researchers and engineers working in robotics, control theory, and machine learning who need to perform large-scale physics-based simulations efficiently on standard hardware.

Highlights

  • Parallel execution of thousands of simulations on CPU.
  • Direct, live memory access to simulation states and controls via NumPy.
  • Efficient handling of per-simulation model parameters.
  • High-performance implementation that inspired native batching features now integrated into the official MuJoCo library.

Related

  • Dispatch
  • Dispatch
  • Project
  • Project
  • Project