diff --git a/test/benchmarks/mapping_passes.py b/test/benchmarks/mapping_passes.py index 55bed7ffc00b..b33ed36915d8 100644 --- a/test/benchmarks/mapping_passes.py +++ b/test/benchmarks/mapping_passes.py @@ -68,6 +68,11 @@ def time_stochastic_swap(self, _, __): swap.property_set['layout'] = self.layout swap.run(self.dag) + def time_sabre_swap(self, _, __): + swap = SabreSwap(self.coupling_map, seed=42) + swap.property_set['layout'] = self.layout + swap.run(self.dag) + def time_basic_swap(self, _, __): swap = BasicSwap(self.coupling_map) swap.property_set['layout'] = self.layout @@ -111,6 +116,9 @@ def time_set_layout(self, _, __): def time_noise_adaptive_layout(self, _, __): NoiseAdaptiveLayout(self.backend_props).run(self.fresh_dag) + def time_sabre_layout(self, _, __): + SabreLayout(self.coupling_map, seed=42).run(self.fresh_dag) + class RoutedPassBenchmarks: params = ([5, 14, 20], @@ -157,3 +165,12 @@ def time_cxdirection(self, _, __): def time_check_cx_direction(self, _, __): CheckCXDirection(self.coupling_map).run(self.routed_dag) + + def time_gate_direction(self, _, __): + GateDirection(self.coupling_map).run(self.routed_dag) + + def time_check_gate_direction(self, _, __): + CheckGateDirection(self.coupling_map).run(self.routed_dag) + + def time_check_map(self, _, __): + CheckMap(self.coupling_map).run(self.routed_dag) diff --git a/test/benchmarks/passes.py b/test/benchmarks/passes.py index 386bdbd3f76e..deb1ba3c2be6 100644 --- a/test/benchmarks/passes.py +++ b/test/benchmarks/passes.py @@ -14,9 +14,10 @@ # pylint: disable=no-member,invalid-name,missing-docstring,no-name-in-module # pylint: disable=attribute-defined-outside-init,unsubscriptable-object -# pylint: disable=unused-wildcard-import,wildcard-import +# pylint: disable=unused-wildcard-import,wildcard-import,undefined-variable +from qiskit.circuit.equivalence_library import SessionEquivalenceLibrary as SEL from qiskit.transpiler.passes import * from qiskit.converters import circuit_to_dag @@ -88,6 +89,31 @@ def time_optimize_1q(self, _, __): Optimize1qGates().run(self.unrolled_dag) +class MultipleBasisPassBenchmarks: + params = ([5, 14, 20], + [1024], + [['u', 'cx', 'id'], ['rx', 'ry', 'rz', 'r', 'rxx', 'id'], + ['rz', 'x', 'sx', 'cx', 'id']]) + + param_names = ['n_qubits', 'depth', 'basis_gates'] + timeout = 300 + + def setup(self, n_qubits, depth, basis_gates): + seed = 42 + self.circuit = random_circuit(n_qubits, depth, measure=True, seed=seed) + self.dag = circuit_to_dag(self.circuit) + self.basis_gates = basis_gates + + def time_optimize_1q_decompose(self, _, __, ___): + Optimize1qGatesDecomposition(self.basis_gates).run(self.dag) + + def time_optimize_1q_commutation(self, _, __, ___): + Optimize1qGatesSimpleCommutation(self.basis_gates).run(self.dag) + + def time_basis_translator(self, _, __, ___): + BasisTranslator(SEL, self.basis_gates).run(self.dag) + + class PassBenchmarks: params = ([5, 14, 20], [1024]) @@ -161,3 +187,29 @@ def time_remove_diagonal_gates_before_measurement(self, _, __): def time_remove_final_measurements(self, _, __): RemoveFinalMeasurements().run(self.dag) + + def time_contains_instruction(self, _, __): + ContainsInstruction('cx').run(self.dag) + + def time_gates_in_basis(self, _, __): + GatesInBasis(self.basis_gates).run(self.dag) + + def time_remove_barriers(self, _, __): + RemoveBarriers().run(self.dag) + + +class MultiQBlockPassBenchmarks: + params = ([5, 14, 20], + [1024], [1, 2, 3, 4, 5]) + + param_names = ['n_qubits', 'depth', 'max_block_size'] + timeout = 300 + + def setup(self, n_qubits, depth, _): + seed = 42 + self.circuit = random_circuit(n_qubits, depth, measure=True, + conditional=True, reset=True, seed=seed) + self.dag = circuit_to_dag(self.circuit) + + def time_collect_multiq_block(self, _, __, max_block_size): + CollectMultiQBlocks(max_block_size).run(self.dag)