Skip to main content

mjbatch

Build PyPI version

mjbatch is a Python library for running thousands of MuJoCo simulations in parallel on CPU.

Features include:

  • C++ thread pool execution, with the GIL released;
  • Live array access to simulation state and controls across the batch, with bind for MjData fields;
  • Per-simulation model parameters, with expand for MjModel fields and set_const to recompute derived constants.
  • Batched queries beyond stepping: site Jacobians with jac_site and heightfield sampling with sample_hfield (world/yaw grid alignment); query ops return caller-allocated results without refreshing the bound views.
  • Per-substep control from Python with step(..., callback=...).
  • Optional per-worker CPU pinning on Linux, with cpu_ids binding pool worker i to cpu_ids[i].

For example:

import mujoco, numpy as np
from mjbatch import Batch

model = mujoco.MjModel.from_xml_path("scene.xml")
batch = Batch(model, num_sims=4096)  # threads default to every logical CPU
qpos, ctrl = batch.bind("qpos"), batch.bind("ctrl")
batch.expand("geom_friction")[:, :, 0] = np.random.uniform(0.4, 1.2, (4096, 1))
for _ in range(1000):
  ctrl[:] = policy(qpos)             # your controller, all 4096 at once
  batch.step()                       # step them in parallel; qpos updates in place

sample_hfield samples a shared heightfield at XY offsets around a body origin, returning the world z of the sampled surface. alignment="yaw" rotates the sampling grid by the frame body's yaw about world z, so a per-sim geom_quat rotates each simulation's scan pattern.

Examples

We showcase a range of applications built using mjbatch: RL, MPC, SysID, and hardware co-design. Each example is a self-contained, performant implementation. For instance, the Go1 RL controller learns to walk in under a minute on a five-year-old M1 laptop.

cart-pole swing-up cart-pole MPC
A two-pole cart swung upright with iLQR A cart-pole swing-up controller using predictive sampling
G1 backflip Go1 joystick
A G1 humanoid tracking a reference backflip with receding-horizon iLQR A Go1 quadruped joystick controller trained with PPO
throwing arm co-design Rizon inertia identification
CEM jointly optimizes a robot arm's proportions, gears, and controls Damped Gauss–Newton fits a Rizon arm's inertial parameters to synthetic motion data

Run with uv run examples/<file>.py; some need uv sync --group examples. The ones that open a window need a display; --headless runs the solver without one.

License

