iqm.qiskit_iqm.iqm_transpilation.IQMOptimizeSingleQubitGates#
- class iqm.qiskit_iqm.iqm_transpilation.IQMOptimizeSingleQubitGates(*args, **kwargs)#
- Bases: - TransformationPass- Optimize the decomposition of single-qubit gates for the IQM gate set. - This optimization pass expects the circuit to be correctly layouted and translated to the IQM architecture and raises an error otherwise. The optimization logic follows the steps: - Convert single-qubit gates to \(U\) gates and combine all neighboring \(U\) gates. 
- Convert \(U\) gates according to \(U(\theta , \phi , \lambda) = ~ RZ(\phi + \lambda) R(\theta, \pi / 2 - \lambda)\). 
- Commute RZ gates to the end of the circuit using the fact that RZ and CZ gates commute, and \(R(\theta , \phi) RZ(\lambda) = RZ(\lambda) R(\theta, \phi - \lambda)\). 
- Drop RZ gates immediately before measurements, and otherwise replace them according to \(RZ(\lambda) = R(\pi, \lambda / 2) R(- \pi, 0)\). 
 - Parameters:
- drop_final_rz – Drop terminal RZ gates even if there are no measurements following them (since they do not affect the measurement results). Note that this will change the unitary propagator of the circuit. It is recommended always to set this to true as the final RZ gates do no change the measurement outcomes of the circuit. 
- ignore_barriers (bool) – Removes the barriers from the circuit before optimization (default = False). 
 
 - Attributes - Methods - _apply_final_r_gates(dag, rz_angles)- Helper function that adds the final PRX/R gates to the circuit according to the accumulated angles. - _handle_c_if_blocks(dag)- Helper function that replaces all classically controlled RGates with an if_else operator. - _handle_if_else_block(dag, node, rz_angles)- Call the optimization recursively on both branches of the if_else node. - _handle_u_gates(dag, node, rz_angles)- Helper function that converts U gates to PRXs and RZ gates, so that the RZ gates can be commuted to the end of the circuit. - _validate_ops(dag)- Helper function that validates that the operations in the circuit are compatible with the IQMOptimizeSingleQubitGates pass. - run(dag[, decompose_rz_to_r])- Runs the single-qubit gate optimization pass. - run(dag: DAGCircuit, decompose_rz_to_r: bool = True) DAGCircuit#
- Runs the single-qubit gate optimization pass. - Parameters:
- dag (DAGCircuit) – The input DAG circuit to optimize. 
- decompose_rz_to_r (bool) – Whether to decompose RZ gates into R gates, or add the to the DAG as RZ gates. This is used in recursive calls to communicate the accumulated RZ angles in - rz_angles.
 
- Returns:
- The optimized DAG circuit. 
- Return type:
 
 
