QASM Import & Execution

Overview

QuantumRingsLib supports both OpenQASM 2.0 and OpenQASM 3.0 for composing and executing quantum circuits.

  • OpenQASM 2.0 — best for existing circuits and straightforward workflows.

  • OpenQASM 3.0 — best for complex circuits that require control flow.

Depending on the circuit type, different execution paths can be used.

Choosing an execution path

BackendV2.run accepts both QASM 2.0 and QASM 3.0 files directly and works in all scenarios. The import methods QuantumCircuit.from_qasm_file and QuantumCircuit.from_qasm_str accept files and strings, respectively, and are available when you need a QuantumCircuit object to inspect or modify before running. The helper classes qasm2 (OpenQASM 2.0) and OpenQASM (OpenQASM 3.0) also create QuantumCircuit objects.

Standard

Circuit contains…

Supported methods

2.0

Any circuit

BackendV2.run

QuantumCircuit.from_qasm_file / QuantumCircuit.from_qasm_str

qasm2.load / qasm2.loads

3.0

No control flow; measurements at end

BackendV2.run

QuantumCircuit.from_qasm_file / QuantumCircuit.from_qasm_str

OpenQASM.load / OpenQASM.loads

3.0

Loops or conditionals; measurements at end; classical bits not referenced after measure

BackendV2.run

QuantumCircuit.from_qasm_file / QuantumCircuit.from_qasm_str

OpenQASM.load / OpenQASM.loads

3.0

Loops or conditionals that reference mid-circuit measured classical bits

BackendV2.run only

See also