Apache-2.0.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mjbatch_uni-0.1.0.tar.gz (29.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

mjbatch_uni-0.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (174.7 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

mjbatch_uni-0.1.0-cp313-cp313-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (163.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.26+ ARM64manylinux: glibc 2.28+ ARM64

mjbatch_uni-0.1.0-cp313-cp313-macosx_11_0_arm64.whl (139.3 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

mjbatch_uni-0.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (174.7 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

mjbatch_uni-0.1.0-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (163.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.26+ ARM64manylinux: glibc 2.28+ ARM64

mjbatch_uni-0.1.0-cp312-cp312-macosx_11_0_arm64.whl (139.2 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

mjbatch_uni-0.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (175.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

mjbatch_uni-0.1.0-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (164.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.26+ ARM64manylinux: glibc 2.28+ ARM64

mjbatch_uni-0.1.0-cp311-cp311-macosx_11_0_arm64.whl (140.0 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

mjbatch_uni-0.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (175.3 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

mjbatch_uni-0.1.0-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (165.0 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.26+ ARM64manylinux: glibc 2.28+ ARM64

mjbatch_uni-0.1.0-cp310-cp310-macosx_11_0_arm64.whl (140.4 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file mjbatch_uni-0.1.0.tar.gz.

File metadata

  • Download URL: mjbatch_uni-0.1.0.tar.gz
  • Upload date:
  • Size: 29.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for mjbatch_uni-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e2856c55cb6179d256360aa56c76c53207cfaf6dee5ba6130bd83fd9b0778a6d
MD5 c3770cfc0c7cc2bf3fb5d73accd37a5c
BLAKE2b-256 bd5f284d7e603033b977b825cbb73282f9233d071a4b43da1ef98335fae610db

See more details on using hashes here.

Provenance

The following attestation bundles were made for mjbatch_uni-0.1.0.tar.gz:

Publisher: ci.yml on unilabsim/mjbatch_uni

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mjbatch_uni-0.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mjbatch_uni-0.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 838e207355095053f70d571803de2b7958a95cafed9e7df19c6aa2cbf3ef135a
MD5 3bfac349ec5770bb669a7fc9b1f399a8
BLAKE2b-256 67dad5a2d73db2a21d884615a62c169733c0ce7ec24a3633515bd8a5ebb95ab9

See more details on using hashes here.

Provenance

The following attestation bundles were made for mjbatch_uni-0.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: ci.yml on unilabsim/mjbatch_uni

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mjbatch_uni-0.1.0-cp313-cp313-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for mjbatch_uni-0.1.0-cp313-cp313-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d6cb335cd3c745228c33d372b6e95115d9fe68249ebb8dc09fbc78de000e1a27
MD5 fb2e534d7ad33181198a15567bc44671
BLAKE2b-256 ee1a4d456c39d58b581df6b157f3f2df59cd9a5a0a876cda7f0765d152c34bc2

See more details on using hashes here.

Provenance

The following attestation bundles were made for mjbatch_uni-0.1.0-cp313-cp313-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl:

Publisher: ci.yml on unilabsim/mjbatch_uni

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mjbatch_uni-0.1.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mjbatch_uni-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 87296ee8012d4435e1652d80e4679d5196ecd196c0ed05bb23601490bb2e1428
MD5 233d2d4c0146d86f07681dd9d66ff1f0
BLAKE2b-256 4b9513657cf8311dbb21d78ca219c07675899a45fa27f5eedfb6e56711fb5452

See more details on using hashes here.

Provenance

The following attestation bundles were made for mjbatch_uni-0.1.0-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: ci.yml on unilabsim/mjbatch_uni

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mjbatch_uni-0.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mjbatch_uni-0.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 25fbf20cbb9e72bc98e37c1a65ae621d9cea5904d3e3a8e8aad5bbcd59faa1ed
MD5 5976b0a5b3e48fd697c4b14c5a1ece40
BLAKE2b-256 9b7f9b5d8f6c51abb8a3f02d9a1f4bd2d49e7b74a238921840cf9ab747b8372f

See more details on using hashes here.

Provenance

The following attestation bundles were made for mjbatch_uni-0.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: ci.yml on unilabsim/mjbatch_uni

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mjbatch_uni-0.1.0-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for mjbatch_uni-0.1.0-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e3c65e2a0936bb210f4b6c5229512490e07ac8e7be42cc14e464b5d4cef93de2
MD5 058b7999d64f1671ccf4bd30a3353a62
BLAKE2b-256 32ee8308873ed1a1697a44454ebe9f03a3b2c962aa0d1786ed5c79939a5a7d57

See more details on using hashes here.

Provenance

The following attestation bundles were made for mjbatch_uni-0.1.0-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl:

Publisher: ci.yml on unilabsim/mjbatch_uni

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mjbatch_uni-0.1.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mjbatch_uni-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 23bb9f101fcb02c04482eea4285fedccea19450550902151c76a7739491cf54c
MD5 cbf748f4930d4466d2959a5d55bd0141
BLAKE2b-256 76d15f46d25aa730bc2dbf1e90a5cfc9c0744d19a4be766ff79988db9bf0e518

See more details on using hashes here.

Provenance

The following attestation bundles were made for mjbatch_uni-0.1.0-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: ci.yml on unilabsim/mjbatch_uni

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mjbatch_uni-0.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mjbatch_uni-0.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0476b1dd333d95118123c9b4c05d6e42dc652cb8c69fc5b0960aed1dbf0ec09e
MD5 ef3d526ea5a4d6cabb24f306abf8828c
BLAKE2b-256 af129ca93e335f9a6f7d0e62e8eff24b8771d73ed4c38273c8950856133d3ddf

See more details on using hashes here.

Provenance

The following attestation bundles were made for mjbatch_uni-0.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: ci.yml on unilabsim/mjbatch_uni

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mjbatch_uni-0.1.0-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for mjbatch_uni-0.1.0-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 cb2fd277ea5f9c045d263c79425ea92fbce0bc7b5d79e648dfd4ea18d1501282
MD5 1e2652d073be90c574fa65f17f7856f1
BLAKE2b-256 fb5911885b99ef0797e1a286a5edd5017fec074a6a145c6dd8d59599cc6bda95

See more details on using hashes here.

Provenance

The following attestation bundles were made for mjbatch_uni-0.1.0-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl:

Publisher: ci.yml on unilabsim/mjbatch_uni

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mjbatch_uni-0.1.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mjbatch_uni-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b4b02e5c3829225e697207719b22061004c255f332f724cdc220fc2c633f233e
MD5 3a39cee86d4151984534ac9f435e0021
BLAKE2b-256 4da5734641dfb1d442b3c53c9024b050be59652a00d6ac2d830502350fcf6233

See more details on using hashes here.

Provenance

The following attestation bundles were made for mjbatch_uni-0.1.0-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: ci.yml on unilabsim/mjbatch_uni

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mjbatch_uni-0.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mjbatch_uni-0.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bf8ab61861d59d4e537ddca47c1e5df1fc5e80c5a81d753f7d7608a528a99dfb
MD5 175f73916a37012cb16dd80554db34c5
BLAKE2b-256 12b8f04152b71065d6ba14363f8e66bd2f0ade429af058b19dc75ae691dd8c58

See more details on using hashes here.

Provenance

The following attestation bundles were made for mjbatch_uni-0.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: ci.yml on unilabsim/mjbatch_uni

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mjbatch_uni-0.1.0-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for mjbatch_uni-0.1.0-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 07310303cc9a4f67ba64965325a4456783556586aa69a0f18756ae686cdf8430
MD5 e435216e615959a032a9a4710b271329
BLAKE2b-256 cc181ec66faa8c51e72c84696c7432cd17ab45c32834e9fea580488d10c202a2

See more details on using hashes here.

Provenance

The following attestation bundles were made for mjbatch_uni-0.1.0-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl:

Publisher: ci.yml on unilabsim/mjbatch_uni

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mjbatch_uni-0.1.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mjbatch_uni-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 40f787b39f3a4c4214bc41d6928fa6d3ea7737d012dd72e64c39c533fdaaf197
MD5 cfce5d9e53b147ffd1598d480016e5f9
BLAKE2b-256 7fb5d737ce697d40763b32d4c3ddf7a2188a2f1abd6bc2a8fb2396006048d6f9

See more details on using hashes here.

Provenance

The following attestation bundles were made for mjbatch_uni-0.1.0-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: ci.yml on unilabsim/mjbatch_uni

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.2.1

13 files

0.2.0

13 files

This release

0.1.0 This release

13 files

0.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page