From 553f218c67bba61ba9fcedf759770e1f130e764a Mon Sep 17 00:00:00 2001 From: Ali Javadi Date: Mon, 23 Jan 2023 22:41:42 -0500 Subject: [PATCH 1/2] faster transpile (qubit lookup) in rb code --- .../library/randomized_benchmarking/rb_experiment.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qiskit_experiments/library/randomized_benchmarking/rb_experiment.py b/qiskit_experiments/library/randomized_benchmarking/rb_experiment.py index 1fe97ed8b2..e9b51e9e89 100644 --- a/qiskit_experiments/library/randomized_benchmarking/rb_experiment.py +++ b/qiskit_experiments/library/randomized_benchmarking/rb_experiment.py @@ -384,12 +384,13 @@ def _transpiled_circuits(self) -> List[QuantumCircuit]: # This is probably main source of performance regression. # This should be integrated into transpile pass in future. for circ in transpiled: + qubit_indices = {bit: index for index, bit in enumerate(circ.qubits)} count_ops_result = defaultdict(int) # This is physical circuits, i.e. qargs is physical index for inst, qargs, _ in circ.data: if inst.name in ("measure", "reset", "delay", "barrier", "snapshot"): continue - qinds = [circ.find_bit(q).index for q in qargs] + qinds = [qubit_indices[q] for q in qargs] if not set(self.physical_qubits).issuperset(qinds): continue # Not aware of multi-qubit gate direction From d511ed1e0ba74dfca30ff04670361394a1155e77 Mon Sep 17 00:00:00 2001 From: Ali Javadi Date: Mon, 23 Jan 2023 22:43:13 -0500 Subject: [PATCH 2/2] just once --- .../library/randomized_benchmarking/rb_experiment.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiskit_experiments/library/randomized_benchmarking/rb_experiment.py b/qiskit_experiments/library/randomized_benchmarking/rb_experiment.py index e9b51e9e89..274f56dfee 100644 --- a/qiskit_experiments/library/randomized_benchmarking/rb_experiment.py +++ b/qiskit_experiments/library/randomized_benchmarking/rb_experiment.py @@ -383,8 +383,8 @@ def _transpiled_circuits(self) -> List[QuantumCircuit]: # Compute average basis gate numbers per Clifford operation # This is probably main source of performance regression. # This should be integrated into transpile pass in future. + qubit_indices = {bit: index for index, bit in enumerate(transpiled[0].qubits)} for circ in transpiled: - qubit_indices = {bit: index for index, bit in enumerate(circ.qubits)} count_ops_result = defaultdict(int) # This is physical circuits, i.e. qargs is physical index for inst, qargs, _ in circ.data: