qiskit_braket_provider.providers.to_qiskit¶
- to_qiskit(circuit, add_measurements=True, verbatim_box_name='verbatim')[source]¶
Return a Qiskit quantum circuit from a Braket quantum circuit.
- Parameters:
circuit (Circuit | Program | str) – Braket quantum circuit or OpenQASM 3 program.
add_measurements (bool) – Whether to append measurements in the conversion
verbatim_box_name (str) – Name to use for BoxOp labels when converting verbatim boxes. Default: “verbatim”
- Returns:
Qiskit quantum circuit
- Return type:
QuantumCircuit
Examples
Convert an OpenQASM 3 program with a verbatim box:
>>> openqasm_program = ''' ... OPENQASM 3.0; ... #pragma braket verbatim ... box { ... h $0; ... cnot $0, $1; ... } ... ''' >>> qiskit_circuit = to_qiskit(openqasm_program) >>> # The verbatim box is represented as a BoxOp in the circuit >>> # You can inspect it by iterating through the circuit operations >>> for instruction in qiskit_circuit.data: ... if hasattr(instruction.operation, 'label') and instruction.operation.label == 'verbatim': ... print(f"Found verbatim box: {instruction.operation}")
Use a custom name for verbatim boxes:
>>> qiskit_circuit = to_qiskit(openqasm_program, verbatim_box_name="my_verbatim") >>> # All verbatim boxes will have the label "my_verbatim"