3

I would like to run circuits saved as OpenQASM circuits in Stim. Does anyone know how to import these circuits from OpenQASM to Stim?

Many thanks.

user206444
  • 65
  • 4

1 Answers1

3

This isn't directly supported by qiskit or by stim, but you can try using cirq as an intermediary. I don't know how consistently this works, but it works on simple cases.

# pip install stimcirq ply

import stimcirq from cirq.contrib.qasm_import import circuit_from_qasm

cirq_circuit = circuit_from_qasm(""" OPENQASM 2.0; include "qelib1.inc";

qreg q[2];
creg m[2];

h q[0];
cx q[0],q[1];
measure q[0] -> m[0];
measure q[1] -> m[1];

""")

stim_circuit = stimcirq.cirq_circuit_to_stim_circuit(cirq_circuit) print(stim_circuit)

H 0
TICK
CX 0 1
TICK
M 0 1
TICK
Craig Gidney
  • 44,299
  • 1
  • 41
  • 116