mujoco-accelerated
Skill15k starsChanged 3 months agoApache-2.0View on GitHub
GPU and TPU batch simulation, MJX (JAX), MJWarp (CUDA), parallel rollouts (jax.vmap), trajectory scan (jax.lax.scan), differentiability, device memory (put_model, put_data), njmax contact pre-allocation, float32 precision, XLA compilation caching. Use for RL environment batches, GPU rollouts, differentiable physics. Do NOT use for CPU simulation, noslip/PGS solvers (mujoco-python), rendering (mujoco-rendering), or GUI (mujoco-gui).
Trending
Quiet since August.thin dataabout the whole repository
Who's talking about google-deepmind/mujoco
- A Hacker News story“MuJoCo – Advanced Physics Simulation”Hacker News · Apr 19, 2026 · 116 points
- openai/mujoco-py“Cannot change site position programmatically when pos is set to zero in XML”GitHub · Mar 7, 2024 · 7 reactions
- dtcxzyw/llvm-opt-benchmark“Wishlist for new benchmarks”GitHub · Jan 17, 2024 · 5 reactions
- astral-sh/uv“MuJoCo `mjpython` fails with uvx”GitHub · Nov 8, 2024 · 4 reactions
- jrouwe/JoltPhysics“[Feature Request] Soft-soft collisions and self-collisions”GitHub · Dec 12, 2023 · 4 reactions
The biggest 5 of 13 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 13
Talked about on GitHub, Hacker News and Bluesky (13 times).
On GitHub · 10
- Mar 7, 2024Cannot change site position programmatically when pos is set to zero in XML — openai/mujoco-py7 reactions
- Jan 17, 2024Wishlist for new benchmarks — dtcxzyw/llvm-opt-benchmarksays it tested it5 reactions · 15 comments
- Nov 8, 2024MuJoCo `mjpython` fails with uvx — astral-sh/uv4 reactions · 7 comments
- Dec 12, 2023[Feature Request] Soft-soft collisions and self-collisions — jrouwe/JoltPhysics4 reactions · 5 comments
- Jul 22, 2026passive adhesion — google-deepmind/mujoco_warp3 reactions · 1 comment
5 more on GitHub
- Aug 26, 2026Fix JAX FFI VMA propagation — NVIDIA/warp2 reactions · 6 comments
- Oct 31, 20251st party WASM bindings are now available for Alpha testing — zalo/mujoco_wasmsays it tested it2 reactions · 21 comments
- Aug 7, 2025reset_data — google-deepmind/mujoco_warp2 reactions · 1 comment
- Dec 27, 2025fix: CGL: try to init pixel format without explicit profile before falling back to profile selection — rust-windowing/glutin1 reaction · 3 comments
- Nov 8, 2024Fix glfw name when using system installed version — google-deepmind/mujoco_mpc1 reaction · 1 comment
On Hacker News · 2
- Apr 19, 2026MuJoCo – Advanced Physics Simulation116 points · 24 comments
- Oct 18, 2023MuJoCo 31 point
On Bluesky · 1
- Apr 22, 2026MuJoCo – Advanced Physics Simulation Discussion — @hn100.bsky.social1 likes and repost
In this repository5 other files it gives its agents.
- mujoco-guiSkill
- mujoco-pythonSkill
- mujoco-renderingSkill
- mujoco-spec-editingSkill
- mujoco-studioSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 174
PGS solver: Not available on GPU backends.
- Distinctive: line 187
Compilation caching: Avoid long recompilations on startup by enabling persistent XLA caching:
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
MuJoCo Accelerated: MJX & MJWarp GPU Backends
[!TIP]
Related skills:
- mujoco-python — CPU physics simulation, kinematics, and full solver suite.
- mujoco-studio — Interactive simulation and Studio viewer plugins.
[!IMPORTANT]
MJX and MJWarp are Python-only GPU acceleration backends. Standard CPU simulation runs in full
float64viaimport mujoco.
1. Backend Comparison: C++ vs MJX vs MJWarp
| Feature | C++ Engine (Default) | MJX (JAX) | MJWarp (CUDA) |
| Import | import mujoco | from mujoco import mjx | import mujoco_warp as mjw |
| Hardware | CPU | GPU / TPU | NVIDIA GPU |
| Precision | float64 | float32 | float32 |
| Differentiable | ❌ No | ✅ Yes (JAX gradients) | ❌ No |
| Batch Stepping | ❌ Serial / multi-threaded | ✅ jax.vmap | ✅ Native CUDA batches |
| Solvers | Newton, CG, PGS, noslip | Newton, CG | Newton, CG |
| Constraint Islands | ✅ Yes | ❌ No | ❌ No |
| Plugins | All engine plugins | ❌ No | SDF plugins only |
2. MJX Workflow (JAX)
MJX translates MuJoCo data structures into immutable JAX pytrees that execute natively on GPUs and TPUs.
import mujoco
from mujoco import mjx
# 1. Load CPU model and data
model = mujoco.MjModel.from_xml_path('scene.xml')
data = mujoco.MjData(model)
# 2. Transfer to device (GPU/TPU)
# ALWAYS specify njmax when contacts are present
mjx_model = mjx.put_model(model)
mjx_data = mjx.put_data(model, data, njmax=500)
# 3. Step on device (functional paradigm returns new data)
mjx_data = mjx.step(mjx_model, mjx_data)
# 4. Copy data back to host CPU
mjx.get_data_into(data, model, mjx_data)
print(data.body('torso').xpos)3. High-Throughput Rollouts: jax.vmap and jax.lax.scan
Parallel Batches (jax.vmap)
import jax
from mujoco import mjx
# Vectorize step over batch dimension (model unbatched, data batched)
batched_step = jax.vmap(mjx.step, in_axes=(None, 0))
# JIT-compile for maximum device throughput
batched_step_jit = jax.jit(batched_step)
batch_data = batched_step_jit(mjx_model, batch_data)Multi-Step Trajectory Rollouts (jax.lax.scan)
For RL environment steps, avoid Python loops by scanning across steps:
def rollout(model: mjx.Model, init_data: mjx.Data, ctrl_sequence: jax.Array):
def step_fn(d, ctrl):
d = d.replace(ctrl=ctrl)
d = mjx.step(model, d)
return d, (d.qpos, d.sensordata)
final_data, trajectory = jax.lax.scan(step_fn, init_data, ctrl_sequence)
return final_data, trajectory4. Contact Pre-allocation (The njmax Gotcha)
[!CAUTION]
mjx.put_data()pre-allocates GPU memory for contacts based ondata.ncon. On a newly initializedMjData,data.nconis 0. Ifnjmaxis omitted, the device contact buffer size is 0 and contacts will be silently ignored.
Always provide njmax:
# ✅ RIGHT — allocates capacity for up to 500 contacts
mjx_data = mjx.put_data(model, data, njmax=500)A standard rule of thumb is 2× to 5× the expected peak number of contacts.
5. MJX Named Access & bind()
MJX provides declarative named access over JAX arrays via bind():
spec = mujoco.MjSpec.from_file('model.xml')
model = spec.compile()
data = mujoco.MjData(model)
mx = mjx.put_model(model)
dx = mjx.put_data(model, data, njmax=500)
# Read body positions from JAX device arrays
torso_pos = dx.bind(mx, spec.body('torso')).xpos
# Functional update of control inputs
dx = dx.bind(mx, spec.actuators).set('ctrl', [1.0, 0.5])6. MJWarp Guide (NVIDIA CUDA)
MJWarp (mujoco_warp) provides a CUDA-native simulator optimized for maximum
batch throughput on NVIDIA hardware without JAX:
import mujoco
import mujoco_warp as mjw
model = mujoco.MjModel.from_xml_path('scene.xml')
batch_size = 4096
# Transfer batch to CUDA
mjw_model = mjw.put_model(model)
mjw_data = mjw.put_data(model, batch_size)
# Advance all 4096 environments in parallel
mjw.step(mjw_model, mjw_data)
# Extract states directly into GPU tensors or NumPy arrays
qpos_tensor = mjw_data.qpos7. Supported Geometries & Feature Gaps
Collision Geom Support Matrix
| Geometry Pair | MJX (JAX) | MJWarp (CUDA) |
| Sphere - Sphere | ✅ Supported | ✅ Supported |
| Sphere - Plane | ✅ Supported | ✅ Supported |
| Capsule - Capsule | ✅ Supported | ✅ Supported |
| Capsule - Plane | ✅ Supported | ✅ Supported |
| Box - Plane | ✅ Supported | ✅ Supported |
| Mesh - Primitive | ✅ Convex meshes | ✅ Convex meshes |
| Mesh - Mesh | ⚠️ Performance sensitive | ✅ Warp accelerated |
Solvers Not Available on GPU
- noslip solver: Available only in C++ engine. If exact frictional stick conditions without sliding drift are required, use CPU.
- PGS solver: Not available on GPU backends.
- Constraint Islands: Handled monolithically on GPU.
8. Common Gotchas & Numerical Stability
- Float32 precision: GPU backends run in single precision (
float32). Stiff systems may experience numerical drift or NaN errors. Counteract this by increasingmodel.opt.iterationsor decreasingmodel.opt.timestep. - Immutability in MJX:
mjx.Datais a JAX pytree. In-place assignments fail; use.replace():mjx_data = mjx_data.replace(qpos=new_qpos) - Compilation caching: Avoid long recompilations on startup by enabling
persistent XLA caching:
import jax jax.config.update('jax_compilation_cache_dir', '/tmp/jax_cache')
9. Key References
Documentation
- MJX Guide
- Python Bindings Reference
Source Code Examples
- MJX Support Tests
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

