Skip to content

Commit

Permalink
Merge pull request #927 from qiboteam/drag_correction
Browse files Browse the repository at this point in the history
Minor correction to qubit spectroscopy ef and drag calibration
  • Loading branch information
andrea-pasquale authored Jul 12, 2024
2 parents 347a7b9 + 9496f50 commit 69a3c6d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 13 deletions.
41 changes: 29 additions & 12 deletions src/qibocal/protocols/drag.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from .utils import (
COLORBAND,
COLORBAND_LINE,
HZ_TO_GHZ,
chi2_reduced,
fallback_period,
guess_period,
Expand Down Expand Up @@ -63,6 +64,8 @@ class DragTuningResults(Results):
class DragTuningData(Data):
"""DragTuning acquisition outputs."""

anharmonicity: dict[QubitId, float] = field(default_factory=dict)
"""Anharmonicity of each qubit."""
data: dict[QubitId, npt.NDArray[DragTuningType]] = field(default_factory=dict)
"""Raw data acquired."""

Expand All @@ -76,24 +79,29 @@ def _acquisition(
Data acquisition for drag pulse tuning experiment.
See https://arxiv.org/pdf/1504.06597.pdf Fig. 2 (c).
"""

data = DragTuningData(
anharmonicity={
qubit: platform.qubits[qubit].anharmonicity * HZ_TO_GHZ for qubit in targets
}
)
# define the parameter to sweep and its range:
# qubit drive DRAG pulse beta parameter
beta_param_range = np.arange(
params.beta_start, params.beta_end, params.beta_step
).round(4)

data = DragTuningData()
beta_param_range = np.arange(params.beta_start, params.beta_end, params.beta_step)

sequences, all_ro_pulses = [], []
for beta_param in beta_param_range:
sequence = PulseSequence()
ro_pulses = {}
for qubit in targets:
RX_drag_pulse = platform.create_RX_drag_pulse(
qubit, start=0, beta=beta_param
qubit, start=0, beta=beta_param / data.anharmonicity[qubit]
)
RX_drag_pulse_minus = platform.create_RX_drag_pulse(
qubit, start=RX_drag_pulse.finish, beta=beta_param, relative_phase=np.pi
qubit,
start=RX_drag_pulse.finish,
beta=beta_param / data.anharmonicity[qubit],
relative_phase=np.pi,
)
ro_pulses[qubit] = platform.create_qubit_readout_pulse(
qubit, start=RX_drag_pulse_minus.finish
Expand Down Expand Up @@ -197,7 +205,6 @@ def _fit(data: DragTuningData) -> DragTuningResults:
)
except Exception as e:
log.warning(f"drag_tuning_fit failed for qubit {qubit} due to {e}.")

return DragTuningResults(betas_optimal, fitted_parameters, chi2=chi2)


Expand All @@ -208,6 +215,7 @@ def _plot(data: DragTuningData, target: QubitId, fit: DragTuningResults):
fitting_report = ""

qubit_data = data[target]
betas = qubit_data.beta
fig = go.Figure(
[
go.Scatter(
Expand All @@ -220,7 +228,7 @@ def _plot(data: DragTuningData, target: QubitId, fit: DragTuningResults):
legendgroup="Probability",
),
go.Scatter(
x=np.concatenate((qubit_data.beta, qubit_data.beta[::-1])),
x=np.concatenate((betas, betas[::-1])),
y=np.concatenate(
(
qubit_data.prob + qubit_data.error,
Expand All @@ -239,8 +247,8 @@ def _plot(data: DragTuningData, target: QubitId, fit: DragTuningResults):
# add fitting traces
if fit is not None:
beta_range = np.linspace(
min(qubit_data.beta),
max(qubit_data.beta),
min(betas),
max(betas),
20,
)

Expand Down Expand Up @@ -273,7 +281,16 @@ def _plot(data: DragTuningData, target: QubitId, fit: DragTuningResults):


def _update(results: DragTuningResults, platform: Platform, target: QubitId):
update.drag_pulse_beta(results.betas[target], platform, target)
try:
update.drag_pulse_beta(
results.betas[target] / platform.qubits[target].anharmonicity,
platform,
target,
)
except ZeroDivisionError:
log.warning(
f"Beta parameter cannot be updated since the anharmoncity for qubit {target} is 0."
)


drag_tuning = Routine(_acquisition, _fit, _plot, _update)
Expand Down
2 changes: 1 addition & 1 deletion src/qibocal/protocols/qubit_spectroscopy_ef.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def _acquisition(
if platform.qubits[qubit].native_gates.RX12.frequency is None:

qd_pulses[qubit].frequency = (
rx_pulses[qubit].frequency - DEFAULT_ANHARMONICITY
rx_pulses[qubit].frequency + DEFAULT_ANHARMONICITY
)
else:
qd_pulses[qubit].frequency = platform.qubits[
Expand Down

0 comments on commit 69a3c6d

Please sign in to comment.