qbraid.transpiler.conversions.qasm2.qasm2_to_pyquil

qasm2_to_pyquil(qasm)[source]

Returns a pyQuil Program equivalent to the input OpenQASM 2 program.

OpenQASM 2 is a subset of OpenQASM 3 for the purposes of this conversion, so the OpenQASM 3 converter is reused directly. Routing through it (rather than through Cirq, which was previously the shortest path in the conversion graph) preserves two properties that Rigetti’s ProtoQuil dialect requires and that a Cirq round trip does not keep:

  • Instruction order. A cirq.Circuit stores operations in moments, so rebuilding a program from it emits each measurement as early as it can be scheduled, interleaving measurements with gates on other qubits.

  • A single classical register. Cirq’s Quil writer declares one BIT[1] register per measurement key (m0, m1, …), losing the source register layout, whereas this emits one ro register whose bit indices are the declared creg bit indices.

Parameters:

qasm (str) – OpenQASM 2 program to convert.

Returns:

pyQuil Program equivalent to the input program.

Return type:

pyquil.Program

Raises:

ProgramConversionError – If the program is malformed or contains a gate/statement that is not supported by the conversion.