From d279ba63eb24c1b083ec5efb81d5daaa80b01b6f Mon Sep 17 00:00:00 2001 From: Stavros Efthymiou <35475381+stavros11@users.noreply.github.com> Date: Tue, 30 Jan 2024 19:17:29 +0400 Subject: [PATCH] refactor: Remove pulse.start from platform and sweeper --- src/qibolab/platform.py | 60 +++++++++++++++++++++++------------------ src/qibolab/sweeper.py | 4 +-- 2 files changed, 35 insertions(+), 29 deletions(-) diff --git a/src/qibolab/platform.py b/src/qibolab/platform.py index defed15f8..c15f51bf2 100644 --- a/src/qibolab/platform.py +++ b/src/qibolab/platform.py @@ -274,7 +274,7 @@ def sweep( platform = create_dummy() sequence = PulseSequence() parameter = Parameter.frequency - pulse = platform.create_qubit_readout_pulse(qubit=0, start=0) + pulse = platform.create_qubit_readout_pulse(qubit=0) sequence.append(pulse) parameter_range = np.random.randint(10, size=10) sweeper = Sweeper(parameter, parameter_range, [pulse]) @@ -337,62 +337,68 @@ def get_coupler(self, coupler): except KeyError: return list(self.couplers.keys())[coupler] - def create_RX90_pulse(self, qubit, start=0, relative_phase=0): + def create_RX90_pulse(self, qubit, relative_phase=0): qubit = self.get_qubit(qubit) - return self.qubits[qubit].native_gates.RX90.pulse(start, relative_phase) + pulse = self.qubits[qubit].native_gates.RX90 + pulse.relative_phase = relative_phase + return pulse - def create_RX_pulse(self, qubit, start=0, relative_phase=0): + def create_RX_pulse(self, qubit, relative_phase=0): qubit = self.get_qubit(qubit) - return self.qubits[qubit].native_gates.RX.pulse(start, relative_phase) + pulse = self.qubits[qubit].native_gates.RX + pulse.relative_phase = relative_phase + return pulse - def create_RX12_pulse(self, qubit, start=0, relative_phase=0): + def create_RX12_pulse(self, qubit, relative_phase=0): qubit = self.get_qubit(qubit) - return self.qubits[qubit].native_gates.RX12.pulse(start, relative_phase) + pulse = self.qubits[qubit].native_gates.RX12 + pulse.relative_phase = relative_phase + return pulse - def create_CZ_pulse_sequence(self, qubits, start=0): + def create_CZ_pulse_sequence(self, qubits): pair = tuple(self.get_qubit(q) for q in qubits) if pair not in self.pairs or self.pairs[pair].native_gates.CZ is None: raise_error( ValueError, f"Calibration for CZ gate between qubits {qubits[0]} and {qubits[1]} not found.", ) - return self.pairs[pair].native_gates.CZ.sequence(start) + return self.pairs[pair].native_gates.CZ - def create_iSWAP_pulse_sequence(self, qubits, start=0): + def create_iSWAP_pulse_sequence(self, qubits): pair = tuple(self.get_qubit(q) for q in qubits) if pair not in self.pairs or self.pairs[pair].native_gates.iSWAP is None: raise_error( ValueError, f"Calibration for iSWAP gate between qubits {qubits[0]} and {qubits[1]} not found.", ) - return self.pairs[pair].native_gates.iSWAP.sequence(start) + return self.pairs[pair].native_gates.iSWAP - def create_CNOT_pulse_sequence(self, qubits, start=0): + def create_CNOT_pulse_sequence(self, qubits): pair = tuple(self.get_qubit(q) for q in qubits) if pair not in self.pairs or self.pairs[pair].native_gates.CNOT is None: raise_error( ValueError, f"Calibration for CNOT gate between qubits {qubits[0]} and {qubits[1]} not found.", ) - return self.pairs[pair].native_gates.CNOT.sequence(start) + return self.pairs[pair].native_gates.CNOT - def create_MZ_pulse(self, qubit, start): + def create_MZ_pulse(self, qubit): qubit = self.get_qubit(qubit) - return self.qubits[qubit].native_gates.MZ.pulse(start) + return self.qubits[qubit].native_gates.MZ - def create_qubit_drive_pulse(self, qubit, start, duration, relative_phase=0): + def create_qubit_drive_pulse(self, qubit, duration, relative_phase=0): qubit = self.get_qubit(qubit) - pulse = self.qubits[qubit].native_gates.RX.pulse(start, relative_phase) + pulse = self.qubits[qubit].native_gates.RX + pulse.relative_phase = relative_phase pulse.duration = duration return pulse - def create_qubit_readout_pulse(self, qubit, start): - qubit = self.get_qubit(qubit) - return self.create_MZ_pulse(qubit, start) + def create_qubit_readout_pulse(self, qubit): + return self.create_MZ_pulse(qubit) - def create_coupler_pulse(self, coupler, start, duration=None, amplitude=None): + def create_coupler_pulse(self, coupler, duration=None, amplitude=None): coupler = self.get_coupler(coupler) - pulse = self.couplers[coupler].native_pulse.CP.pulse(start) + pulse = self.couplers[coupler].native_pulse.CP if duration is not None: pulse.duration = duration if amplitude is not None: @@ -402,16 +408,18 @@ def create_coupler_pulse(self, coupler, start, duration=None, amplitude=None): # TODO Remove RX90_drag_pulse and RX_drag_pulse, replace them with create_qubit_drive_pulse # TODO Add RY90 and RY pulses - def create_RX90_drag_pulse(self, qubit, start, relative_phase=0, beta=None): + def create_RX90_drag_pulse(self, qubit, relative_phase=0, beta=None): qubit = self.get_qubit(qubit) - pulse = self.qubits[qubit].native_gates.RX90.pulse(start, relative_phase) + pulse = self.qubits[qubit].native_gates.RX90 + pulse.relative_phase = relative_phase if beta is not None: pulse.shape = "Drag(5," + str(beta) + ")" return pulse - def create_RX_drag_pulse(self, qubit, start, relative_phase=0, beta=None): + def create_RX_drag_pulse(self, qubit, relative_phase=0, beta=None): qubit = self.get_qubit(qubit) - pulse = self.qubits[qubit].native_gates.RX.pulse(start, relative_phase) + pulse = self.qubits[qubit].native_gates.RX + pulse.relative_phase = relative_phase if beta is not None: pulse.shape = "Drag(5," + str(beta) + ")" return pulse diff --git a/src/qibolab/sweeper.py b/src/qibolab/sweeper.py index 84ff1880c..ddb17297a 100644 --- a/src/qibolab/sweeper.py +++ b/src/qibolab/sweeper.py @@ -14,7 +14,6 @@ class Parameter(Enum): amplitude = auto() duration = auto() relative_phase = auto() - start = auto() attenuation = auto() gain = auto() @@ -26,7 +25,6 @@ class Parameter(Enum): AMPLITUDE = Parameter.amplitude DURATION = Parameter.duration RELATIVE_PHASE = Parameter.relative_phase -START = Parameter.start ATTENUATION = Parameter.attenuation GAIN = Parameter.gain BIAS = Parameter.bias @@ -64,7 +62,7 @@ class Sweeper: platform = create_dummy() sequence = PulseSequence() parameter = Parameter.frequency - pulse = platform.create_qubit_readout_pulse(qubit=0, start=0) + pulse = platform.create_qubit_readout_pulse(qubit=0) sequence.append(pulse) parameter_range = np.random.randint(10, size=10) sweeper = Sweeper(parameter, parameter_range, [pulse])