MENOS
High-performance quantum simulation runtime.
An open-source project by Qaulium AI. Product page: qauliumai.com/menos.
MENOS is a quantum circuit simulation compiler and runtime. It analyzes a circuit, estimates the cost of several execution strategies, chooses a plan, and runs it on the engine that fits the workload. It is also a Qiskit BackendV2, EstimatorV2 and SamplerV2, so existing Qiskit code runs against it unchanged.
Full documentation, from installation to the API reference, is at qauliumai.com/menos/docs (see Documentation).
What is MENOS?
Instead of pushing every circuit through one fixed algorithm, MENOS:
- Analyzes the circuit: its structure, its entanglement, and what output you asked for;
- Estimates what each candidate strategy would cost, in a cost model shared by all engines;
- Plans by choosing the cheapest feasible strategy (or, under a time budget, the one predicted to be fastest);
- Executes the plan, watching it against a time budget and replanning if reality disagrees with the estimate.
Why MENOS?
- The choice of engine is a measured cost comparison, not a rule of thumb.
explain() shows every candidate, including why each loser lost.
- Infeasible is a first-class answer. A candidate that cannot run is reported with the reason.
- Independent qubit groups are simulated independently and recombined exactly.
- Work the output cannot depend on is removed (light-cone reduction) before planning.
- Budgets are enforced, not merely estimated: memory before any allocation, time while the run executes. Every memory estimate is an upper bound on what the job really holds, checked by measurement, and each result reports its measured peak.
- Exact results, reproducibly. Every engine reachable from Python is exact, and the same circuit, options and seed give the same counts.
Key capabilities
|
|
| Output |
Counts, exact statevectors, exact Pauli expectation values, exact noisy simulation |
| Engines |
Dense, stabilizer, Pauli propagation, matrix product state, tensor network, exact circuit cutting, density matrix, trajectory. The dense CPU engine fuses neighbouring gates and uses AVX2 kernels, bit for bit the generic kernel |
| Planner |
Cost model in work units with a calibrated time model per engine, automatic factorization, CPU/CUDA selection by calibrated seconds; branch-and-bound pruning of expensive searches and a plan cache for variational loops, so most jobs plan in milliseconds |
| Memory |
Every estimate an upper bound on use, checked by measurement; measured peaks in RAM, GPU memory and disk on every result; a GPU memory pool reused across jobs; a disk tier for dense states beyond the memory budget, bit for bit the in-memory result |
| Circuits |
CircuitBuilder in Python and C++: named gates, run-time parameters, registers, composition, exact inverse, OpenQASM 3 export |
| Integration |
Qiskit BackendV2 (MENOSBackend), EstimatorV2 (MENOSEstimator) and SamplerV2 (MENOSSampler), with Qiskit Aer noise models; the PennyLane device menos.qubit; OpenQASM 3 import (menos.from_qasm3, static subset) and OpenQASM 2/3 on the command line |
| Mitigation |
Opt-in readout-error mitigation with calibrated, reported uncertainty; batch execution of several circuits (run_batch) |
| GPU |
NVIDIA CUDA dense backend, bitwise identical to the CPU |
| Runtime |
Time-budget monitoring with safe abandonment and replanning |
Architecture
Qiskit · PennyLane · OpenQASM · CircuitBuilder → KIR → light-cone reduction → plan cache → analysis
→ cost model (pruned) → planner → execution plan → runtime (memory ledger)
→ engines (dense CPU · CUDA · disk tier · stabilizer · Pauli · MPS · tensor network · cut · density matrix · trajectory)
↘ monitoring → replanning
The C++ layers depend on each other in one direction (api → runtime → engines → kernels; api → planner → cost → analysis → ir → common), enforced by the build. See the documentation's Architecture, Memory Architecture and How Planning Stays Fast pages, and docs/adr/ for the recorded design decisions.
Installation
MENOS is on PyPI and needs Python 3.10 or newer:
pip install menos
# or, inside a uv project
uv add menos
Add the qiskit extra (pip install "menos[qiskit]" or uv add "menos[qiskit]") to use MENOSBackend, MENOSEstimator and MENOSSampler; it pins Qiskit 2.5.2.
The 1.3.1 wheels are prebuilt for CPython 3.10–3.14 on Linux x86-64 (manylinux 2.28) and Windows x64 (win_amd64). Both have the CUDA backend compiled in (built with the CUDA 12.9 toolkit for compute capabilities 7.5 to 12.0, with the CUDA runtime inside the wheel): on a machine with an NVIDIA GPU and driver the planner can use the GPU, and on a machine without one they run on the CPU engines. The Windows wheels have it from 1.3.1; the 1.3.0 Windows wheels are CPU-only. No source distribution is published, so on other platforms build from source.
From source
Build from source for an unsupported platform, a CUDA build for one specific toolkit or GPU, or development. It needs a C++20 compiler, CMake 3.25+, git and LAPACKE. Building downloads test-only dependencies from GitHub at configure time, so it needs network access.
sudo apt install build-essential cmake git liblapacke-dev liblapack-dev libblas-dev # Ubuntu
uv venv .venv --python 3.12
uv pip install --python .venv/bin/python ".[qiskit]"
On Windows (x64; this builds the CPU engines, see the documentation's CUDA Installation page for the CUDA build), install Visual Studio 2026's C++ tools, then:
powershell -ExecutionPolicy Bypass -File scripts\fetch-openblas-windows.ps1 # pinned OpenBLAS, provides LAPACKE
uv venv .venv --python 3.14
uv pip install --python .venv\Scripts\python.exe ".[qiskit]"
Run these from the repository root. See the documentation's Installation and Requirements pages for details, including building with CUDA.
First circuit
from qiskit import QuantumCircuit
from menos.qiskit import MENOSBackend
qc = QuantumCircuit(2, 2)
qc.h(0)
qc.cx(0, 1)
qc.measure([0, 1], [0, 1])
result = MENOSBackend().run(qc, shots=1000, seed_simulator=7).result()
counts = result.get_counts()
print(counts) # {'00': 507, '11': 493}
assert set(counts) <= {"00", "11"}
To write circuits by hand without Qiskit, use the circuit builder (Writing Circuits): named gates, parameters, registers, composition, inverse and OpenQASM 3 export:
import menos
theta = menos.Parameter("theta")
ansatz = menos.CircuitBuilder(2)
ansatz.h(0).cx(0, 1).rz(theta, 1).measure_all()
options = menos.RunOptions()
options.shots = 100
options.seed = 1
counts = menos.run(ansatz.bind({"theta": 0.5}), options).counts
print(ansatz.to_qasm3())
To see how MENOS planned a job, use the native API, whose results carry a plan report:
from menos import Circuit, Opcode, RunOptions, run
circuit = Circuit(2, 2)
circuit.append(Opcode.H, [0])
circuit.append(Opcode.CX, [0, 1])
circuit.append_measure(0, 0)
circuit.append_measure(1, 1)
options = RunOptions()
options.shots = 100
options.seed = 1
print(run(circuit, options).explain())
PennyLane
With the pennylane extra (pip install "menos[pennylane]", CPython 3.11 or later, PennyLane 0.45.1), MENOS is the PennyLane device menos.qubit:
import pennylane as qml
dev = qml.device("menos.qubit", wires=2, seed=7)
@qml.qnode(dev)
def circuit(x):
qml.RX(x, 0)
qml.CNOT([0, 1])
return qml.expval(qml.Z(0) @ qml.Z(1)), qml.state()
Analytic results are exact and agree with default.qubit within 1e-12. Parameter-shift gradients, shots, shot vectors and noise channels are supported. The runnable version is examples/pennylane_device.py; the documentation's PennyLane Device page lists what is refused.
Supported execution engines
| Engine |
Outputs |
Best for |
| Dense |
counts, statevector, expectation |
small to medium circuits; the only engine that produces a statevector. Beyond the memory budget it streams the state through a scratch file (the disk tier: counts and expectation values, bitwise the same) |
| Stabilizer |
counts, expectation |
Clifford circuits, hundreds of qubits |
| Pauli propagation |
expectation |
local observables on circuits of Clifford gates and rotations |
| MPS |
counts, expectation |
low-entanglement circuits, large qubit counts |
| Tensor network |
expectation |
circuits whose contraction structure is cheap |
| Cut and recombine |
expectation |
circuits made of loosely connected clusters |
| Density matrix |
counts, expectation |
noisy circuits, exactly; about 14 qubits on 16 GiB |
| Trajectory |
counts, expectation |
larger noisy circuits, by sampling with a reported standard error; only on request |
Which one runs is the planner's decision, made per job from its cost model. See the documentation's Simulation Engines section.
CPU threads
The dense, density-matrix and trajectory engines apply gates on every hardware thread by default, using MENOS's own thread pool. RunOptions.max_threads caps that number:
None (the default) means all hardware threads.
- A value above the hardware count is treated as the hardware count.
0 is refused.
The thread count never changes a result: statevectors, counts and expectation values are bit-for-bit identical for every setting. Gates on small states always run on one thread, because waking the pool costs more than it saves. OMP_NUM_THREADS has no effect.
from menos import Circuit, Opcode, RunOptions, run
circuit = Circuit(2, 0)
circuit.append(Opcode.H, [0])
circuit.append(Opcode.CX, [0, 1])
options = RunOptions()
options.shots = 0
options.seed = 1
options.want_statevector = True
options.max_threads = 2
print(run(circuit, options).statevector)
In a process that also runs NumPy or SciPy work between MENOS calls (Qiskit does), OpenBLAS's own idle workers can compete with MENOS's threads. Setting OPENBLAS_NUM_THREADS=1 before starting Python measured 1.8× faster at 16–18 qubits on the Phase 15 gate machine (docs/adr/0019 section 10.9). MENOS does not set it, because the setting is process-wide.
With time_budget_seconds, the planner predicts seconds from a time model calibrated per engine on this machine, and picks the plan predicted to be fastest. The calibration runs once per process, the first time a job needs it (about 1.5–2 s on the development machine); later jobs in the same process reuse it. A CPU-only build never calibrates for a job without a time budget. A prediction that turns out wrong is handled by the run-time monitor like any other overrun.
CUDA
The Linux wheels on PyPI have the CUDA backend compiled in, and from 1.3.1 so do the Windows wheels (the 1.3.0 Windows wheels are CPU-only); a default source install has no GPU support. The CUDA backend accelerates the dense engine when the calibrated model says the GPU is faster end to end, transfers included. It needs CUDA 12.0 or newer, and was verified on Linux x86-64 with CUDA 13.4 (compute capability 8.6) and CUDA 12.4 (compute capability 8.9, built for 8.6), and on Windows x64 with CUDA 12.9 (compute capability 8.9). GPU states are allocated from a memory pool that keeps a finished job's memory for the next job; release_device_memory() gives it back to the driver.
Building from source with CUDA requires setting the GPU architecture explicitly:
CMAKE_ARGS="-DMENOS_ENABLE_CUDA=ON -DCMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc \
-DCUDAToolkit_ROOT=/usr/local/cuda -DCMAKE_CUDA_ARCHITECTURES=86" \
uv pip install --python .venv/bin/python ".[qiskit]"
Use your own toolkit path and compute capability. See the documentation's GPU section.
Documentation
The documentation is hosted online at qauliumai.com/menos/docs.
It covers installation, a first-circuit tutorial, Qiskit integration, every engine, the planner and cost model, observables, GPU setup, runtime monitoring and replanning, the API reference, examples and troubleshooting.
Examples
Runnable programs are in examples/. Each asserts its own results, mostly against Qiskit's reference simulator, and is run by the test suite:
.venv/bin/python examples/bell_state.py
Development
cmake --preset release
cmake --build --preset release
ctest --preset release --output-on-failure
The presets are dev (with sanitizers), release, cuda-dev, cuda-release, cuda12-dev and cuda12-release. The cuda-* presets pin /usr/local/cuda; the cuda12-* presets pin Ubuntu's CUDA 12 toolkit (/usr/bin/nvcc) and GCC 13. All of them pin compute capability 8.6. These values are specific to the development machines. Benchmarks are opt-in (-DMENOS_BUILD_BENCHMARKS=ON).