From 62d5422fbc7813279c9ab5b7ea465709c87b9895 Mon Sep 17 00:00:00 2001 From: David McKay Date: Tue, 14 May 2024 23:58:52 -0400 Subject: [PATCH 1/2] add skip transpile to t1 --- .../framework/composite/composite_analysis.py | 13 +++++---- .../library/characterization/t1.py | 29 ++++++++++++++----- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/qiskit_experiments/framework/composite/composite_analysis.py b/qiskit_experiments/framework/composite/composite_analysis.py index fb04ba50f9..0ec98eed89 100644 --- a/qiskit_experiments/framework/composite/composite_analysis.py +++ b/qiskit_experiments/framework/composite/composite_analysis.py @@ -149,12 +149,15 @@ def _run_analysis(self, experiment_data: ExperimentData): # Since copy for replace result is handled at the parent level # we always run with replace result on component analysis self._analyses[i].run(sub_expdata, replace_results=True) - - # Analysis is running in parallel so we add loop to wait - # for all component analysis to finish before returning - # the parent experiment analysis results - for sub_expdata in component_expdata: + # Block for results to avoid issues nested CompositeAnalysis runs. + # Ideally this constraint will be removed in the future. + # Previously run() was called on all components and then + # block_for_results() was called on all of them, but since only one + # thread can execute Python code at a time there is not much + # difference in performance. Blocking separately limits the number + # of threads that are started simultaneously. sub_expdata.block_for_results() + # Optionally flatten results from all component experiments # for adding to the main experiment data container if self._flatten_results: diff --git a/qiskit_experiments/library/characterization/t1.py b/qiskit_experiments/library/characterization/t1.py index 6f3c02cfc1..ef102ec582 100644 --- a/qiskit_experiments/library/characterization/t1.py +++ b/qiskit_experiments/library/characterization/t1.py @@ -98,7 +98,7 @@ def __init__( # Set experiment options self.set_experiment_options(delays=delays) - def circuits(self) -> List[QuantumCircuit]: + def circuits(self, qnum=0) -> List[QuantumCircuit]: """ Return a list of experiment circuits @@ -109,18 +109,33 @@ def circuits(self) -> List[QuantumCircuit]: circuits = [] for delay in self.experiment_options.delays: - circ = QuantumCircuit(1, 1) - circ.x(0) - circ.barrier(0) - circ.delay(timing.round_delay(time=delay), 0, timing.delay_unit) - circ.barrier(0) - circ.measure(0, 0) + circ = QuantumCircuit(qnum+1, 1) + circ.x(qnum) + circ.barrier(qnum) + circ.delay(timing.round_delay(time=delay), qnum, timing.delay_unit) + circ.barrier(qnum) + circ.measure(qnum, 0) circ.metadata = {"xval": timing.delay_time(time=delay)} circuits.append(circ) return circuits + + def _transpiled_circuits(self) -> List[QuantumCircuit]: + """Return a list of experiment circuits, transpiled. + + Override to skip transpilaion if not needed + """ + if self._backend: + #get basis gates + basis_gates = self._backend.configuration().basis_gates + + if 'x' in basis_gates: + return self.circuits(self.physical_qubits[0]) + + return super()._transpiled_circuits() + def _metadata(self): metadata = super()._metadata() From 6d73c9b795e7a52610fb16c88a66e9ea074aaeaa Mon Sep 17 00:00:00 2001 From: David McKay Date: Wed, 15 May 2024 01:48:13 -0400 Subject: [PATCH 2/2] reset composite analysis --- .../framework/composite/composite_analysis.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/qiskit_experiments/framework/composite/composite_analysis.py b/qiskit_experiments/framework/composite/composite_analysis.py index 0ec98eed89..fb04ba50f9 100644 --- a/qiskit_experiments/framework/composite/composite_analysis.py +++ b/qiskit_experiments/framework/composite/composite_analysis.py @@ -149,15 +149,12 @@ def _run_analysis(self, experiment_data: ExperimentData): # Since copy for replace result is handled at the parent level # we always run with replace result on component analysis self._analyses[i].run(sub_expdata, replace_results=True) - # Block for results to avoid issues nested CompositeAnalysis runs. - # Ideally this constraint will be removed in the future. - # Previously run() was called on all components and then - # block_for_results() was called on all of them, but since only one - # thread can execute Python code at a time there is not much - # difference in performance. Blocking separately limits the number - # of threads that are started simultaneously. - sub_expdata.block_for_results() + # Analysis is running in parallel so we add loop to wait + # for all component analysis to finish before returning + # the parent experiment analysis results + for sub_expdata in component_expdata: + sub_expdata.block_for_results() # Optionally flatten results from all component experiments # for adding to the main experiment data container if self._flatten_results: