Skip to main content

MuJoCo MJX Origami Engine

Latest Release CI Python MuJoCo MJX JAX NVIDIA Warp
NumPy Shapely pytest JSON Schema
Last Commit Issues Stars License



This project is a dual-backend MuJoCo MJX origami folding simulator — a migration of origami-engine from the classic MuJoCo C++ runtime to MJX, with two interchangeable backends in one package. The crease-pattern parsing, geometry reconstruction, and MJCF model generation are shared between backends; only the simulation execution differs.

What this project does

  • Keeps the same crease → face → MJCF pipeline as the classic engine (p1, p2, angle data in, MuJoCo model out)
  • Runs the simulation on MJX-JAX (mujoco.mjx on JAX/XLA) or MJX-Warp (mujoco.warp on NVIDIA Warp) behind a single OrigamiEngine facade
  • Supports differentiable simulation and jax.jit / jax.vmap / jax.lax.scan on the JAX backend (CPU, NVIDIA GPU, or TPU)
  • Supports high-throughput batched population evaluation on the Warp backend (NVIDIA CUDA GPU, e.g. Colab T4)
  • Measures the forward displacement of the paper as a fitness signal, for single genomes or whole populations
  • Auto-selects a backend with backend="auto" (warp if a CUDA GPU is available, otherwise jax)

Backends

Backend Flag Engine Hardware Best for
MJX-JAX backend="jax" mujoco.mjx on JAX/XLA CPU (local dev), NVIDIA GPU, TPU (Colab) Differentiable simulation, jax.jit / jax.vmap / jax.lax.scan, CPU testing
MJX-Warp backend="warp" mujoco.warp on NVIDIA Warp NVIDIA CUDA GPU only (Colab T4) High-throughput batched population evaluation

Simulation Output

Below is the physical rendering of the simulation output, demonstrating how the paper layout reacts to active hinge joint torques and support table vibrations:

Reference crease pattern

Reference Miura-ori 4x4 | 16 faces

Reference Crease Pattern
The default Miura-ori crease pattern shared by both backends, tiling a square sheet into 16 polygonal faces.

Crease Pattern JSON Schema — validates the structure of crease input files.
reference_miura_4x4.json — the reference crease pattern data (p1, p2, and angle per crease).

Mountain folds are negative angles (creasing "up"), Valley folds are positive angles (creasing "down").
Vibrating Table: Amplitude & Frequency Fold Crease Video Preview
Lower amplitude & frequency Partial / standard
High amplitude & frequency Full
Higher amplitude & frequency Full

This repository is structured as a library for crease pattern simulation and analysis on MJX. For full documentation, see the dedicated files below.

Quick start

Install from PyPI

# Core (geometry, patterns, XML generation — no GPU needed)
pip install origami-engine-mjx

# + MJX-JAX backend (CPU works out of the box)
pip install 'origami-engine-mjx[jax]'

# + MJX-Warp backend (requires NVIDIA CUDA GPU)
pip install 'origami-engine-mjx[warp]'

# Everything
pip install 'origami-engine-mjx[all]'

Run a simulation

from origami_engine_mjx import OrigamiEngine, load_default_creases

# CPU (local dev) — MJX-JAX
engine = OrigamiEngine(backend="jax")
creases = load_default_creases()

# Single simulation -> forward displacement (m)
score = engine.evaluate(creases, duration=2.0)
print(f"forward displacement: {score:.4f} m")

# Batch population evaluation
population = [creases, creases, creases]  # replace with your genomes
result = engine.evaluate_population(population, duration=2.0)
print(result.scores)

On Google Colab with an NVIDIA T4:

engine = OrigamiEngine(backend="warp")  # CUDA GPU via MuJoCo Warp
result = engine.evaluate_population(population, duration=8.0, batch_size=128)

Validate (source installation)

pip install -e '.[dev,jax]'
pytest tests_mjx -q              # fast tests (no long sims)
pytest tests_mjx -q -m slow      # includes short MJX-CPU simulations

