Skip to content

Commit

Permalink
refactor: Remove pulse.start from platform and sweeper
Browse files Browse the repository at this point in the history
  • Loading branch information
stavros11 committed Jan 30, 2024
1 parent 627563b commit d279ba6
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 29 deletions.
60 changes: 34 additions & 26 deletions src/qibolab/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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:
Expand All @@ -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
4 changes: 1 addition & 3 deletions src/qibolab/sweeper.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class Parameter(Enum):
amplitude = auto()
duration = auto()
relative_phase = auto()
start = auto()

attenuation = auto()
gain = auto()
Expand All @@ -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
Expand Down Expand Up @@ -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])
Expand Down

0 comments on commit d279ba6

Please sign in to comment.