MTBDD-based quantum circuit simulator · WebAssembly build

MEDUSA, running in your browser

MEDUSA keeps a quantum state as a multi-terminal binary decision diagram and, for circuits with loops, computes a symbolic summary of the loop body once instead of executing every iteration. Every number on this page is measured live on your device by the simulator's own C code compiled to WebAssembly.

Amplitude representation (applies to the whole page)
Loading the simulator…

Loop summarization against plain execution

Grover's search repeats one loop body, the oracle followed by the diffusion operator, about 2n/2 times. Both lanes simulate the same OpenQASM file from the MEDUSA benchmark set. The only difference is the --symbolic flag.

 

With loop summarization

MEDUSA --symbolic --file grover.qasm
–
waiting

Without: every iteration executed

MEDUSA --file grover.qasm
–
waiting
The speedup appears here once both lanes have a result.

Simulation time against circuit size, measured on this device

with loop summarization without time limit (run stopped)
Show the measurements as a table

What the summary does

  1. Abstract. Each distinct amplitude in the state entering the loop is replaced by a symbolic variable. Grover's state has only a handful.
  2. Run the body symbolically. The gates are applied once, and the leaves of the MTBDD become terms over those variables.
  3. Refine to a fixpoint. If two basis states sharing a variable are updated differently, the variable is split and the body is run again.
  4. Evaluate. The resulting update map is applied for all K iterations on a few numbers, with no further gate operations.

Loop-free circuits: the simulator itself is fast

These circuits from the repository's benchmark set have no loops, so summarization plays no part. Gates are applied directly on the decision diagram, whose size follows the structure of the state and not 2n.

CircuitQubitsGatesTimeMTBDD nodesWasm memoryDense vector would hold

Wasm memory is the whole linear memory of the instance at exit, including an 8 MiB stack reservation. The last column is context only: a dense state vector stores one complex amplitude per basis state.

Playground

Edit the circuit or pick an example. Supported gates: x y z h s t tdg, rx ry rz (float64 only), cx cz ccx mcx, one for loop level, and measure.

The result appears here.