Skip to main content

origami-engine-mjx

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:

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

The crease-pattern parsing, geometry reconstruction, and MJCF model generation are shared between backends — only the simulation execution differs.

Install

# 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]'

Quick start

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)

backend="auto" picks warp if a CUDA GPU is available, otherwise jax.

Architecture

origami_engine_mjx/
├── __init__.py            # public API: OrigamiEngine, Crease, build_pattern, ...
├── constants.py           # physical / solver constants (shared)
├── types.py               # Crease, Pattern, SimulationResult, PopulationResult
├── geometry.py            # crease graph -> faces -> spanning tree (shared, Shapely)
├── model.py               # generate_xml(): Pattern -> MJCF XML (shared, no MuJoCo needed)
├── serialization.py       # JSON crease I/O (shared)
├── patterns.py            # reference Miura patterns (shared)
├── plotting.py            # crease-pattern plots (shared)
├── backend.py             # lazy import guards for mujoco / mjx-jax / mjx-warp
├── engine.py              # OrigamiEngine — public facade, backend selection
├── evaluation.py          # evaluate_individual / evaluate_population
├── backends/
│   ├── base.py            # SimulationBackend ABC
│   ├── __init__.py        # registry + get_backend(name)
│   ├── jax_backend.py     # MJX-JAX: put_model / make_data / mjx.step, jit option
│   └── warp_backend.py    # MJX-Warp: mjw.make_model / make_data / mjw.step (GPU)
├── schemas/               # JSON schema for crease files
└── crease_patterns/       # reference_miura_4x4.json

See docs/ARCHITECTURE.md for details, docs/BACKENDS.md for a backend comparison, and docs/COLAB_GPU.md for GPU validation.

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 benchmark in docs/COLAB_GPU.md.

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

Tests

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

Docs

License

Apache-2.0

Metadata

Release files for origami-engine-mjx 0.1.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.1.0
File Size Uploaded Provenance Actions
origami_engine_mjx-0.1.0.tar.gz 2.2 MB With provenance Details for origami_engine_mjx-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 2.3 MB

Release files / origami_engine_mjx-0.1.0.tar.gz

Download URL origami_engine_mjx-0.1.0.tar.gz
Size 2.2 MB
Tags Source
SHA-256 checksum
How to use checksums
cfd37e6738f2da721271ea050145105fb96de72c16f377ccad6d26709edaadfc
BLAKE2b-256 checksum
How to use checksums
5508114181629ab475b5b4086e53f51c2f5ae4ff7b036c6644dee4eef82de7ce
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.1.0-py3-none-any.whl

Download URL origami_engine_mjx-0.1.0-py3-none-any.whl
Size 32.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
24c7bd87c2f3e0c1ffda613b1687d3144b83212eea9daba729358f7589386d64
BLAKE2b-256 checksum
How to use checksums
b47cc7009bb65524343e59fca632ce514b886ab671afb72f0317c3c043a37caa
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.1.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.1.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