---
title: "Kevin Zakka's mjbatch Runs 4,096 MuJoCo Worlds on CPU Threads at Once"
subtitle: "Kevin Zakka's new library steps thousands of MuJoCo simulations in parallel on a single CPU, unlocking RL and MPC workloads without a GPU."
url: "https://alphasignal.ai/news/kevin-zakka-s-mjbatch-runs-4-096-mujoco-worlds-on-cpu-threads-at-once"
author: "AlphaSignal Newsroom"
author_url: "https://alphasignal.ai/editorial-team"
company: "AlphaSignal"
company_url: "https://alphasignal.ai/company/alphasignal"
published: "2026-09-14T00:55:56.000Z"
updated: "2026-09-16T07:59:32.745Z"
type: "Repo"
topics:
  - "Robotics"
  - "Open Source"
subtopics:
  - "Vla Models"
  - "Manipulation"
  - "Humanoid"
upvotes: 524
source_url: "https://github.com/kevinzakka/mjbatch"
comments: 0
truncated: true
---

# Kevin Zakka's mjbatch Runs 4,096 MuJoCo Worlds on CPU Threads at Once

> Kevin Zakka's new library steps thousands of MuJoCo simulations in parallel on a single CPU, unlocking RL and MPC workloads without a GPU.

Kevin Zakka has released [mjbatch](https://github.com/kevinzakka/mjbatch), an Apache-2.0 Python library that batches independent MuJoCo simulations across a C++ CPU thread pool. It accepts a standard `MjModel`, exposes batched state and control arrays as NumPy views, and advances thousands of worlds with one synchronous call. Robotics developers can run reinforcement learning, model predictive control, system identification, and design searches on multicore CPUs while retaining MuJoCo’s native engine.

Many robotics algorithms evaluate the same model from hundreds or thousands of states. A Python loop adds interpreter overhead to every simulation step, while accelerator stacks such as MJX move the workload into JAX and typically involve device arrays, tracing, and compilation. mjbatch keeps the computation on the host CPU and moves the loop into native code.

## One call replaces the Python loop

A `Batch` starts with an `MjModel` and a simulation count. The library creates the corresponding simulation state, dispatches each step through its thread pool, and releases Python’s global interpreter lock during native execution. The `step()` call remains synchronous, so the caller resumes after every world has finished; releasing the lock removes interpreter serialization from the native work and allows other Python threads to run.

| API                      | Purpose                              | Developer detail                                                            |
| ------------------------ | ------------------------------------ | --------------------------------------------------------------------------- |
| Batch(model, num\_sims)  | Creates the simulation batch         | Uses a regular MuJoCo model as the template                                 |
| bind("qpos")             | Exposes a batched data field         | Returns a live NumPy view that can be read or updated in place              |
| expand("geom\_friction") | Exposes a model field per simulation | Supports domain randomization and physical parameter searches               |
| set\_const()             | Recomputes derived model constants   | Required after changing parameters that MuJoCo uses to derive cached values |
| step()                   | Advances every world                 | Dispatches the batch through the C++ thread pool                            |

The live views avoid copying state through a separate Python container. Assigning to `ctrl` updates the controls consumed by the next step, while reading `qpos` returns the current positions for every environment.

_Preview only. Full text requires an AlphaSignal Pro account._

## Sources

- [kevinzakka/mjbatch](https://github.com/kevinzakka/mjbatch)
- [Kevin Zakka on X announcing mjbatch](https://twitter.com/kevin_zakka/status/2097893656414044388)
- [MuJoCo MJX documentation](https://mujoco.readthedocs.io/en/stable/mjx.html)
