From c28039847aad2869956f22ed785517188eba3bab Mon Sep 17 00:00:00 2001 From: Andrea Pasquale Date: Fri, 15 Nov 2024 15:15:09 +0100 Subject: [PATCH] refactor: Platform -> CalibrationPlatform + drop virtual_z_signal --- src/qibocal/protocols/__init__.py | 2 - src/qibocal/protocols/allxy/allxy.py | 7 +- .../allxy/allxy_resonator_depletion_tuning.py | 5 +- src/qibocal/protocols/classification.py | 9 +- src/qibocal/protocols/coherence/spin_echo.py | 5 +- .../protocols/coherence/spin_echo_signal.py | 9 +- src/qibocal/protocols/coherence/t1.py | 5 +- src/qibocal/protocols/coherence/t1_signal.py | 8 +- src/qibocal/protocols/coherence/t2.py | 5 +- src/qibocal/protocols/coherence/t2_signal.py | 7 +- src/qibocal/protocols/coherence/zeno.py | 9 +- src/qibocal/protocols/dispersive_shift.py | 20 ++- .../protocols/dispersive_shift_qutrit.py | 16 +- src/qibocal/protocols/drag.py | 7 +- src/qibocal/protocols/flipping.py | 11 +- .../flux_dependence/qubit_crosstalk.py | 8 +- .../flux_dependence/qubit_flux_dependence.py | 6 +- .../resonator_flux_dependence.py | 19 ++- .../protocols/qubit_power_spectroscopy.py | 4 +- src/qibocal/protocols/qubit_spectroscopy.py | 11 +- .../protocols/qubit_spectroscopy_ef.py | 11 +- .../protocols/qutrit_classification.py | 5 +- src/qibocal/protocols/rabi/amplitude.py | 11 +- .../protocols/rabi/amplitude_frequency.py | 7 +- .../rabi/amplitude_frequency_signal.py | 9 +- .../protocols/rabi/amplitude_signal.py | 11 +- src/qibocal/protocols/rabi/ef.py | 10 +- src/qibocal/protocols/rabi/length.py | 7 +- .../protocols/rabi/length_frequency.py | 7 +- .../protocols/rabi/length_frequency_signal.py | 9 +- src/qibocal/protocols/rabi/length_signal.py | 11 +- src/qibocal/protocols/ramsey/ramsey.py | 12 +- src/qibocal/protocols/ramsey/ramsey_signal.py | 16 +- src/qibocal/protocols/ramsey/ramsey_zz.py | 13 +- .../randomized_benchmarking/filtered_rb.py | 6 +- .../randomized_benchmarking/standard_rb.py | 8 +- .../randomized_benchmarking/standard_rb_2q.py | 9 +- .../standard_rb_2q_inter.py | 8 +- .../randomized_benchmarking/utils.py | 8 +- .../protocols/readout_characterization.py | 9 +- .../protocols/readout_mitigation_matrix.py | 9 +- .../resonator_amplitude.py | 11 +- src/qibocal/protocols/resonator_punchout.py | 16 +- .../protocols/resonator_spectroscopy.py | 20 +-- .../calibrate_state_discrimination.py | 11 +- .../time_of_flight_readout.py | 7 +- src/qibocal/protocols/state_tomography.py | 6 +- .../two_qubit_interaction/__init__.py | 1 - .../two_qubit_interaction/chevron/chevron.py | 11 +- .../chevron/chevron_signal.py | 7 +- .../two_qubit_interaction/chevron/utils.py | 5 +- .../two_qubit_interaction/optimize.py | 9 +- .../two_qubit_interaction/virtual_z_phases.py | 10 +- .../virtual_z_phases_signal.py | 145 ------------------ .../protocols/two_qubit_state_tomography.py | 6 +- tests/runcards/protocols.yml | 26 ---- 56 files changed, 276 insertions(+), 384 deletions(-) delete mode 100644 src/qibocal/protocols/two_qubit_interaction/virtual_z_phases_signal.py diff --git a/src/qibocal/protocols/__init__.py b/src/qibocal/protocols/__init__.py index 1c1d01a52..f6aa87e61 100644 --- a/src/qibocal/protocols/__init__.py +++ b/src/qibocal/protocols/__init__.py @@ -49,7 +49,6 @@ chevron, chevron_signal, correct_virtual_z_phases, - correct_virtual_z_phases_signal, optimize_two_qubit_gate, ) from .two_qubit_state_tomography import two_qubit_state_tomography @@ -93,7 +92,6 @@ "chevron", "chevron_signal", "correct_virtual_z_phases", - "correct_virtual_z_phases_signal", "state_tomography", "allxy_resonator_depletion_tuning", "two_qubit_state_tomography", diff --git a/src/qibocal/protocols/allxy/allxy.py b/src/qibocal/protocols/allxy/allxy.py index b1fa926cd..5fc31c17a 100644 --- a/src/qibocal/protocols/allxy/allxy.py +++ b/src/qibocal/protocols/allxy/allxy.py @@ -3,9 +3,10 @@ import numpy as np import numpy.typing as npt import plotly.graph_objects as go -from qibolab import AcquisitionType, AveragingMode, Delay, Platform, PulseSequence +from qibolab import AcquisitionType, AveragingMode, Delay, PulseSequence from qibocal.auto.operation import Data, Parameters, QubitId, Results, Routine +from qibocal.calibration import CalibrationPlatform @dataclass @@ -64,7 +65,7 @@ class AllXYData(Data): def _acquisition( params: AllXYParameters, - platform: Platform, + platform: CalibrationPlatform, targets: list[QubitId], ) -> AllXYData: r""" @@ -124,7 +125,7 @@ def _acquisition( def allxy_sequence( - platform: Platform, + platform: CalibrationPlatform, gates, qubit, sequence_delay=None, diff --git a/src/qibocal/protocols/allxy/allxy_resonator_depletion_tuning.py b/src/qibocal/protocols/allxy/allxy_resonator_depletion_tuning.py index 8b2cb90ac..4f92216df 100644 --- a/src/qibocal/protocols/allxy/allxy_resonator_depletion_tuning.py +++ b/src/qibocal/protocols/allxy/allxy_resonator_depletion_tuning.py @@ -4,9 +4,10 @@ import numpy as np import numpy.typing as npt import plotly.graph_objects as go -from qibolab import AveragingMode, Platform, PulseSequence +from qibolab import AveragingMode, PulseSequence from qibocal.auto.operation import Data, Parameters, QubitId, Results, Routine +from qibocal.calibration import CalibrationPlatform from . import allxy @@ -54,7 +55,7 @@ def delay_params(self): def _acquisition( params: AllXYResonatorParameters, - platform: Platform, + platform: CalibrationPlatform, targets: list[QubitId], ) -> AllXYResonatorData: r""" diff --git a/src/qibocal/protocols/classification.py b/src/qibocal/protocols/classification.py index f62c04221..06fa3425b 100644 --- a/src/qibocal/protocols/classification.py +++ b/src/qibocal/protocols/classification.py @@ -7,7 +7,7 @@ import numpy.typing as npt import pandas as pd import plotly.graph_objects as go -from qibolab import AcquisitionType, Platform, PulseSequence +from qibolab import AcquisitionType, PulseSequence from sklearn.metrics import roc_auc_score, roc_curve from qibocal import update @@ -20,6 +20,7 @@ Routine, ) from qibocal.auto.serialize import serialize +from qibocal.calibration import CalibrationPlatform from qibocal.fitting.classifier import run from qibocal.protocols.utils import ( LEGEND_FONT_SIZE, @@ -151,7 +152,7 @@ def save(self, path): def _acquisition( params: SingleShotClassificationParameters, - platform: Platform, + platform: CalibrationPlatform, targets: list[QubitId], ) -> SingleShotClassificationData: """ @@ -396,7 +397,9 @@ def _plot( def _update( - results: SingleShotClassificationResults, platform: Platform, target: QubitId + results: SingleShotClassificationResults, + platform: CalibrationPlatform, + target: QubitId, ): update.iq_angle(results.rotation_angle[target], platform, target) update.threshold(results.threshold[target], platform, target) diff --git a/src/qibocal/protocols/coherence/spin_echo.py b/src/qibocal/protocols/coherence/spin_echo.py index 6e4264f88..22b90c390 100644 --- a/src/qibocal/protocols/coherence/spin_echo.py +++ b/src/qibocal/protocols/coherence/spin_echo.py @@ -3,9 +3,10 @@ import numpy as np import plotly.graph_objects as go -from qibolab import AcquisitionType, AveragingMode, Parameter, Platform, Sweeper +from qibolab import AcquisitionType, AveragingMode, Parameter, Sweeper from qibocal.auto.operation import QubitId, Routine +from qibocal.calibration import CalibrationPlatform from qibocal.result import probability from ..utils import table_dict, table_html @@ -35,7 +36,7 @@ class SpinEchoData(t1.T1Data): def _acquisition( params: SpinEchoParameters, - platform: Platform, + platform: CalibrationPlatform, targets: list[QubitId], ) -> SpinEchoData: """Data acquisition for SpinEcho""" diff --git a/src/qibocal/protocols/coherence/spin_echo_signal.py b/src/qibocal/protocols/coherence/spin_echo_signal.py index 6850c6d1b..8321e6217 100644 --- a/src/qibocal/protocols/coherence/spin_echo_signal.py +++ b/src/qibocal/protocols/coherence/spin_echo_signal.py @@ -3,9 +3,10 @@ import numpy as np import plotly.graph_objects as go -from qibolab import AcquisitionType, AveragingMode, Parameter, Platform, Sweeper +from qibolab import AcquisitionType, AveragingMode, Parameter, Sweeper from qibocal.auto.operation import Parameters, QubitId, Results, Routine +from qibocal.calibration import CalibrationPlatform from qibocal.result import magnitude, phase from ... import update @@ -47,7 +48,7 @@ class SpinEchoSignalData(T1SignalData): def _acquisition( params: SpinEchoSignalParameters, - platform: Platform, + platform: CalibrationPlatform, targets: list[QubitId], ) -> SpinEchoSignalData: """Data acquisition for SpinEcho""" @@ -172,7 +173,9 @@ def _plot(data: SpinEchoSignalData, target: QubitId, fit: SpinEchoSignalResults return figures, fitting_report -def _update(results: SpinEchoSignalResults, platform: Platform, target: QubitId): +def _update( + results: SpinEchoSignalResults, platform: CalibrationPlatform, target: QubitId +): update.t2_spin_echo(results.t2_spin_echo[target], platform, target) diff --git a/src/qibocal/protocols/coherence/t1.py b/src/qibocal/protocols/coherence/t1.py index 477590183..0db2a3a97 100644 --- a/src/qibocal/protocols/coherence/t1.py +++ b/src/qibocal/protocols/coherence/t1.py @@ -4,9 +4,10 @@ import numpy as np import numpy.typing as npt import plotly.graph_objects as go -from qibolab import AcquisitionType, AveragingMode, Parameter, Platform, Sweeper +from qibolab import AcquisitionType, AveragingMode, Parameter, Sweeper from qibocal.auto.operation import Data, QubitId, Routine +from qibocal.calibration import CalibrationPlatform from qibocal.result import probability from ..utils import table_dict, table_html @@ -44,7 +45,7 @@ class T1Data(Data): def _acquisition( - params: T1Parameters, platform: Platform, targets: list[QubitId] + params: T1Parameters, platform: CalibrationPlatform, targets: list[QubitId] ) -> T1Data: """Data acquisition for T1 experiment.""" diff --git a/src/qibocal/protocols/coherence/t1_signal.py b/src/qibocal/protocols/coherence/t1_signal.py index 7968d5d4f..640fcfec6 100644 --- a/src/qibocal/protocols/coherence/t1_signal.py +++ b/src/qibocal/protocols/coherence/t1_signal.py @@ -9,12 +9,12 @@ AveragingMode, Delay, Parameter, - Platform, PulseSequence, Sweeper, ) from qibocal.auto.operation import Data, Parameters, QubitId, Results, Routine +from qibocal.calibration import CalibrationPlatform from qibocal.result import magnitude, phase from ... import update @@ -63,7 +63,7 @@ def average(self): def t1_sequence( - platform: Platform, targets: list[QubitId], delay: Optional[int] = None + platform: CalibrationPlatform, targets: list[QubitId], delay: Optional[int] = None ): """Create sequence for T1 experiment with a given optional delay.""" sequence = PulseSequence() @@ -88,7 +88,7 @@ def t1_sequence( def _acquisition( - params: T1SignalParameters, platform: Platform, targets: list[QubitId] + params: T1SignalParameters, platform: CalibrationPlatform, targets: list[QubitId] ) -> T1SignalData: """Data acquisition for T1 experiment. @@ -207,7 +207,7 @@ def _plot(data: T1SignalData, target: QubitId, fit: T1SignalResults = None): return figures, fitting_report -def _update(results: T1SignalResults, platform: Platform, target: QubitId): +def _update(results: T1SignalResults, platform: CalibrationPlatform, target: QubitId): update.t1(results.t1[target], platform, target) diff --git a/src/qibocal/protocols/coherence/t2.py b/src/qibocal/protocols/coherence/t2.py index cc3054a7a..6a6d9d672 100644 --- a/src/qibocal/protocols/coherence/t2.py +++ b/src/qibocal/protocols/coherence/t2.py @@ -3,9 +3,10 @@ import numpy as np import plotly.graph_objects as go -from qibolab import AcquisitionType, AveragingMode, Parameter, Platform, Sweeper +from qibolab import AcquisitionType, AveragingMode, Parameter, Sweeper from qibocal.auto.operation import QubitId, Routine +from qibocal.calibration import CalibrationPlatform from ...result import probability from ..ramsey.utils import ramsey_sequence @@ -41,7 +42,7 @@ class T2Data(t1.T1Data): def _acquisition( params: T2Parameters, - platform: Platform, + platform: CalibrationPlatform, targets: list[QubitId], ) -> T2Data: """Data acquisition for T2 experiment.""" diff --git a/src/qibocal/protocols/coherence/t2_signal.py b/src/qibocal/protocols/coherence/t2_signal.py index 60afc3f33..4f1a2dea4 100644 --- a/src/qibocal/protocols/coherence/t2_signal.py +++ b/src/qibocal/protocols/coherence/t2_signal.py @@ -3,10 +3,11 @@ import numpy as np import plotly.graph_objects as go -from qibolab import AcquisitionType, AveragingMode, Parameter, Platform, Sweeper +from qibolab import AcquisitionType, AveragingMode, Parameter, Sweeper from qibocal import update from qibocal.auto.operation import Parameters, QubitId, Results, Routine +from qibocal.calibration import CalibrationPlatform from ...result import magnitude, phase from ..ramsey.utils import ramsey_sequence @@ -51,7 +52,7 @@ class T2SignalData(t1_signal.T1SignalData): def _acquisition( params: T2SignalParameters, - platform: Platform, + platform: CalibrationPlatform, targets: list[QubitId], ) -> T2SignalData: """Data acquisition for T2 experiment. @@ -174,7 +175,7 @@ def _plot(data: T2SignalData, target: QubitId, fit: T2SignalResults = None): return figures, fitting_report -def _update(results: T2SignalResults, platform: Platform, target: QubitId): +def _update(results: T2SignalResults, platform: CalibrationPlatform, target: QubitId): update.t2(results.t2[target], platform, target) diff --git a/src/qibocal/protocols/coherence/zeno.py b/src/qibocal/protocols/coherence/zeno.py index f957907da..2ed4d4fec 100644 --- a/src/qibocal/protocols/coherence/zeno.py +++ b/src/qibocal/protocols/coherence/zeno.py @@ -3,10 +3,11 @@ import numpy as np import plotly.graph_objects as go -from qibolab import AcquisitionType, AveragingMode, Platform, PulseSequence, Readout +from qibolab import AcquisitionType, AveragingMode, PulseSequence, Readout from qibocal import update from qibocal.auto.operation import Parameters, QubitId, Results, Routine +from qibocal.calibration import CalibrationPlatform from ...result import probability from ..utils import table_dict, table_html @@ -36,7 +37,7 @@ class ZenoResults(Results): def zeno_sequence( - platform: Platform, targets: list[QubitId], readouts: int + platform: CalibrationPlatform, targets: list[QubitId], readouts: int ) -> tuple[PulseSequence, dict[QubitId, int]]: """Generating sequence for Zeno experiment.""" @@ -62,7 +63,7 @@ class ZenoData(t1.T1Data): def _acquisition( params: ZenoParameters, - platform: Platform, + platform: CalibrationPlatform, targets: list[QubitId], ) -> ZenoData: """ @@ -199,7 +200,7 @@ def _plot(data: ZenoData, fit: ZenoResults, target: QubitId): return figures, fitting_report -def _update(results: ZenoResults, platform: Platform, qubit: QubitId): +def _update(results: ZenoResults, platform: CalibrationPlatform, qubit: QubitId): update.t1(results.zeno_t1[qubit], platform, qubit) diff --git a/src/qibocal/protocols/dispersive_shift.py b/src/qibocal/protocols/dispersive_shift.py index 275c15ed8..3a63792f8 100644 --- a/src/qibocal/protocols/dispersive_shift.py +++ b/src/qibocal/protocols/dispersive_shift.py @@ -4,17 +4,11 @@ import numpy.typing as npt import plotly.graph_objects as go from plotly.subplots import make_subplots -from qibolab import ( - AcquisitionType, - AveragingMode, - Parameter, - Platform, - PulseSequence, - Sweeper, -) +from qibolab import AcquisitionType, AveragingMode, Parameter, PulseSequence, Sweeper from qibocal import update from qibocal.auto.operation import Data, Parameters, QubitId, Results, Routine +from qibocal.calibration import CalibrationPlatform from qibocal.protocols.utils import ( HZ_TO_GHZ, lorentzian, @@ -79,7 +73,9 @@ class DispersiveShiftData(Data): def _acquisition( - params: DispersiveShiftParameters, platform: Platform, targets: list[QubitId] + params: DispersiveShiftParameters, + platform: CalibrationPlatform, + targets: list[QubitId], ) -> DispersiveShiftData: r""" Data acquisition for dispersive shift experiment. @@ -88,7 +84,7 @@ def _acquisition( Args: params (DispersiveShiftParameters): experiment's parameters - platform (Platform): Qibolab platform object + platform (CalibrationPlatform): Qibolab platform object targets (list): list of target qubits to perform the action """ @@ -322,7 +318,9 @@ def _plot(data: DispersiveShiftData, target: QubitId, fit: DispersiveShiftResult return figures, fitting_report -def _update(results: DispersiveShiftResults, platform: Platform, target: QubitId): +def _update( + results: DispersiveShiftResults, platform: CalibrationPlatform, target: QubitId +): update.readout_frequency(results.best_freq[target], platform, target) if results.frequencies[target] is not None: delta = ( diff --git a/src/qibocal/protocols/dispersive_shift_qutrit.py b/src/qibocal/protocols/dispersive_shift_qutrit.py index be2a67906..0ce0f09c8 100644 --- a/src/qibocal/protocols/dispersive_shift_qutrit.py +++ b/src/qibocal/protocols/dispersive_shift_qutrit.py @@ -3,16 +3,10 @@ import numpy as np import plotly.graph_objects as go from plotly.subplots import make_subplots -from qibolab import ( - AcquisitionType, - AveragingMode, - Parameter, - Platform, - PulseSequence, - Sweeper, -) +from qibolab import AcquisitionType, AveragingMode, Parameter, PulseSequence, Sweeper from qibocal.auto.operation import QubitId, Results, Routine +from qibocal.calibration import CalibrationPlatform from qibocal.protocols.utils import ( GHZ_TO_HZ, HZ_TO_GHZ, @@ -71,7 +65,9 @@ class DispersiveShiftQutritData(DispersiveShiftData): def _acquisition( - params: DispersiveShiftParameters, platform: Platform, targets: list[QubitId] + params: DispersiveShiftParameters, + platform: CalibrationPlatform, + targets: list[QubitId], ) -> DispersiveShiftQutritData: r""" Data acquisition for dispersive shift qutrit experiment. @@ -80,7 +76,7 @@ def _acquisition( Args: params (DispersiveShiftParameters): experiment's parameters - platform (Platform): Qibolab platform object + platform (CalibrationPlatform): Qibolab platform object targets (list): list of target qubits to perform the action """ diff --git a/src/qibocal/protocols/drag.py b/src/qibocal/protocols/drag.py index f88dfac63..6910c9ffb 100644 --- a/src/qibocal/protocols/drag.py +++ b/src/qibocal/protocols/drag.py @@ -4,10 +4,11 @@ import numpy as np import numpy.typing as npt import plotly.graph_objects as go -from qibolab import AcquisitionType, AveragingMode, Delay, Drag, Platform, PulseSequence +from qibolab import AcquisitionType, AveragingMode, Delay, Drag, PulseSequence from scipy.optimize import curve_fit from qibocal.auto.operation import Data, Parameters, QubitId, Results, Routine +from qibocal.calibration import CalibrationPlatform from qibocal.config import log from qibocal.result import probability from qibocal.update import replace @@ -70,7 +71,7 @@ class DragTuningData(Data): def _acquisition( params: DragTuningParameters, - platform: Platform, + platform: CalibrationPlatform, targets: list[QubitId], ) -> DragTuningData: r""" @@ -297,7 +298,7 @@ def _plot(data: DragTuningData, target: QubitId, fit: DragTuningResults): return figures, fitting_report -def _update(results: DragTuningResults, platform: Platform, target: QubitId): +def _update(results: DragTuningResults, platform: CalibrationPlatform, target: QubitId): # TODO: implement update pass # try: diff --git a/src/qibocal/protocols/flipping.py b/src/qibocal/protocols/flipping.py index ccc8dcf73..a09d1360b 100644 --- a/src/qibocal/protocols/flipping.py +++ b/src/qibocal/protocols/flipping.py @@ -4,11 +4,12 @@ import numpy as np import numpy.typing as npt import plotly.graph_objects as go -from qibolab import AcquisitionType, AveragingMode, Platform, PulseSequence +from qibolab import AcquisitionType, AveragingMode, PulseSequence from scipy.optimize import curve_fit from qibocal import update from qibocal.auto.operation import Data, Parameters, QubitId, Results, Routine +from qibocal.calibration import CalibrationPlatform from qibocal.config import log from qibocal.protocols.utils import ( fallback_period, @@ -22,7 +23,7 @@ def flipping_sequence( - platform: Platform, qubit: QubitId, delta_amplitude: float, flips: int + platform: CalibrationPlatform, qubit: QubitId, delta_amplitude: float, flips: int ): """Pulse sequence for flipping experiment.""" @@ -97,7 +98,7 @@ class FlippingData(Data): def _acquisition( params: FlippingParameters, - platform: Platform, + platform: CalibrationPlatform, targets: list[QubitId], ) -> FlippingData: r""" @@ -109,7 +110,7 @@ def _acquisition( Args: params (:class:`SingleShotClassificationParameters`): input parameters - platform (:class:`Platform`): Qibolab's platform + platform (:class:`CalibrationPlatform`): Qibolab's platform qubits (dict): dict of target :class:`Qubit` objects to be characterized Returns: @@ -356,7 +357,7 @@ def _plot(data: FlippingData, target: QubitId, fit: FlippingResults = None): return figures, fitting_report -def _update(results: FlippingResults, platform: Platform, qubit: QubitId): +def _update(results: FlippingResults, platform: CalibrationPlatform, qubit: QubitId): update.drive_amplitude(results.amplitude[qubit], platform, qubit) diff --git a/src/qibocal/protocols/flux_dependence/qubit_crosstalk.py b/src/qibocal/protocols/flux_dependence/qubit_crosstalk.py index 2fc34837a..98402accb 100644 --- a/src/qibocal/protocols/flux_dependence/qubit_crosstalk.py +++ b/src/qibocal/protocols/flux_dependence/qubit_crosstalk.py @@ -8,7 +8,6 @@ AveragingMode, Delay, Parameter, - Platform, PulseSequence, Sweeper, ) @@ -16,6 +15,7 @@ from qibocal import update from qibocal.auto.operation import QubitId, Routine +from qibocal.calibration import CalibrationPlatform from qibocal.config import log from ...result import magnitude, phase @@ -92,7 +92,7 @@ def __contains__(self, key: QubitId): def _acquisition( params: QubitCrosstalkParameters, - platform: Platform, + platform: CalibrationPlatform, targets: list[QubitId], ) -> QubitCrosstalkData: """Data acquisition for Crosstalk Experiment.""" @@ -315,7 +315,9 @@ def _plot(data: QubitCrosstalkData, fit: QubitCrosstalkResults, target: QubitId) return figures, fitting_report -def _update(results: QubitCrosstalkResults, platform: Platform, qubit: QubitId): +def _update( + results: QubitCrosstalkResults, platform: CalibrationPlatform, qubit: QubitId +): """Update crosstalk matrix.""" for flux_qubit, element in results.crosstalk_matrix[qubit].items(): diff --git a/src/qibocal/protocols/flux_dependence/qubit_flux_dependence.py b/src/qibocal/protocols/flux_dependence/qubit_flux_dependence.py index eb9e2f64f..81eb12720 100644 --- a/src/qibocal/protocols/flux_dependence/qubit_flux_dependence.py +++ b/src/qibocal/protocols/flux_dependence/qubit_flux_dependence.py @@ -8,13 +8,13 @@ AveragingMode, Delay, Parameter, - Platform, PulseSequence, Sweeper, ) from scipy.optimize import curve_fit from qibocal.auto.operation import Data, QubitId, Results, Routine +from qibocal.calibration import CalibrationPlatform from qibocal.config import log from qibocal.result import magnitude, phase from qibocal.update import replace @@ -83,7 +83,7 @@ def register_qubit(self, qubit, freq, bias, signal, phase): def _acquisition( params: QubitFluxParameters, - platform: Platform, + platform: CalibrationPlatform, targets: list[QubitId], ) -> QubitFluxData: """Data acquisition for QubitFlux Experiment.""" @@ -271,7 +271,7 @@ def _plot(data: QubitFluxData, fit: QubitFluxResults, target: QubitId): return figures, "" -def _update(results: QubitFluxResults, platform: Platform, qubit: QubitId): +def _update(results: QubitFluxResults, platform: CalibrationPlatform, qubit: QubitId): update.drive_frequency(results.frequency[qubit], platform, qubit) update.sweetspot(results.sweetspot[qubit], platform, qubit) update.flux_offset(results.sweetspot[qubit], platform, qubit) diff --git a/src/qibocal/protocols/flux_dependence/resonator_flux_dependence.py b/src/qibocal/protocols/flux_dependence/resonator_flux_dependence.py index a680aaccb..3766e3bdc 100644 --- a/src/qibocal/protocols/flux_dependence/resonator_flux_dependence.py +++ b/src/qibocal/protocols/flux_dependence/resonator_flux_dependence.py @@ -3,16 +3,11 @@ import numpy as np import numpy.typing as npt -from qibolab import ( - AcquisitionType, - AveragingMode, - Parameter, - Platform, - PulseSequence, - Sweeper, -) +from qibolab import AcquisitionType, AveragingMode, Parameter, PulseSequence, Sweeper from scipy.optimize import curve_fit +from qibocal.calibration import CalibrationPlatform + from ... import update from ...auto.operation import Data, Parameters, QubitId, Results, Routine from ...config import log @@ -87,7 +82,9 @@ def register_qubit(self, qubit, freq, bias, signal, phase): def _acquisition( - params: ResonatorFluxParameters, platform: Platform, targets: list[QubitId] + params: ResonatorFluxParameters, + platform: CalibrationPlatform, + targets: list[QubitId], ) -> ResonatorFluxData: """Data acquisition for ResonatorFlux experiment.""" @@ -297,7 +294,9 @@ def _plot(data: ResonatorFluxData, fit: ResonatorFluxResults, target: QubitId): return figures, "" -def _update(results: ResonatorFluxResults, platform: Platform, qubit: QubitId): +def _update( + results: ResonatorFluxResults, platform: CalibrationPlatform, qubit: QubitId +): update.dressed_resonator_frequency(results.resonator_freq[qubit], platform, qubit) update.readout_frequency(results.resonator_freq[qubit], platform, qubit) update.coupling(results.coupling[qubit], platform, qubit) diff --git a/src/qibocal/protocols/qubit_power_spectroscopy.py b/src/qibocal/protocols/qubit_power_spectroscopy.py index 7cec117ec..0380d9295 100644 --- a/src/qibocal/protocols/qubit_power_spectroscopy.py +++ b/src/qibocal/protocols/qubit_power_spectroscopy.py @@ -9,12 +9,12 @@ AveragingMode, Delay, Parameter, - Platform, PulseSequence, Sweeper, ) from qibocal.auto.operation import Parameters, QubitId, Results, Routine +from qibocal.calibration import CalibrationPlatform from ..result import magnitude, phase from ..update import replace @@ -48,7 +48,7 @@ class QubitPowerSpectroscopyData(ResonatorPunchoutData): def _acquisition( params: QubitPowerSpectroscopyParameters, - platform: Platform, + platform: CalibrationPlatform, targets: list[QubitId], ) -> QubitPowerSpectroscopyData: """Perform a qubit spectroscopy experiment with different amplitudes. diff --git a/src/qibocal/protocols/qubit_spectroscopy.py b/src/qibocal/protocols/qubit_spectroscopy.py index b27066acf..7362de178 100644 --- a/src/qibocal/protocols/qubit_spectroscopy.py +++ b/src/qibocal/protocols/qubit_spectroscopy.py @@ -2,9 +2,10 @@ from typing import Optional import numpy as np -from qibolab import Delay, Parameter, Platform, PulseSequence, Sweeper +from qibolab import Delay, Parameter, PulseSequence, Sweeper from qibocal.auto.operation import Parameters, QubitId, Results, Routine +from qibocal.calibration import CalibrationPlatform from qibocal.result import magnitude, phase from qibocal.update import replace @@ -52,7 +53,9 @@ class QubitSpectroscopyData(ResonatorSpectroscopyData): def _acquisition( - params: QubitSpectroscopyParameters, platform: Platform, targets: list[QubitId] + params: QubitSpectroscopyParameters, + platform: CalibrationPlatform, + targets: list[QubitId], ) -> QubitSpectroscopyData: """Data acquisition for qubit spectroscopy.""" # create a sequence of pulses for the experiment: @@ -170,7 +173,9 @@ def _plot(data: QubitSpectroscopyData, target: QubitId, fit: QubitSpectroscopyRe return spectroscopy_plot(data, target, fit) -def _update(results: QubitSpectroscopyResults, platform: Platform, target: QubitId): +def _update( + results: QubitSpectroscopyResults, platform: CalibrationPlatform, target: QubitId +): platform.calibration.single_qubits[target].qubit.frequency_01 = results.frequency[ target ] diff --git a/src/qibocal/protocols/qubit_spectroscopy_ef.py b/src/qibocal/protocols/qubit_spectroscopy_ef.py index 241179265..1ee1b65c8 100644 --- a/src/qibocal/protocols/qubit_spectroscopy_ef.py +++ b/src/qibocal/protocols/qubit_spectroscopy_ef.py @@ -1,9 +1,10 @@ from dataclasses import asdict, dataclass, field import numpy as np -from qibolab import Delay, Parameter, Platform, PulseSequence, Sweeper +from qibolab import Delay, Parameter, PulseSequence, Sweeper from qibocal.auto.operation import QubitId, Routine +from qibocal.calibration import CalibrationPlatform from qibocal.update import replace from .. import update @@ -49,7 +50,9 @@ def fit_ef(data: QubitSpectroscopyEFData) -> QubitSpectroscopyEFResults: def _acquisition( - params: QubitSpectroscopyEFParameters, platform: Platform, targets: list[QubitId] + params: QubitSpectroscopyEFParameters, + platform: CalibrationPlatform, + targets: list[QubitId], ) -> QubitSpectroscopyEFData: """Data acquisition for qubit spectroscopy ef protocol. @@ -194,7 +197,9 @@ def _plot( return figures, report -def _update(results: QubitSpectroscopyEFResults, platform: Platform, target: QubitId): +def _update( + results: QubitSpectroscopyEFResults, platform: CalibrationPlatform, target: QubitId +): """Update w12 frequency""" update.frequency_12_transition(results.frequency[target], platform, target) platform.calibration.single_qubits[target].qubit.frequency_12 = results.frequency[ diff --git a/src/qibocal/protocols/qutrit_classification.py b/src/qibocal/protocols/qutrit_classification.py index f61e5fc36..e72f6315f 100644 --- a/src/qibocal/protocols/qutrit_classification.py +++ b/src/qibocal/protocols/qutrit_classification.py @@ -1,9 +1,10 @@ from dataclasses import dataclass, field from typing import Optional -from qibolab import AcquisitionType, Platform, PulseSequence +from qibolab import AcquisitionType, PulseSequence from qibocal.auto.operation import QubitId, Routine +from qibocal.calibration import CalibrationPlatform from qibocal.protocols.classification import ( ClassificationType, SingleShotClassificationData, @@ -41,7 +42,7 @@ class QutritClassificationResults(Results): def _acquisition( params: QutritClassificationParameters, - platform: Platform, + platform: CalibrationPlatform, targets: list[QubitId], ) -> QutritClassificationData: """ diff --git a/src/qibocal/protocols/rabi/amplitude.py b/src/qibocal/protocols/rabi/amplitude.py index 1cd6ddda0..9907b6f52 100644 --- a/src/qibocal/protocols/rabi/amplitude.py +++ b/src/qibocal/protocols/rabi/amplitude.py @@ -2,10 +2,11 @@ import numpy as np import numpy.typing as npt -from qibolab import AcquisitionType, AveragingMode, Parameter, Platform, Sweeper +from qibolab import AcquisitionType, AveragingMode, Parameter, Sweeper from qibocal import update from qibocal.auto.operation import Data, QubitId, Routine +from qibocal.calibration import CalibrationPlatform from qibocal.config import log from qibocal.result import probability @@ -43,7 +44,9 @@ class RabiAmplitudeData(Data): def _acquisition( - params: RabiAmplitudeParameters, platform: Platform, targets: list[QubitId] + params: RabiAmplitudeParameters, + platform: CalibrationPlatform, + targets: list[QubitId], ) -> RabiAmplitudeData: r""" Data acquisition for Rabi experiment sweeping amplitude. @@ -133,7 +136,9 @@ def _plot(data: RabiAmplitudeData, target: QubitId, fit: RabiAmplitudeResults = return utils.plot_probabilities(data, target, fit) -def _update(results: RabiAmplitudeResults, platform: Platform, target: QubitId): +def _update( + results: RabiAmplitudeResults, platform: CalibrationPlatform, target: QubitId +): update.drive_amplitude(results.amplitude[target], platform, target) update.drive_duration(results.length[target], platform, target) diff --git a/src/qibocal/protocols/rabi/amplitude_frequency.py b/src/qibocal/protocols/rabi/amplitude_frequency.py index b97d8be76..8f060b583 100644 --- a/src/qibocal/protocols/rabi/amplitude_frequency.py +++ b/src/qibocal/protocols/rabi/amplitude_frequency.py @@ -6,9 +6,10 @@ import numpy.typing as npt import plotly.graph_objects as go from plotly.subplots import make_subplots -from qibolab import AcquisitionType, AveragingMode, Parameter, Platform, Sweeper +from qibolab import AcquisitionType, AveragingMode, Parameter, Sweeper from qibocal.auto.operation import QubitId, Routine +from qibocal.calibration import CalibrationPlatform from qibocal.config import log from qibocal.protocols.utils import ( HZ_TO_GHZ, @@ -72,7 +73,9 @@ def register_qubit(self, qubit, freq, amp, prob, error): def _acquisition( - params: RabiAmplitudeFrequencyParameters, platform: Platform, targets: list[QubitId] + params: RabiAmplitudeFrequencyParameters, + platform: CalibrationPlatform, + targets: list[QubitId], ) -> RabiAmplitudeFreqData: """Data acquisition for Rabi experiment sweeping amplitude.""" diff --git a/src/qibocal/protocols/rabi/amplitude_frequency_signal.py b/src/qibocal/protocols/rabi/amplitude_frequency_signal.py index e36a7f7e8..5314d6bf6 100644 --- a/src/qibocal/protocols/rabi/amplitude_frequency_signal.py +++ b/src/qibocal/protocols/rabi/amplitude_frequency_signal.py @@ -7,10 +7,11 @@ import numpy.typing as npt import plotly.graph_objects as go from plotly.subplots import make_subplots -from qibolab import AcquisitionType, AveragingMode, Parameter, Platform, Sweeper +from qibolab import AcquisitionType, AveragingMode, Parameter, Sweeper from qibocal import update from qibocal.auto.operation import Data, Parameters, QubitId, Routine +from qibocal.calibration import CalibrationPlatform from qibocal.config import log from qibocal.protocols.utils import ( HZ_TO_GHZ, @@ -97,7 +98,7 @@ def frequencies(self, qubit): def _acquisition( params: RabiAmplitudeFrequencySignalParameters, - platform: Platform, + platform: CalibrationPlatform, targets: list[QubitId], ) -> RabiAmplitudeFreqSignalData: """Data acquisition for Rabi experiment sweeping amplitude.""" @@ -290,7 +291,9 @@ def _plot( def _update( - results: RabiAmplitudeFrequencySignalResults, platform: Platform, target: QubitId + results: RabiAmplitudeFrequencySignalResults, + platform: CalibrationPlatform, + target: QubitId, ): update.drive_duration(results.length[target], platform, target) update.drive_amplitude(results.amplitude[target], platform, target) diff --git a/src/qibocal/protocols/rabi/amplitude_signal.py b/src/qibocal/protocols/rabi/amplitude_signal.py index 76bbbeab6..5b23f46cb 100644 --- a/src/qibocal/protocols/rabi/amplitude_signal.py +++ b/src/qibocal/protocols/rabi/amplitude_signal.py @@ -3,10 +3,11 @@ import numpy as np import numpy.typing as npt -from qibolab import AcquisitionType, AveragingMode, Parameter, Platform, Sweeper +from qibolab import AcquisitionType, AveragingMode, Parameter, Sweeper from qibocal import update from qibocal.auto.operation import Data, Parameters, QubitId, Results, Routine +from qibocal.calibration import CalibrationPlatform from qibocal.config import log from qibocal.protocols.utils import fallback_period, guess_period from qibocal.result import magnitude, phase @@ -57,7 +58,9 @@ class RabiAmplitudeSignalData(Data): def _acquisition( - params: RabiAmplitudeSignalParameters, platform: Platform, targets: list[QubitId] + params: RabiAmplitudeSignalParameters, + platform: CalibrationPlatform, + targets: list[QubitId], ) -> RabiAmplitudeSignalData: r""" Data acquisition for Rabi experiment sweeping amplitude. @@ -152,7 +155,9 @@ def _plot( return utils.plot(data, target, fit) -def _update(results: RabiAmplitudeSignalResults, platform: Platform, target: QubitId): +def _update( + results: RabiAmplitudeSignalResults, platform: CalibrationPlatform, target: QubitId +): update.drive_amplitude(results.amplitude[target], platform, target) update.drive_duration(results.length[target], platform, target) diff --git a/src/qibocal/protocols/rabi/ef.py b/src/qibocal/protocols/rabi/ef.py index b69220c75..9774e42a7 100644 --- a/src/qibocal/protocols/rabi/ef.py +++ b/src/qibocal/protocols/rabi/ef.py @@ -5,12 +5,12 @@ AveragingMode, Delay, Parameter, - Platform, PulseSequence, Sweeper, ) from qibocal.auto.operation import QubitId, Routine +from qibocal.calibration import CalibrationPlatform from qibocal.update import replace from ... import update @@ -34,7 +34,9 @@ class RabiAmplitudeEFData(amplitude_signal.RabiAmplitudeSignalData): def _acquisition( - params: RabiAmplitudeEFParameters, platform: Platform, targets: list[QubitId] + params: RabiAmplitudeEFParameters, + platform: CalibrationPlatform, + targets: list[QubitId], ) -> RabiAmplitudeEFData: r""" Data acquisition for Rabi EF experiment sweeping amplitude. @@ -118,7 +120,9 @@ def _plot( return figures, report -def _update(results: RabiAmplitudeEFResults, platform: Platform, target: QubitId): +def _update( + results: RabiAmplitudeEFResults, platform: CalibrationPlatform, target: QubitId +): """Update RX2 amplitude_signal""" update.drive_12_amplitude(results.amplitude[target], platform, target) update.drive_12_duration(results.length[target], platform, target) diff --git a/src/qibocal/protocols/rabi/length.py b/src/qibocal/protocols/rabi/length.py index e116153bd..d0921ba12 100644 --- a/src/qibocal/protocols/rabi/length.py +++ b/src/qibocal/protocols/rabi/length.py @@ -3,10 +3,11 @@ import numpy as np import numpy.typing as npt -from qibolab import AcquisitionType, AveragingMode, Parameter, Platform, Sweeper +from qibolab import AcquisitionType, AveragingMode, Parameter, Sweeper from qibocal import update from qibocal.auto.operation import Parameters, QubitId, Routine +from qibocal.calibration import CalibrationPlatform from qibocal.config import log from qibocal.protocols.rabi.length_signal import ( RabiLengthSignalData, @@ -56,7 +57,7 @@ class RabiLengthData(RabiLengthSignalData): def _acquisition( - params: RabiLengthParameters, platform: Platform, targets: list[QubitId] + params: RabiLengthParameters, platform: CalibrationPlatform, targets: list[QubitId] ) -> RabiLengthData: r""" Data acquisition for RabiLength Experiment. @@ -157,7 +158,7 @@ def _fit(data: RabiLengthData) -> RabiLengthResults: return RabiLengthResults(durations, amplitudes, fitted_parameters, chi2) -def _update(results: RabiLengthResults, platform: Platform, target: QubitId): +def _update(results: RabiLengthResults, platform: CalibrationPlatform, target: QubitId): update.drive_duration(results.length[target], platform, target) update.drive_amplitude(results.amplitude[target], platform, target) diff --git a/src/qibocal/protocols/rabi/length_frequency.py b/src/qibocal/protocols/rabi/length_frequency.py index 6a680d153..536aeb245 100644 --- a/src/qibocal/protocols/rabi/length_frequency.py +++ b/src/qibocal/protocols/rabi/length_frequency.py @@ -6,9 +6,10 @@ import numpy.typing as npt import plotly.graph_objects as go from plotly.subplots import make_subplots -from qibolab import AcquisitionType, AveragingMode, Parameter, Platform, Sweeper +from qibolab import AcquisitionType, AveragingMode, Parameter, Sweeper from qibocal.auto.operation import QubitId, Routine +from qibocal.calibration import CalibrationPlatform from qibocal.config import log from qibocal.protocols.utils import table_dict, table_html @@ -66,7 +67,9 @@ def register_qubit(self, qubit, freq, lens, prob, error): def _acquisition( - params: RabiLengthFrequencyParameters, platform: Platform, targets: list[QubitId] + params: RabiLengthFrequencyParameters, + platform: CalibrationPlatform, + targets: list[QubitId], ) -> RabiLengthFreqData: """Data acquisition for Rabi experiment sweeping length.""" diff --git a/src/qibocal/protocols/rabi/length_frequency_signal.py b/src/qibocal/protocols/rabi/length_frequency_signal.py index 997cfa695..93bb7dbfa 100644 --- a/src/qibocal/protocols/rabi/length_frequency_signal.py +++ b/src/qibocal/protocols/rabi/length_frequency_signal.py @@ -7,10 +7,11 @@ import numpy.typing as npt import plotly.graph_objects as go from plotly.subplots import make_subplots -from qibolab import AcquisitionType, AveragingMode, Parameter, Platform, Sweeper +from qibolab import AcquisitionType, AveragingMode, Parameter, Sweeper from qibocal import update from qibocal.auto.operation import Data, Parameters, QubitId, Routine +from qibocal.calibration import CalibrationPlatform from qibocal.config import log from qibocal.protocols.utils import table_dict, table_html @@ -94,7 +95,7 @@ def frequencies(self, qubit): def _acquisition( params: RabiLengthFrequencySignalParameters, - platform: Platform, + platform: CalibrationPlatform, targets: list[QubitId], ) -> RabiLengthFreqSignalData: """Data acquisition for Rabi experiment sweeping length.""" @@ -300,7 +301,9 @@ def _plot( def _update( - results: RabiLengthFrequencySignalResults, platform: Platform, target: QubitId + results: RabiLengthFrequencySignalResults, + platform: CalibrationPlatform, + target: QubitId, ): update.drive_amplitude(results.amplitude[target], platform, target) update.drive_duration(results.length[target], platform, target) diff --git a/src/qibocal/protocols/rabi/length_signal.py b/src/qibocal/protocols/rabi/length_signal.py index 8a6107341..94572de16 100644 --- a/src/qibocal/protocols/rabi/length_signal.py +++ b/src/qibocal/protocols/rabi/length_signal.py @@ -3,10 +3,11 @@ import numpy as np import numpy.typing as npt -from qibolab import AcquisitionType, AveragingMode, Parameter, Platform, Sweeper +from qibolab import AcquisitionType, AveragingMode, Parameter, Sweeper from qibocal import update from qibocal.auto.operation import Data, Parameters, QubitId, Results, Routine +from qibocal.calibration import CalibrationPlatform from qibocal.config import log from qibocal.protocols.utils import fallback_period, guess_period from qibocal.result import magnitude, phase @@ -59,7 +60,9 @@ class RabiLengthSignalData(Data): def _acquisition( - params: RabiLengthSignalParameters, platform: Platform, targets: list[QubitId] + params: RabiLengthSignalParameters, + platform: CalibrationPlatform, + targets: list[QubitId], ) -> RabiLengthSignalData: r""" Data acquisition for RabiLength Experiment. @@ -153,7 +156,9 @@ def _fit(data: RabiLengthSignalData) -> RabiLengthSignalResults: return RabiLengthSignalResults(durations, data.amplitudes, fitted_parameters) -def _update(results: RabiLengthSignalResults, platform: Platform, target: QubitId): +def _update( + results: RabiLengthSignalResults, platform: CalibrationPlatform, target: QubitId +): update.drive_duration(results.length[target], platform, target) update.drive_amplitude(results.amplitude[target], platform, target) diff --git a/src/qibocal/protocols/ramsey/ramsey.py b/src/qibocal/protocols/ramsey/ramsey.py index 4d6de0668..0b9ca57bc 100644 --- a/src/qibocal/protocols/ramsey/ramsey.py +++ b/src/qibocal/protocols/ramsey/ramsey.py @@ -4,16 +4,10 @@ import numpy as np import numpy.typing as npt import plotly.graph_objects as go -from qibolab import ( - AcquisitionType, - AveragingMode, - Parameter, - Platform, - Readout, - Sweeper, -) +from qibolab import AcquisitionType, AveragingMode, Parameter, Readout, Sweeper from qibocal.auto.operation import QubitId, Routine +from qibocal.calibration import CalibrationPlatform from qibocal.config import log from qibocal.result import probability @@ -59,7 +53,7 @@ class RamseyData(RamseySignalData): def _acquisition( params: RamseyParameters, - platform: Platform, + platform: CalibrationPlatform, targets: list[QubitId], ) -> RamseyData: """Data acquisition for Ramsey Experiment (detuned). diff --git a/src/qibocal/protocols/ramsey/ramsey_signal.py b/src/qibocal/protocols/ramsey/ramsey_signal.py index 3d16f89a1..58dd26ba3 100644 --- a/src/qibocal/protocols/ramsey/ramsey_signal.py +++ b/src/qibocal/protocols/ramsey/ramsey_signal.py @@ -4,16 +4,10 @@ import numpy as np import numpy.typing as npt import plotly.graph_objects as go -from qibolab import ( - AcquisitionType, - AveragingMode, - Parameter, - Platform, - Readout, - Sweeper, -) +from qibolab import AcquisitionType, AveragingMode, Parameter, Readout, Sweeper from qibocal.auto.operation import Data, Parameters, QubitId, Results, Routine +from qibocal.calibration import CalibrationPlatform from qibocal.config import log from qibocal.result import magnitude @@ -85,7 +79,7 @@ def waits(self): def _acquisition( params: RamseySignalParameters, - platform: Platform, + platform: CalibrationPlatform, targets: list[QubitId], ) -> RamseySignalData: """Data acquisition for Ramsey Experiment (detuned).""" @@ -296,7 +290,9 @@ def _plot(data: RamseySignalData, target: QubitId, fit: RamseySignalResults = No return figures, fitting_report -def _update(results: RamseySignalResults, platform: Platform, target: QubitId): +def _update( + results: RamseySignalResults, platform: CalibrationPlatform, target: QubitId +): if results.detuning is not None: update.drive_frequency(results.frequency[target][0], platform, target) else: diff --git a/src/qibocal/protocols/ramsey/ramsey_zz.py b/src/qibocal/protocols/ramsey/ramsey_zz.py index d93b92c0e..021951e26 100644 --- a/src/qibocal/protocols/ramsey/ramsey_zz.py +++ b/src/qibocal/protocols/ramsey/ramsey_zz.py @@ -4,14 +4,9 @@ import numpy as np import numpy.typing as npt import plotly.graph_objects as go -from qibolab import ( - AcquisitionType, - AveragingMode, - Parameter, - Platform, - Readout, - Sweeper, -) +from qibolab import AcquisitionType, AveragingMode, Parameter, Readout, Sweeper + +from qibocal.calibration import CalibrationPlatform from ...auto.operation import QubitId, Routine from ...config import log @@ -64,7 +59,7 @@ class RamseyZZData(RamseySignalData): def _acquisition( params: RamseyZZParameters, - platform: Platform, + platform: CalibrationPlatform, targets: list[QubitId], ) -> RamseyZZData: """Data acquisition for RamseyZZ Experiment. diff --git a/src/qibocal/protocols/randomized_benchmarking/filtered_rb.py b/src/qibocal/protocols/randomized_benchmarking/filtered_rb.py index fcb5d2a7a..4bc1b35b2 100644 --- a/src/qibocal/protocols/randomized_benchmarking/filtered_rb.py +++ b/src/qibocal/protocols/randomized_benchmarking/filtered_rb.py @@ -2,9 +2,9 @@ import numpy as np import plotly.graph_objects as go -from qibolab import Platform from qibocal.auto.operation import QubitId, Results, Routine +from qibocal.calibration import CalibrationPlatform from qibocal.protocols.randomized_benchmarking.utils import rb_acquisition from qibocal.protocols.utils import table_dict, table_html @@ -23,7 +23,7 @@ class FilteredRBResult(Results): def _acquisition( params: FilteredRBParameters, - platform: Platform, + platform: CalibrationPlatform, targets: list[QubitId], ) -> RBData: """The data acquisition stage of Filtered Randomized Benchmarking. @@ -34,7 +34,7 @@ def _acquisition( Args: params : All parameters in one object. - platform : Platform the experiment is executed on. + platform : CalibrationPlatform the experiment is executed on. target : list of qubits the experiment is executed on. Returns: diff --git a/src/qibocal/protocols/randomized_benchmarking/standard_rb.py b/src/qibocal/protocols/randomized_benchmarking/standard_rb.py index 14b388a48..5b265d134 100644 --- a/src/qibocal/protocols/randomized_benchmarking/standard_rb.py +++ b/src/qibocal/protocols/randomized_benchmarking/standard_rb.py @@ -3,9 +3,9 @@ import numpy as np import plotly.graph_objects as go -from qibolab import Platform from qibocal.auto.operation import Parameters, QubitId, Routine +from qibocal.calibration import CalibrationPlatform from ..utils import table_dict, table_html from .fitting import exp1B_func @@ -69,7 +69,7 @@ def __post_init__(self): def _acquisition( params: StandardRBParameters, - platform: Platform, + platform: CalibrationPlatform, targets: list[QubitId], ) -> RBData: """The data acquisition stage of Standard Randomized Benchmarking. @@ -80,7 +80,7 @@ def _acquisition( Args: params: All parameters in one object. - platform: Platform the experiment is executed on. + platform: CalibrationPlatform the experiment is executed on. target: list of qubits the experiment is executed on. Returns: @@ -224,7 +224,7 @@ def _plot( return [fig], fitting_report -def _update(results: StandardRBResult, platform: Platform, target: QubitId): +def _update(results: StandardRBResult, platform: CalibrationPlatform, target: QubitId): """Write rb fidelity in calibration.""" # TODO: shall we use the gate fidelity or the pulse fidelity diff --git a/src/qibocal/protocols/randomized_benchmarking/standard_rb_2q.py b/src/qibocal/protocols/randomized_benchmarking/standard_rb_2q.py index 104223c47..46c4544c5 100644 --- a/src/qibocal/protocols/randomized_benchmarking/standard_rb_2q.py +++ b/src/qibocal/protocols/randomized_benchmarking/standard_rb_2q.py @@ -1,8 +1,7 @@ from dataclasses import dataclass -from qibolab import Platform - from qibocal.auto.operation import QubitPairId, Routine +from qibocal.calibration import CalibrationPlatform from qibocal.protocols.randomized_benchmarking.standard_rb import ( StandardRBParameters, _plot, @@ -27,7 +26,7 @@ class StandardRB2QParameters(StandardRBParameters): def _acquisition( params: StandardRB2QParameters, - platform: Platform, + platform: CalibrationPlatform, targets: list[QubitPairId], ) -> RB2QData: """Data acquisition for two qubit Standard Randomized Benchmarking.""" @@ -42,7 +41,9 @@ def _fit(data: RB2QData) -> StandardRBResult: return results -def _update(results: StandardRBResult, platform: Platform, target: QubitPairId): +def _update( + results: StandardRBResult, platform: CalibrationPlatform, target: QubitPairId +): """Write rb fidelity in calibration.""" # FIXME: error raised by qq fit if isinstance(target, list): diff --git a/src/qibocal/protocols/randomized_benchmarking/standard_rb_2q_inter.py b/src/qibocal/protocols/randomized_benchmarking/standard_rb_2q_inter.py index f9e51adc3..6d59cda92 100644 --- a/src/qibocal/protocols/randomized_benchmarking/standard_rb_2q_inter.py +++ b/src/qibocal/protocols/randomized_benchmarking/standard_rb_2q_inter.py @@ -1,9 +1,9 @@ from dataclasses import dataclass, fields import numpy as np -from qibolab import Platform from qibocal.auto.operation import QubitPairId, Routine +from qibocal.calibration import CalibrationPlatform from qibocal.protocols.randomized_benchmarking.standard_rb import _plot from qibocal.protocols.randomized_benchmarking.standard_rb_2q import ( StandardRB2QParameters, @@ -40,7 +40,7 @@ def __contains__(self, value: QubitPairId): def _acquisition( params: StandardRB2QInterParameters, - platform: Platform, + platform: CalibrationPlatform, targets: list[QubitPairId], ) -> RB2QInterData: """Data acquisition for two qubit Interleaved Randomized Benchmarking.""" @@ -93,7 +93,9 @@ def _fit(data: RB2QInterData) -> StandardRB2QInterResult: ) -def _update(results: StandardRBResult, platform: Platform, target: QubitPairId): +def _update( + results: StandardRBResult, platform: CalibrationPlatform, target: QubitPairId +): """Write cz fidelity in calibration.""" # TODO: shall we use the gate fidelity or the pulse fidelity platform.calibration.two_qubits[target].cz_fidelity = tuple( diff --git a/src/qibocal/protocols/randomized_benchmarking/utils.py b/src/qibocal/protocols/randomized_benchmarking/utils.py index e6b67af75..a10188171 100644 --- a/src/qibocal/protocols/randomized_benchmarking/utils.py +++ b/src/qibocal/protocols/randomized_benchmarking/utils.py @@ -10,7 +10,6 @@ from qibo.backends import GlobalBackend from qibo.config import raise_error from qibo.models import Circuit -from qibolab import Platform from qibocal.auto.operation import Data, Parameters, QubitId, QubitPairId, Results from qibocal.auto.transpile import ( @@ -18,6 +17,7 @@ execute_transpiled_circuit, execute_transpiled_circuits, ) +from qibocal.calibration import CalibrationPlatform from qibocal.config import raise_error from qibocal.protocols.randomized_benchmarking import noisemodels from qibocal.protocols.randomized_benchmarking.dict_utils import ( @@ -335,7 +335,7 @@ class StandardRBResult(Results): def setup( params: Parameters, - platform: Platform, + platform: CalibrationPlatform, single_qubit: bool = True, interleave: Optional[str] = None, ): @@ -484,7 +484,7 @@ def execute_circuits(circuits, targets, params, backend, single_qubit=True): def rb_acquisition( params: Parameters, - platform: Platform, + platform: CalibrationPlatform, targets: list[QubitId], add_inverse_layer: bool = True, interleave: str = None, @@ -531,7 +531,7 @@ def rb_acquisition( def twoq_rb_acquisition( params: Parameters, - platform: Platform, + platform: CalibrationPlatform, targets: list[QubitPairId], add_inverse_layer: bool = True, interleave: str = None, diff --git a/src/qibocal/protocols/readout_characterization.py b/src/qibocal/protocols/readout_characterization.py index c2dd96c42..d2f32befd 100644 --- a/src/qibocal/protocols/readout_characterization.py +++ b/src/qibocal/protocols/readout_characterization.py @@ -4,10 +4,11 @@ import numpy.typing as npt import plotly.graph_objects as go from plotly.subplots import make_subplots -from qibolab import AcquisitionType, Delay, Platform, PulseSequence, Readout +from qibolab import AcquisitionType, Delay, PulseSequence, Readout from qibocal import update from qibocal.auto.operation import Data, Parameters, QubitId, Results, Routine +from qibocal.calibration import CalibrationPlatform from qibocal.protocols.utils import ( effective_qubit_temperature, format_error_single_cell, @@ -73,7 +74,7 @@ class ReadoutCharacterizationData(Data): def _acquisition( params: ReadoutCharacterizationParameters, - platform: Platform, + platform: CalibrationPlatform, targets: list[QubitId], ) -> ReadoutCharacterizationData: """Data acquisition for resonator spectroscopy.""" @@ -313,7 +314,9 @@ def _plot( def _update( - results: ReadoutCharacterizationResults, platform: Platform, target: QubitId + results: ReadoutCharacterizationResults, + platform: CalibrationPlatform, + target: QubitId, ): update.readout_fidelity(results.fidelity[target], platform, target) platform.calibration.single_qubits[target].readout.effective_temperature = ( diff --git a/src/qibocal/protocols/readout_mitigation_matrix.py b/src/qibocal/protocols/readout_mitigation_matrix.py index 0d5b9e2de..780d08d7d 100644 --- a/src/qibocal/protocols/readout_mitigation_matrix.py +++ b/src/qibocal/protocols/readout_mitigation_matrix.py @@ -7,11 +7,12 @@ from qibo import gates from qibo.backends import GlobalBackend from qibo.models import Circuit -from qibolab import Platform, PulseSequence +from qibolab import PulseSequence from scipy.sparse import lil_matrix from qibocal.auto.operation import Data, Parameters, QubitId, Results, Routine from qibocal.auto.transpile import dummy_transpiler, execute_transpiled_circuit +from qibocal.calibration import CalibrationPlatform from qibocal.config import log from .utils import calculate_frequencies, computational_basis @@ -108,7 +109,7 @@ def matrix(self, qubits: list[QubitId]): def _acquisition( params: ReadoutMitigationMatrixParameters, - platform: Platform, + platform: CalibrationPlatform, targets: list[list[QubitId]], ) -> ReadoutMitigationMatrixData: data = ReadoutMitigationMatrixData( @@ -197,7 +198,9 @@ def _plot( def _update( - results: ReadoutMitigationMatrixData, platform: Platform, target: list[QubitId] + results: ReadoutMitigationMatrixData, + platform: CalibrationPlatform, + target: list[QubitId], ): # create empty matrix if it doesn't exist if platform.calibration.readout_mitigation_matrix is None: diff --git a/src/qibocal/protocols/readout_optimization/resonator_amplitude.py b/src/qibocal/protocols/readout_optimization/resonator_amplitude.py index ea814769c..ab054220d 100644 --- a/src/qibocal/protocols/readout_optimization/resonator_amplitude.py +++ b/src/qibocal/protocols/readout_optimization/resonator_amplitude.py @@ -5,10 +5,11 @@ import numpy.typing as npt import plotly.graph_objects as go from plotly.subplots import make_subplots -from qibolab import AcquisitionType, Delay, Platform, PulseSequence +from qibolab import AcquisitionType, Delay, PulseSequence from qibocal import update from qibocal.auto.operation import Data, Parameters, QubitId, Results, Routine +from qibocal.calibration import CalibrationPlatform from qibocal.fitting.classifier.qubit_fit import QubitFit from qibocal.protocols.utils import table_dict, table_html from qibocal.update import replace @@ -62,7 +63,7 @@ class ResonatorAmplitudeResults(Results): def _acquisition( params: ResonatorAmplitudeParameters, - platform: Platform, + platform: CalibrationPlatform, targets: list[QubitId], ) -> ResonatorAmplitudeData: r""" @@ -73,7 +74,7 @@ def _acquisition( Args: params (:class:`ResonatorAmplitudeParameters`): input parameters - platform (:class:`Platform`): Qibolab's platform + platform (:class:`CalibrationPlatform`): Qibolab's platform targets (list): list of QubitIds to be characterized Returns: @@ -197,7 +198,9 @@ def _plot( return figures, fitting_report -def _update(results: ResonatorAmplitudeResults, platform: Platform, target: QubitId): +def _update( + results: ResonatorAmplitudeResults, platform: CalibrationPlatform, target: QubitId +): update.readout_amplitude(results.best_amp[target], platform, target) update.iq_angle(results.best_angle[target], platform, target) update.threshold(results.best_threshold[target], platform, target) diff --git a/src/qibocal/protocols/resonator_punchout.py b/src/qibocal/protocols/resonator_punchout.py index c8beab0e6..8996eb80d 100644 --- a/src/qibocal/protocols/resonator_punchout.py +++ b/src/qibocal/protocols/resonator_punchout.py @@ -5,17 +5,11 @@ import numpy.typing as npt import plotly.graph_objects as go from plotly.subplots import make_subplots -from qibolab import ( - AcquisitionType, - AveragingMode, - Parameter, - Platform, - PulseSequence, - Sweeper, -) +from qibolab import AcquisitionType, AveragingMode, Parameter, PulseSequence, Sweeper from qibocal import update from qibocal.auto.operation import Data, Parameters, QubitId, Results, Routine +from qibocal.calibration import CalibrationPlatform from qibocal.result import magnitude, phase from .utils import HZ_TO_GHZ, fit_punchout, norm, table_dict, table_html @@ -85,7 +79,7 @@ def register_qubit(self, qubit, freq, amp, signal, phase): def _acquisition( params: ResonatorPunchoutParameters, - platform: Platform, + platform: CalibrationPlatform, targets: list[QubitId], ) -> ResonatorPunchoutData: """Data acquisition for Punchout over amplitude.""" @@ -256,7 +250,9 @@ def _plot( return figures, fitting_report -def _update(results: ResonatorPunchoutResults, platform: Platform, target: QubitId): +def _update( + results: ResonatorPunchoutResults, platform: CalibrationPlatform, target: QubitId +): update.readout_frequency(results.readout_frequency[target], platform, target) update.bare_resonator_frequency(results.bare_frequency[target], platform, target) update.dressed_resonator_frequency( diff --git a/src/qibocal/protocols/resonator_spectroscopy.py b/src/qibocal/protocols/resonator_spectroscopy.py index 66b683c94..a0e48a923 100644 --- a/src/qibocal/protocols/resonator_spectroscopy.py +++ b/src/qibocal/protocols/resonator_spectroscopy.py @@ -5,17 +5,11 @@ import numpy as np import numpy.typing as npt from _collections_abc import Callable -from qibolab import ( - AcquisitionType, - AveragingMode, - Parameter, - Platform, - PulseSequence, - Sweeper, -) +from qibolab import AcquisitionType, AveragingMode, Parameter, PulseSequence, Sweeper from qibocal import update from qibocal.auto.operation import Data, Parameters, QubitId, Results, Routine +from qibocal.calibration import CalibrationPlatform from qibocal.result import magnitude, phase from qibocal.update import replace @@ -169,7 +163,9 @@ def load(cls, path): def _acquisition( - params: ResonatorSpectroscopyParameters, platform: Platform, targets: list[QubitId] + params: ResonatorSpectroscopyParameters, + platform: CalibrationPlatform, + targets: list[QubitId], ) -> ResonatorSpectroscopyData: """Data acquisition for resonator spectroscopy.""" # create a sequence of pulses for the experiment: @@ -318,7 +314,11 @@ def _plot( return FITS[data.fit_function].plot(data, target, fit) -def _update(results: ResonatorSpectroscopyResults, platform: Platform, target: QubitId): +def _update( + results: ResonatorSpectroscopyResults, + platform: CalibrationPlatform, + target: QubitId, +): update.readout_frequency(results.frequency[target], platform, target) if len(results.bare_frequency) == 0: update.readout_amplitude(results.amplitude[target], platform, target) diff --git a/src/qibocal/protocols/signal_experiments/calibrate_state_discrimination.py b/src/qibocal/protocols/signal_experiments/calibrate_state_discrimination.py index b29a083b6..28dba9c42 100644 --- a/src/qibocal/protocols/signal_experiments/calibrate_state_discrimination.py +++ b/src/qibocal/protocols/signal_experiments/calibrate_state_discrimination.py @@ -5,10 +5,11 @@ import numpy.typing as npt import plotly.graph_objects as go from plotly.subplots import make_subplots -from qibolab import AcquisitionType, AveragingMode, Platform, PulseSequence +from qibolab import AcquisitionType, AveragingMode, PulseSequence from qibocal import update from qibocal.auto.operation import Data, Parameters, QubitId, Results, Routine +from qibocal.calibration import CalibrationPlatform SAMPLES_FACTOR = 16 @@ -65,7 +66,7 @@ class CalibrateStateDiscriminationData(Data): def _acquisition( params: CalibrateStateDiscriminationParameters, - platform: Platform, + platform: CalibrationPlatform, targets: list[QubitId], ) -> CalibrateStateDiscriminationData: r""" @@ -75,7 +76,7 @@ def _acquisition( Args: params (CalibrateStateDiscriminationParameters): experiment's parameters - platform (Platform): Qibolab platform object + platform (CalibrationPlatform): Qibolab platform object qubits (dict): list of target qubits to perform the action """ @@ -237,7 +238,9 @@ def _plot( def _update( - results: CalibrateStateDiscriminationResults, platform: Platform, qubit: QubitId + results: CalibrateStateDiscriminationResults, + platform: CalibrationPlatform, + qubit: QubitId, ): update.kernel(results.data[qubit], platform, qubit) diff --git a/src/qibocal/protocols/signal_experiments/time_of_flight_readout.py b/src/qibocal/protocols/signal_experiments/time_of_flight_readout.py index 5861ffe4e..351b5c103 100644 --- a/src/qibocal/protocols/signal_experiments/time_of_flight_readout.py +++ b/src/qibocal/protocols/signal_experiments/time_of_flight_readout.py @@ -4,9 +4,10 @@ import numpy as np import numpy.typing as npt import plotly.graph_objects as go -from qibolab import AcquisitionType, AveragingMode, Platform, PulseSequence +from qibolab import AcquisitionType, AveragingMode, PulseSequence from qibocal.auto.operation import Data, Parameters, QubitId, Results, Routine +from qibocal.calibration import CalibrationPlatform from qibocal.protocols.utils import table_dict, table_html from qibocal.result import magnitude from qibocal.update import replace @@ -45,7 +46,9 @@ class TimeOfFlightReadoutData(Data): def _acquisition( - params: TimeOfFlightReadoutParameters, platform: Platform, targets: list[QubitId] + params: TimeOfFlightReadoutParameters, + platform: CalibrationPlatform, + targets: list[QubitId], ) -> TimeOfFlightReadoutData: """Data acquisition for time of flight experiment.""" diff --git a/src/qibocal/protocols/state_tomography.py b/src/qibocal/protocols/state_tomography.py index c4ab17a77..7089bfeb2 100644 --- a/src/qibocal/protocols/state_tomography.py +++ b/src/qibocal/protocols/state_tomography.py @@ -10,10 +10,10 @@ from qibo import Circuit, gates from qibo.backends import GlobalBackend, NumpyBackend, matrices from qibo.quantum_info import fidelity, partial_trace -from qibolab import Platform from qibocal.auto.operation import DATAFILE, Data, Parameters, QubitId, Results, Routine from qibocal.auto.transpile import dummy_transpiler, execute_transpiled_circuit +from qibocal.calibration import CalibrationPlatform from .utils import table_dict, table_html @@ -95,7 +95,9 @@ class StateTomographyResults(Results): def _acquisition( - params: StateTomographyParameters, platform: Platform, targets: list[QubitId] + params: StateTomographyParameters, + platform: CalibrationPlatform, + targets: list[QubitId], ) -> StateTomographyData: """Acquisition protocol for single qubit state tomography experiment.""" if params.circuit is None: diff --git a/src/qibocal/protocols/two_qubit_interaction/__init__.py b/src/qibocal/protocols/two_qubit_interaction/__init__.py index afee642fd..b64dd150d 100644 --- a/src/qibocal/protocols/two_qubit_interaction/__init__.py +++ b/src/qibocal/protocols/two_qubit_interaction/__init__.py @@ -1,4 +1,3 @@ from .chevron import chevron, chevron_signal from .optimize import optimize_two_qubit_gate from .virtual_z_phases import correct_virtual_z_phases -from .virtual_z_phases_signal import correct_virtual_z_phases_signal diff --git a/src/qibocal/protocols/two_qubit_interaction/chevron/chevron.py b/src/qibocal/protocols/two_qubit_interaction/chevron/chevron.py index 9f8cda596..6f16c5814 100644 --- a/src/qibocal/protocols/two_qubit_interaction/chevron/chevron.py +++ b/src/qibocal/protocols/two_qubit_interaction/chevron/chevron.py @@ -7,10 +7,11 @@ import numpy.typing as npt import plotly.graph_objects as go from plotly.subplots import make_subplots -from qibolab import AcquisitionType, AveragingMode, Parameter, Platform, Pulse, Sweeper +from qibolab import AcquisitionType, AveragingMode, Parameter, Pulse, Sweeper from scipy.optimize import curve_fit from qibocal.auto.operation import Data, Parameters, QubitPairId, Results, Routine +from qibocal.calibration import CalibrationPlatform from qibocal.config import log from qibocal.protocols.utils import table_dict, table_html @@ -113,14 +114,14 @@ def high_frequency(self, pair): def _aquisition( params: ChevronParameters, - platform: Platform, + platform: CalibrationPlatform, targets: list[QubitPairId], ) -> ChevronData: r"""Perform an CZ experiment between pairs of qubits by changing its frequency. Args: - platform: Platform to use. + platform: CalibrationPlatform to use. params: Experiment parameters. targets (list): List of pairs to use sequentially. @@ -313,7 +314,9 @@ def _plot(data: ChevronData, fit: ChevronResults, target: QubitPairId): return [fig], fitting_report -def _update(results: ChevronResults, platform: Platform, target: QubitPairId): +def _update( + results: ChevronResults, platform: CalibrationPlatform, target: QubitPairId +): if isinstance(target, list): target = tuple(target) if target not in results.duration: diff --git a/src/qibocal/protocols/two_qubit_interaction/chevron/chevron_signal.py b/src/qibocal/protocols/two_qubit_interaction/chevron/chevron_signal.py index 52ed8a751..2cc6c3aa6 100644 --- a/src/qibocal/protocols/two_qubit_interaction/chevron/chevron_signal.py +++ b/src/qibocal/protocols/two_qubit_interaction/chevron/chevron_signal.py @@ -4,9 +4,10 @@ import numpy as np import numpy.typing as npt -from qibolab import AcquisitionType, AveragingMode, Parameter, Platform, Pulse, Sweeper +from qibolab import AcquisitionType, AveragingMode, Parameter, Pulse, Sweeper from qibocal.auto.operation import QubitPairId, Routine +from qibocal.calibration import CalibrationPlatform from qibocal.result import magnitude from ..utils import order_pair @@ -72,7 +73,7 @@ def high_frequency(self, pair): def _aquisition( params: ChevronSignalParameters, - platform: Platform, + platform: CalibrationPlatform, targets: list[QubitPairId], ) -> ChevronSignalData: r""" @@ -80,7 +81,7 @@ def _aquisition( Args: params: Experiment parameters. - platform: Platform to use. + platform: CalibrationPlatform to use. targets (list): List of pairs to use sequentially. Returns: diff --git a/src/qibocal/protocols/two_qubit_interaction/chevron/utils.py b/src/qibocal/protocols/two_qubit_interaction/chevron/utils.py index 360c9b431..c7d1652d8 100644 --- a/src/qibocal/protocols/two_qubit_interaction/chevron/utils.py +++ b/src/qibocal/protocols/two_qubit_interaction/chevron/utils.py @@ -1,7 +1,8 @@ import numpy as np -from qibolab import Platform, PulseSequence, VirtualZ +from qibolab import PulseSequence, VirtualZ from qibocal.auto.operation import QubitPairId +from qibocal.calibration import CalibrationPlatform from ..utils import order_pair @@ -14,7 +15,7 @@ def chevron_sequence( - platform: Platform, + platform: CalibrationPlatform, pair: QubitPairId, duration_max: int, parking: bool = False, diff --git a/src/qibocal/protocols/two_qubit_interaction/optimize.py b/src/qibocal/protocols/two_qubit_interaction/optimize.py index 40a4be810..f23640034 100644 --- a/src/qibocal/protocols/two_qubit_interaction/optimize.py +++ b/src/qibocal/protocols/two_qubit_interaction/optimize.py @@ -7,7 +7,7 @@ import numpy.typing as npt import plotly.graph_objects as go from plotly.subplots import make_subplots -from qibolab import AcquisitionType, AveragingMode, Parameter, Platform, Pulse, Sweeper +from qibolab import AcquisitionType, AveragingMode, Parameter, Pulse, Sweeper from scipy.optimize import curve_fit from qibocal import update @@ -19,6 +19,7 @@ Results, Routine, ) +from qibocal.calibration import CalibrationPlatform from qibocal.config import log from qibocal.protocols.utils import table_dict, table_html @@ -146,7 +147,7 @@ def register_qubit( def _acquisition( params: OptimizeTwoQubitGateParameters, - platform: Platform, + platform: CalibrationPlatform, targets: list[QubitPairId], ) -> OptimizeTwoQubitGateData: r""" @@ -470,7 +471,9 @@ def _plot( def _update( - results: OptimizeTwoQubitGateResults, platform: Platform, target: QubitPairId + results: OptimizeTwoQubitGateResults, + platform: CalibrationPlatform, + target: QubitPairId, ): # FIXME: quick fix for qubit order target = tuple(sorted(target)) diff --git a/src/qibocal/protocols/two_qubit_interaction/virtual_z_phases.py b/src/qibocal/protocols/two_qubit_interaction/virtual_z_phases.py index 58be9fa4a..b69072920 100644 --- a/src/qibocal/protocols/two_qubit_interaction/virtual_z_phases.py +++ b/src/qibocal/protocols/two_qubit_interaction/virtual_z_phases.py @@ -12,7 +12,6 @@ AveragingMode, Delay, Parameter, - Platform, Pulse, PulseSequence, Sweeper, @@ -28,6 +27,7 @@ Results, Routine, ) +from qibocal.calibration import CalibrationPlatform from qibocal.config import log from qibocal.protocols.utils import table_dict, table_html @@ -110,7 +110,7 @@ def __getitem__(self, pair): def create_sequence( - platform: Platform, + platform: CalibrationPlatform, setup: Literal["I", "X"], target_qubit: QubitId, control_qubit: QubitId, @@ -186,7 +186,7 @@ def create_sequence( def _acquisition( params: VirtualZPhasesParameters, - platform: Platform, + platform: CalibrationPlatform, targets: list[QubitPairId], ) -> VirtualZPhasesData: r""" @@ -473,7 +473,9 @@ def _plot(data: VirtualZPhasesData, fit: VirtualZPhasesResults, target: QubitPai return [fig1, fig2], "".join(fitting_report) # target and control qubit -def _update(results: VirtualZPhasesResults, platform: Platform, target: QubitPairId): +def _update( + results: VirtualZPhasesResults, platform: CalibrationPlatform, target: QubitPairId +): target = tuple(sorted(target)) update.virtual_phases( results.virtual_phase[target], results.native, platform, target diff --git a/src/qibocal/protocols/two_qubit_interaction/virtual_z_phases_signal.py b/src/qibocal/protocols/two_qubit_interaction/virtual_z_phases_signal.py deleted file mode 100644 index 3cd6b3901..000000000 --- a/src/qibocal/protocols/two_qubit_interaction/virtual_z_phases_signal.py +++ /dev/null @@ -1,145 +0,0 @@ -"""CZ virtual correction experiment for two qubit gates, tune landscape.""" - -from dataclasses import dataclass - -import numpy as np -from qibolab import AcquisitionType, AveragingMode, Parameter, Platform, Sweeper - -from qibocal.auto.operation import QubitPairId, Routine -from qibocal.result import magnitude - -from .utils import order_pair -from .virtual_z_phases import ( - VirtualZPhasesData, - VirtualZPhasesParameters, - VirtualZPhasesResults, - VirtualZPhasesType, - _fit, -) -from .virtual_z_phases import _plot as _plot_prob -from .virtual_z_phases import _update, create_sequence - - -@dataclass -class VirtualZPhasesSignalParameters(VirtualZPhasesParameters): - """VirtualZ runcard inputs.""" - - -@dataclass -class VirtualZPhasesSignalResults(VirtualZPhasesResults): - """VirtualZ outputs when fitting will be done.""" - - -VirtualZPhasesType = np.dtype([("target", np.float64), ("control", np.float64)]) - - -@dataclass -class VirtualZPhasesSignalData(VirtualZPhasesData): - """VirtualZPhases data.""" - - -def _acquisition( - params: VirtualZPhasesSignalParameters, - platform: Platform, - targets: list[QubitPairId], -) -> VirtualZPhasesSignalData: - r""" - Acquisition for VirtualZPhases. See https://arxiv.org/pdf/1904.06560.pdf - - Check the two-qubit landscape created by a flux pulse of a given duration - and amplitude. - The system is initialized with a Y90 pulse on the low frequency qubit and either - an Id or an X gate on the high frequency qubit. Then the flux pulse is applied to - the high frequency qubit in order to perform a two-qubit interaction. The Id/X gate - is undone in the high frequency qubit and a theta90 pulse is applied to the low - frequency qubit before measurement. That is, a pi-half pulse around the relative phase - parametereized by the angle theta. - Measurements on the low frequency qubit yield the 2Q-phase of the gate and the - remnant single qubit Z phase aquired during the execution to be corrected. - Population of the high frequency qubit yield the leakage to the non-computational states - during the execution of the flux pulse. - """ - - theta_absolute = np.arange(params.theta_start, params.theta_end, params.theta_step) - data = VirtualZPhasesData(native=params.native, thetas=theta_absolute.tolist()) - for pair in targets: - # order the qubits so that the low frequency one is the first - ord_pair = order_pair(pair, platform) - - for target_q, control_q in ( - (ord_pair[0], ord_pair[1]), - (ord_pair[1], ord_pair[0]), - ): - for setup in ("I", "X"): - ( - sequence, - theta_pulse, - data.amplitudes[ord_pair], - data.durations[ord_pair], - ) = create_sequence( - platform, - setup, - target_q, - control_q, - ord_pair, - params.native, - params.dt, - params.parking, - params.flux_pulse_amplitude, - params.flux_pulse_duration, - ) - - sweeper = Sweeper( - parameter=Parameter.relative_phase, - range=(params.theta_start, params.theta_end, params.theta_step), - pulses=[theta_pulse], - ) - results = platform.execute( - [sequence], - [[sweeper]], - nshots=params.nshots, - relaxation_time=params.relaxation_time, - acquisition_type=AcquisitionType.INTEGRATION, - averaging_mode=AveragingMode.CYCLIC, - ) - - ro_target = list( - sequence.channel(platform.qubits[target_q].acquisition) - )[-1] - ro_control = list( - sequence.channel(platform.qubits[control_q].acquisition) - )[-1] - result_target = magnitude(results[ro_target.id]) - result_control = magnitude(results[ro_control.id]) - - data.register_qubit( - VirtualZPhasesType, - (target_q, control_q, setup), - dict( - target=result_target, - control=result_control, - ), - ) - return data - - -def _plot( - data: VirtualZPhasesSignalData, - fit: VirtualZPhasesSignalResults, - target: QubitPairId, -): - """Plot routine for VirtualZPhases.""" - figs, fitting_report = _plot_prob(data, fit, target) - - for fig in figs: - fig.update_layout( - yaxis_title="Signal [a.u.]", - ) - - return figs, fitting_report - - -correct_virtual_z_phases_signal = Routine( - _acquisition, _fit, _plot, _update, two_qubit_gates=True -) -"""Virtual Z correction routine.""" diff --git a/src/qibocal/protocols/two_qubit_state_tomography.py b/src/qibocal/protocols/two_qubit_state_tomography.py index 9061832a2..75c9ffbbd 100644 --- a/src/qibocal/protocols/two_qubit_state_tomography.py +++ b/src/qibocal/protocols/two_qubit_state_tomography.py @@ -12,7 +12,6 @@ from qibo.backends import GlobalBackend, NumpyBackend from qibo.quantum_info import fidelity, partial_trace from qibo.result import QuantumState -from qibolab import Platform from qibocal.auto.operation import ( DATAFILE, @@ -23,6 +22,7 @@ Routine, ) from qibocal.auto.transpile import dummy_transpiler, execute_transpiled_circuit +from qibocal.calibration import CalibrationPlatform from .state_tomography import StateTomographyParameters, plot_reconstruction from .utils import table_dict, table_html @@ -90,7 +90,9 @@ class StateTomographyResults(Results): def _acquisition( - params: StateTomographyParameters, platform: Platform, targets: list[QubitPairId] + params: StateTomographyParameters, + platform: CalibrationPlatform, + targets: list[QubitPairId], ) -> StateTomographyData: """Acquisition protocol for two qubit state tomography experiment.""" qubits = [q for pair in targets for q in pair] diff --git a/tests/runcards/protocols.yml b/tests/runcards/protocols.yml index d43182d6a..e02fe071d 100644 --- a/tests/runcards/protocols.yml +++ b/tests/runcards/protocols.yml @@ -672,19 +672,6 @@ actions: native: iSWAP parking: True - - id: iswap virtual signal - operation: correct_virtual_z_phases_signal - targets: [[0, 2],[1,2]] - parameters: - theta_start: 0 - theta_end: 180 - theta_step: 10 - flux_pulse_amplitude: 0.5 - flux_pulse_duration: 10 - native: iSWAP - dt: 0 - parking: True - - id: cz_virtual_phase operation: correct_virtual_z_phases targets: [[0, 2],[1,2]] @@ -698,19 +685,6 @@ actions: native: CZ parking: True - - id: cz virtual signal - operation: correct_virtual_z_phases_signal - targets: [[0, 2],[1,2]] - parameters: - theta_start: 0 - theta_end: 180 - theta_step: 10 - flux_pulse_amplitude: 0.5 - flux_pulse_duration: 10 - native: CZ - dt: 0 - parking: True - - id: readout_mitigation_matrix pulses operation: readout_mitigation_matrix targets: [[0,1,2],[1,2]]