diff --git a/src/qibocal/protocols/classification.py b/src/qibocal/protocols/classification.py index 5f580ed3a..d1f4b4143 100644 --- a/src/qibocal/protocols/classification.py +++ b/src/qibocal/protocols/classification.py @@ -9,7 +9,7 @@ import plotly.graph_objects as go from qibolab import AcquisitionType, ExecutionParameters from qibolab.platform import Platform -from qibolab.pulses import PulseSequence +from qibolab.pulses import Delay, PulseSequence from qibolab.qubits import QubitId from sklearn.metrics import roc_auc_score, roc_curve @@ -169,16 +169,16 @@ def _acquisition( sequences, all_ro_pulses = [], [] for state in [0, 1]: sequence = PulseSequence() - RX_pulses = {} ro_pulses = {} - for qubit in targets: - RX_pulses[qubit] = platform.create_RX_pulse(qubit, start=0) - ro_pulses[qubit] = platform.create_qubit_readout_pulse( - qubit, start=RX_pulses[qubit].finish - ) + for q in targets: + qubit = platform.qubits[q] + rx_sequence = qubit.native_gates.RX.create_sequence(theta=np.pi, phi=0) + ro_sequence = qubit.native_gates.MZ.create_sequence() if state == 1: - sequence.add(RX_pulses[qubit]) - sequence.add(ro_pulses[qubit]) + sequence.extend(rx_sequence) + sequence[qubit.measure.name].append(Delay(duration=rx_sequence.duration)) + sequence.extend(ro_sequence) + ro_pulses[q] = ro_sequence[qubit.measure.name][0].id sequences.append(sequence) all_ro_pulses.append(ro_pulses) @@ -186,7 +186,8 @@ def _acquisition( data = SingleShotClassificationData( nshots=params.nshots, qubit_frequencies={ - qubit: platform.qubits[qubit].drive_frequency for qubit in targets + qubit: platform.config(platform.qubits[qubit].drive.name).frequency + for qubit in targets }, classifiers_list=params.classifiers_list, savedir=params.savedir, @@ -207,7 +208,7 @@ def _acquisition( for ig, (state, ro_pulses) in enumerate(zip([0, 1], all_ro_pulses)): for qubit in targets: - serial = ro_pulses[qubit].serial + serial = ro_pulses[qubit] if params.unrolling: result = results[serial][ig] else: diff --git a/src/qibocal/protocols/rabi/amplitude.py b/src/qibocal/protocols/rabi/amplitude.py index cbc9c6364..2ab378bfe 100644 --- a/src/qibocal/protocols/rabi/amplitude.py +++ b/src/qibocal/protocols/rabi/amplitude.py @@ -53,7 +53,7 @@ def _acquisition( to find the drive pulse amplitude that creates a rotation of a desired angle. """ - sequence, qd_pulses, _, durations = utils.sequence_amplitude( + sequence, qd_pulses, ro_pulses, durations = utils.sequence_amplitude( targets, params, platform ) # define the parameter to sweep and its range: @@ -84,7 +84,7 @@ def _acquisition( sweeper, ) for qubit in targets: - prob = results[qubit].probability(state=1) + prob = results[ro_pulses[qubit].id].probability(state=1) data.register_qubit( RabiAmpType, (qubit), diff --git a/src/qibocal/protocols/rabi/amplitude_signal.py b/src/qibocal/protocols/rabi/amplitude_signal.py index de5aa7084..bd2fd6309 100644 --- a/src/qibocal/protocols/rabi/amplitude_signal.py +++ b/src/qibocal/protocols/rabi/amplitude_signal.py @@ -26,7 +26,7 @@ class RabiAmplitudeSignalParameters(Parameters): """Maximum amplitude multiplicative factor.""" step_amp_factor: float """Step amplitude multiplicative factor.""" - pulse_length: Optional[float] + pulse_length: Optional[float] = None """RX pulse duration [ns].""" @@ -100,7 +100,7 @@ def _acquisition( sweeper, ) for qubit in targets: - result = results[ro_pulses[qubit].serial] + result = results[ro_pulses[qubit].id] data.register_qubit( RabiAmpSignalType, (qubit), diff --git a/src/qibocal/protocols/rabi/utils.py b/src/qibocal/protocols/rabi/utils.py index e90eca842..171e579ac 100644 --- a/src/qibocal/protocols/rabi/utils.py +++ b/src/qibocal/protocols/rabi/utils.py @@ -2,7 +2,7 @@ import plotly.graph_objects as go from plotly.subplots import make_subplots from qibolab.platform import Platform -from qibolab.pulses import PulseSequence +from qibolab.pulses import Delay, PulseSequence from qibolab.qubits import QubitId from scipy.optimize import curve_fit @@ -231,17 +231,21 @@ def sequence_amplitude( qd_pulses = {} ro_pulses = {} durations = {} - for qubit in targets: - qd_pulses[qubit] = platform.create_RX_pulse(qubit, start=0) + for q in targets: + qubit = platform.qubits[q] + qd_sequence = qubit.native_gates.RX.create_sequence(theta=np.pi, phi=0) + ro_sequence = qubit.native_gates.MZ.create_sequence() + + qd_pulses[q] = qd_sequence[qubit.drive.name][0] if params.pulse_length is not None: - qd_pulses[qubit].duration = params.pulse_length + qd_pulses[q].duration = params.pulse_length - durations[qubit] = qd_pulses[qubit].duration - ro_pulses[qubit] = platform.create_qubit_readout_pulse( - qubit, start=qd_pulses[qubit].finish - ) - sequence.add(qd_pulses[qubit]) - sequence.add(ro_pulses[qubit]) + durations[q] = qd_pulses[q].duration + ro_pulses[q] = ro_sequence[qubit.measure.name][0] + + sequence[qubit.drive.name].append(qd_pulses[q]) + sequence[qubit.measure.name].append(Delay(duration=durations[q])) + sequence[qubit.measure.name].append(ro_pulses[q]) return sequence, qd_pulses, ro_pulses, durations diff --git a/src/qibocal/protocols/resonator_spectroscopy.py b/src/qibocal/protocols/resonator_spectroscopy.py index a0a51bed3..1cdd7f3b2 100644 --- a/src/qibocal/protocols/resonator_spectroscopy.py +++ b/src/qibocal/protocols/resonator_spectroscopy.py @@ -129,24 +129,26 @@ def _acquisition( amplitudes = {} attenuations = {} - for qubit in targets: - ro_pulses[qubit] = platform.create_qubit_readout_pulse(qubit, start=0) + for q in targets: + qubit = platform.qubits[q] + ro_sequence = qubit.native_gates.MZ.create_sequence() + ro_pulses[q] = ro_sequence[qubit.measure.name][0] if params.amplitude is not None: - ro_pulses[qubit].amplitude = params.amplitude + ro_pulses[q].amplitude = params.amplitude - amplitudes[qubit] = ro_pulses[qubit].amplitude + amplitudes[q] = ro_pulses[q].amplitude if params.attenuation is not None: - platform.qubits[qubit].readout.attenuation = params.attenuation + platform.qubits[q].readout.attenuation = params.attenuation try: - attenuation = platform.qubits[qubit].readout.attenuation + attenuation = platform.qubits[q].readout.attenuation except AttributeError: attenuation = None - attenuations[qubit] = attenuation - sequence.add(ro_pulses[qubit]) + attenuations[q] = attenuation + sequence[qubit.measure.name].append(ro_pulses[q]) # define the parameter to sweep and its range: delta_frequency_range = np.arange( @@ -155,7 +157,7 @@ def _acquisition( sweeper = Sweeper( Parameter.frequency, delta_frequency_range, - pulses=[ro_pulses[qubit] for qubit in targets], + channels=[platform.qubits[q].measure for q in targets], type=SweeperType.OFFSET, ) data = ResonatorSpectroscopyData( @@ -173,15 +175,16 @@ def _acquisition( # retrieve the results for every qubit for qubit in targets: - result = results[ro_pulses[qubit].serial] + result = results[ro_pulses[qubit].id] # store the results + ro_frequency = platform.config(platform.qubits[qubit].measure.name).frequency data.register_qubit( ResSpecType, (qubit), dict( signal=result.average.magnitude, phase=result.average.phase, - freq=delta_frequency_range + ro_pulses[qubit].frequency, + freq=delta_frequency_range + ro_frequency, error_signal=result.average.std, error_phase=result.phase_std, ), diff --git a/src/qibocal/update.py b/src/qibocal/update.py index 9e4d1c730..07eb444c3 100644 --- a/src/qibocal/update.py +++ b/src/qibocal/update.py @@ -5,7 +5,6 @@ import numpy as np from qibolab import pulses -from qibolab.native import VirtualZPulse from qibolab.platform import Platform from qibolab.qubits import QubitId, QubitPairId