def optimized_circuit(circuit: circuits.Circuit, tolerance: float = 1e-8, repeat: int = 10, merge_interactions: bool = True ) -> circuits.Circuit: circuit = circuits.Circuit(circuit) # Make a copy for _ in range(repeat): start_len = len(circuit) start_cz_count = _cz_count(circuit) if merge_interactions: circuits.MergeInteractions(allow_partial_czs=False, post_clean_up=_optimized_ops, ).optimize_circuit(circuit) circuit2 = pauli_string_optimized_circuit( circuit, move_cliffords=False, tolerance=tolerance) circuit3 = clifford_optimized_circuit( circuit2, tolerance=tolerance) if (len(circuit3) == start_len and _cz_count(circuit3) == start_cz_count): return circuit3 circuit = circuit3 return circuit
def optimized_circuit( circuit: circuits.Circuit, tolerance: float = 1e-8, repeat: int = 10, ) -> circuits.Circuit: for _ in range(repeat): circuit2 = pauli_string_optimized_circuit(circuit, move_cliffords=True, tolerance=tolerance) circuit3 = clifford_optimized_circuit(circuit2, tolerance=tolerance) if (len(circuit3) == len(circuit) and _cz_count(circuit3) == _cz_count(circuit)): return circuit3 circuit = circuit3 return circuit
def optimized_circuit( circuit: circuits.Circuit, atol: float = 1e-8, repeat: int = 10, merge_interactions: bool = True ) -> circuits.Circuit: circuit = circuits.Circuit(circuit) # Make a copy gateset = _CZTargetGateSet(post_clean_up=_optimized_ops) for _ in range(repeat): start_len = len(circuit) start_cz_count = _cz_count(circuit) if merge_interactions: circuit = transformers.optimize_for_target_gateset(circuit, gateset=gateset) circuit2 = pauli_string_optimized_circuit(circuit, move_cliffords=False, atol=atol) circuit3 = clifford_optimized_circuit(circuit2, atol=atol) if len(circuit3) == start_len and _cz_count(circuit3) == start_cz_count: return circuit3 circuit = circuit3 return circuit