Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: add skip transpile to t1 #1454

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions qiskit_experiments/library/characterization/t1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is much faster but circuits() is the base class method and signature shouldn't change. Indeed this breaks polymorphism of experiment class, e.g. user may think T2 also has this argument. Also experiment.run doesn't consider the qnum argument.

You can consider another approach of creating a pass manager that only performs virtual -> physical index mapping. Which must be lightweight compared with the default level0 pass manager (to reduce overhead you can directly run layout, i.e. layout.run(circuits))

https://github.com/Qiskit-Extensions/qiskit-experiments/blob/fe4ccff973dae85fdff3416b253880051b71e6c3/qiskit_experiments/calibration_management/base_calibration_experiment.py#L317-L332

Unfortunately this code is not as performant as the proposed code change because of the initialization overhead of passes and pass manager instance. However this doesn't cause API break.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there's anything forbidden by this idea in inheritance because the circuit call still behaves the same. You can absolutely add parameters to an inherited function. But this is also backwards compatibl. I also don't know why run needs to know anything about this. It's merely to allow the circuit to be created on any qubit if desired. I don't see why it's relevant whether a user will think T2 has this argument. Of course since this works really well I would argue it should be added to the T2 class as well.

"""
Return a list of experiment circuits

Expand All @@ -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()
Expand Down
Loading