Qiskit OpenQASM 3 Importer

0.6.0 · active · verified Fri Apr 17

The `qiskit-qasm3-import` library provides functionality to parse OpenQASM 3 strings into Qiskit circuits, enabling interoperability between QASM 3 programs and the Qiskit ecosystem. It is currently at version 0.6.0 and releases new minor versions periodically, typically in conjunction with Qiskit's major releases or to add support for new QASM 3 features.

Common errors

Warnings

Install

Imports

Quickstart

Parse an OpenQASM 3 string into a Qiskit `QuantumCircuit` object using the `loads` function.

from qiskit_qasm3_import import loads

qasm3_str = """
OPENQASM 3.0;
include "qelib1.inc";
qreg q[2];
creg c[2];
h q[0];
cx q[0], q[1];
measure q -> c;
"""

# Parse the QASM 3 string into a Qiskit QuantumCircuit
circuit = loads(qasm3_str)

# Print a summary of the resulting circuit
print(circuit.draw('text', idle_wires=False))

view raw JSON →