Performance notes

  • MJX-JAX on CPU is slow for mesh-contact models: the 16-face reference Miura model costs ~70 s/step on CPU (mesh–mesh collision in XLA). Tiny models run at ~1.4 s/step. Use CPU only for correctness tests with short durations; use GPU for real workloads.
  • JIT compilation of mjx.step is expensive for this model; the JAX backend runs eager by default (jit=False).
  • On a Colab T4 GPU, both backends should be dramatically faster — see examples/colab_gpu_validation.py and the benchmark in COLAB_GPU.md.

📖 Documentation

For in-depth information, see the dedicated documentation files:

All documentation lives in docs/.

Examples

Script Demonstrates
examples/01_evaluate_cpu_jax.py Single sim + population on CPU (MJX-JAX)
examples/02_evaluate_warp_gpu.py MJX-Warp on NVIDIA GPU
examples/03_batch_population.py Batch population evaluation with configurable batch size
examples/colab_gpu_validation.py Full GPU validation + benchmark script for Colab T4

Core modules (brief)

  • origami_engine_mjx/constants.py — physical / solver constants (shared)
  • origami_engine_mjx/types.py — Crease, Pattern, SimulationResult, PopulationResult
  • origami_engine_mjx/geometry.py — crease graph → faces → spanning tree (shared, Shapely)
  • origami_engine_mjx/model.py — generate_xml(): Pattern → MJCF XML (shared, no MuJoCo needed)
  • origami_engine_mjx/serialization.py — JSON crease I/O (shared)
  • origami_engine_mjx/patterns.py — reference Miura patterns (shared)
  • origami_engine_mjx/plotting.py — crease-pattern plots (shared)
  • origami_engine_mjx/backend.py — lazy import guards for mujoco / mjx-jax / mjx-warp
  • origami_engine_mjx/engine.py — OrigamiEngine, the public facade with backend selection
  • origami_engine_mjx/evaluation.py — evaluate_individual / evaluate_population
  • origami_engine_mjx/backends/ — base.py (SimulationBackend ABC), jax_backend.py (put_model / make_data / mjx.step, optional jit), warp_backend.py (mjw.make_model / make_data / mjw.step, GPU), and a registry with get_backend(name)
  • origami_engine_mjx/schemas/ — JSON schema for crease files
  • origami_engine_mjx/crease_patterns/ — reference_miura_4x4.json

Library API

pip install -e ".[dev,jax]"

python -c "
from origami_engine_mjx import (
    OrigamiEngine,
    Crease,
    build_pattern,
    load_default_creases,
)
"

For the complete layout and data flow, see ARCHITECTURE.md.

License

Apache-2.0

Metadata

Release files for origami-engine-mjx 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for origami-engine-mjx 0.3.0
File Size Uploaded Provenance Actions
origami_engine_mjx-0.3.0.tar.gz 2.3 MB With provenance Details for origami_engine_mjx-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for origami-engine-mjx 0.3.0
File Interpreter ABI Platform Actions
origami_engine_mjx-0.3.0-py3-none-any.whl Python 3 none any Details for origami_engine_mjx-0.3.0-py3-none-any.whl

Total release size: 2.3 MB

Release files / origami_engine_mjx-0.3.0.tar.gz

Download URL origami_engine_mjx-0.3.0.tar.gz
Size 2.3 MB
Tags Source
SHA-256 checksum
How to use checksums
51c45a5d8698867106c38ac832519c3044796c442b11350a242a6567d23b5565
BLAKE2b-256 checksum
How to use checksums
ee733469fcbe77c6d3d9cf7fea5ad01b540a79f421a50649b06570c62a5d8ec5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Release files / origami_engine_mjx-0.3.0-py3-none-any.whl

Download URL origami_engine_mjx-0.3.0-py3-none-any.whl
Size 35.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
50e71cf1370e6760c9cab83da0e7791cd0743dd7dcc1237a0652122fae8871af
BLAKE2b-256 checksum
How to use checksums
0bcf8da79da06f4f035583294e080eba04bc2f2b7a6cf4b1d48c028cb7b9bf1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Security for origami-engine-mjx 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for origami_engine_mjx-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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