qbraid_qir.qiskit.qiskit_to_qir
- qiskit_to_qir(circuit, name=None, transpile=False, **kwargs)[source]
Converts a Qiskit QuantumCircuit to a PyQIR module.
- Parameters:
circuit (
QuantumCircuit) – The Qiskit QuantumCircuit to convert.name (
Optional[str]) – Identifier for created QIR module. Auto-generated if not provided.transpile (
bool) – If True, transpile the circuit to the supported basis gate set before conversion. This enables conversion of circuits containing gates not directly supported in QIR. Defaults to False.
- Keyword Arguments:
initialize_runtime (bool) – Whether to perform quantum runtime environment initialization, default True.
record_output (bool) – Whether to record output calls for registers, default True.
emit_barrier_calls (bool) – Whether to emit barrier calls in the QIR, default False.
- Return type:
Module- Returns:
The QIR
pyqir.Modulerepresentation of the input Qiskit circuit.- Raises:
TypeError – If the input is not a valid Qiskit QuantumCircuit.
ValueError – If the input circuit is empty.
QiskitConversionError – If the conversion fails.
Example
>>> from qiskit import QuantumCircuit >>> from qbraid_qir.qiskit import qiskit_to_qir >>> >>> qc = QuantumCircuit(2, 2) >>> qc.h(0) >>> qc.cx(0, 1) >>> qc.measure([0, 1], [0, 1]) >>> >>> module = qiskit_to_qir(qc, name="bell") >>> ir = str(module)