Skip to content

Commit dcf41b9

Browse files
Attach calibrations for gates used in calibration experiments (backport #1160) (#1161)
This is an automatic backport of pull request #1160 done by [Mergify](https://mergify.com). Co-authored-by: Will Shanks <[email protected]>
1 parent 57d159f commit dcf41b9

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed

qiskit_experiments/calibration_management/calibrations.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,25 @@ def add_schedule(
599599
for param in params_to_register:
600600
self._register_parameter(param, qubits, schedule)
601601

602+
def has_template(self, schedule_name: str, qubits: Optional[Tuple[int, ...]] = None) -> bool:
603+
"""Test if a template schedule is defined
604+
605+
Args:
606+
schedule_name: The name of the template schedule.
607+
qubits: The qubits under which the template schedule was registered.
608+
609+
Returns:
610+
True if a template exists for the schedule name for the given qubits
611+
"""
612+
found = False
613+
try:
614+
self.get_template(schedule_name, qubits)
615+
found = True
616+
except CalibrationError:
617+
pass
618+
619+
return found
620+
602621
def get_template(
603622
self, schedule_name: str, qubits: Optional[Tuple[int, ...]] = None
604623
) -> ScheduleBlock:

qiskit_experiments/library/calibration/fine_drag_cal.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ def _attach_calibrations(self, circuit: QuantumCircuit):
108108
"""Attach the calibrations to the circuit."""
109109
schedule = self._cals.get_schedule(self._sched_name, self.physical_qubits)
110110
circuit.add_calibration(self._sched_name, self.physical_qubits, schedule)
111+
# FineDrag always uses sx so attach it if it is not sched_name
112+
if self._sched_name != "sx":
113+
schedule = self._cals.get_schedule("sx", self.physical_qubits)
114+
circuit.add_calibration("sx", self.physical_qubits, schedule)
111115

112116
def update_calibrations(self, experiment_data: ExperimentData):
113117
"""Update the drag parameter of the pulse in the calibrations."""

qiskit_experiments/library/calibration/rough_amplitude_cal.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,3 +278,12 @@ def _pre_circuit(self) -> QuantumCircuit:
278278
circ = QuantumCircuit(1)
279279
circ.x(0)
280280
return circ
281+
282+
def _attach_calibrations(self, circuit: QuantumCircuit):
283+
"""Attach an x calibration if it is defined."""
284+
# Attach the x calibration as well if it is in self._cals. We allow for
285+
# it not to be present in case a user wants to rely on the default x
286+
# calibration and only calibrate the pulses between levels 1 and 2.
287+
if self._cals.has_template("x", self.physical_qubits):
288+
schedule = self._cals.get_schedule("x", self.physical_qubits)
289+
circuit.add_calibration("x", self.physical_qubits, schedule)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
features:
3+
- |
4+
A new method :meth:`.qiskit_experiments.calibration_management.Calibrations.has_template`
5+
has been added to :class:`.qiskit_experiments.calibration_management.Calibrations`
6+
to check if a template schedule exists for a particular set of qubits.
7+
fixes:
8+
- |
9+
:class:`.qiskit_experiments.library.FineXDragCal` and
10+
:class:`.qiskit_experiments.library.EFRoughXSXAmplitudeCal` were updated to
11+
attach `"sx"` and `"x"` calibrations to their circuits, respectively.
12+
Previously, they only attached the `"x"` and `"x12"` calibrations that they
13+
were calibrating. See issue `#1158 <https://github.com/Qiskit/qiskit-experiments/issues/1158>`_.

0 commit comments

Comments
 (0)