Skip to content

Commit

Permalink
Merge pull request #938 from qiboteam/iSWAP
Browse files Browse the repository at this point in the history
Generalization of two qubit protocols to iSWAP gate
  • Loading branch information
andrea-pasquale committed Aug 12, 2024
2 parents a8dd118 + ef3089e commit 16b54b6
Show file tree
Hide file tree
Showing 11 changed files with 349 additions and 153 deletions.
12 changes: 6 additions & 6 deletions src/qibocal/protocols/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@
chevron_signal,
chsh_circuits,
chsh_pulses,
cz_sweep,
cz_virtualz,
cz_virtualz_signal,
correct_virtual_z_phases,
correct_virtual_z_phases_signal,
optimize_two_qubit_gate,
)
from .two_qubit_state_tomography import two_qubit_state_tomography

Expand Down Expand Up @@ -134,8 +134,8 @@
"chevron_signal",
"chsh_circuits",
"chsh_pulses",
"cz_virtualz",
"cz_virtualz_signal",
"correct_virtual_z_phases",
"correct_virtual_z_phases_signal",
"state_tomography",
"allxy_resonator_depletion_tuning",
"two_qubit_state_tomography",
Expand All @@ -145,5 +145,5 @@
"rabi_length_frequency",
"rabi_length_frequency_signal",
"standard_rb_2q",
"cz_sweep",
"optimize_two_qubit_gate",
]
6 changes: 3 additions & 3 deletions src/qibocal/protocols/two_qubit_interaction/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .chevron import chevron, chevron_signal
from .chsh import chsh_circuits, chsh_pulses
from .cz_sweep import cz_sweep
from .cz_virtualz import cz_virtualz
from .cz_virtualz_signal import cz_virtualz_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
41 changes: 30 additions & 11 deletions src/qibocal/protocols/two_qubit_interaction/chevron/chevron.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ class ChevronParameters(Parameters):
"""Time delay between flux pulses and readout."""
parking: bool = True
"""Wether to park non interacting qubits or not."""
native: str = "CZ"
"""Two qubit interaction to be calibrated.
iSWAP and CZ are the possible options.
"""

@property
def amplitude_range(self):
Expand All @@ -68,9 +74,12 @@ class ChevronResults(Results):
"""CZ angle."""
duration: dict[QubitPairId, int]
"""Virtual Z phase correction."""
native: str = "CZ"
"""Two qubit interaction to be calibrated.
def __contains__(self, key: QubitPairId):
return super().__contains__(key) | super().__contains__((key[1], key[0]))
iSWAP and CZ are the possible options.
"""


ChevronType = np.dtype(
Expand All @@ -90,6 +99,12 @@ class ChevronData(Data):

native_amplitude: dict[QubitPairId, float] = field(default_factory=dict)
"""CZ platform amplitude for qubit pair."""
native: str = "CZ"
"""Two qubit interaction to be calibrated.
iSWAP and CZ are the possible options.
"""
sweetspot: dict[QubitPairId, float] = field(default_factory=dict)
"""Sweetspot value for high frequency qubit."""
data: dict[QubitPairId, npt.NDArray[ChevronType]] = field(default_factory=dict)
Expand Down Expand Up @@ -137,8 +152,8 @@ def _aquisition(
ChevronData: Acquisition data.
"""

# create a DataUnits object to store the results,
data = ChevronData()
# create a DataUnits object to store the results
data = ChevronData(native=params.native)
for pair in targets:
# order the qubits so that the low frequency one is the first
sequence = chevron_sequence(
Expand All @@ -147,6 +162,7 @@ def _aquisition(
duration_max=params.duration_max,
parking=params.parking,
dt=params.dt,
native=params.native,
)
ordered_pair = order_pair(pair, platform)
# TODO: move in function to avoid code duplications
Expand Down Expand Up @@ -216,20 +232,18 @@ def _fit(data: ChevronData) -> ChevronResults:
except Exception as e:
log.warning(f"Chevron fit failed for pair {pair} due to {e}")

return ChevronResults(amplitude=amplitudes, duration=durations)
return ChevronResults(amplitude=amplitudes, duration=durations, native=data.native)


def _plot(data: ChevronData, fit: ChevronResults, target: QubitPairId):
"""Plot the experiment result for a single pair."""
if isinstance(target, list):
target = tuple(target)

# reverse qubit order if not found in data
if target not in data.data:
target = (target[1], target[0])

pair_data = data[target]

fig = make_subplots(
rows=1,
cols=2,
Expand Down Expand Up @@ -278,7 +292,7 @@ def _plot(data: ChevronData, fit: ChevronResults, target: QubitPairId):
color="black",
symbol="cross",
),
name="CZ estimate", # Change name from the params
name=f"{data.native} estimate", # Change name from the params
showlegend=True if measured_qubit == target[0] else False,
legendgroup="Voltage",
),
Expand All @@ -301,7 +315,7 @@ def _plot(data: ChevronData, fit: ChevronResults, target: QubitPairId):
fitting_report = table_html(
table_dict(
target[1],
["CZ amplitude", "CZ duration", "Bias point"],
[f"{fit.native} amplitude", f"{fit.native} duration", "Bias point"],
[
fit.amplitude[target],
fit.duration[target],
Expand All @@ -319,8 +333,13 @@ def _update(results: ChevronResults, platform: Platform, target: QubitPairId):

if target not in results.duration:
target = (target[1], target[0])
update.CZ_duration(results.duration[target], platform, target)
update.CZ_amplitude(results.amplitude[target], platform, target)

getattr(update, f"{results.native}_duration")(
results.duration[target], platform, target
)
getattr(update, f"{results.native}_amplitude")(
results.amplitude[target], platform, target
)


chevron = Routine(_aquisition, _fit, _plot, _update, two_qubit_gates=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def _aquisition(
"""

# create a DataUnits object to store the results,
data = ChevronSignalData()
data = ChevronSignalData(native=params.native)
for pair in targets:
# order the qubits so that the low frequency one is the first
ordered_pair = order_pair(pair, platform)
Expand All @@ -100,6 +100,7 @@ def _aquisition(
duration_max=params.duration_max,
parking=params.parking,
dt=params.dt,
native=params.native,
)

data.native_amplitude[ordered_pair] = (
Expand Down
25 changes: 15 additions & 10 deletions src/qibocal/protocols/two_qubit_interaction/chevron/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,45 @@ def chevron_sequence(
pair: QubitPairId,
duration_max: int,
parking: bool = False,
native: str = "CZ",
dt: int = 0,
):
"""Chevron pulse sequence."""

sequence = PulseSequence()
ordered_pair = order_pair(pair, platform)
# initialize in system in 11 state
initialize_lowfreq = platform.create_RX_pulse(
ordered_pair[0], start=0, relative_phase=0
)

if native == "CZ":
initialize_lowfreq = platform.create_RX_pulse(
ordered_pair[0], start=0, relative_phase=0
)
sequence.add(initialize_lowfreq)

initialize_highfreq = platform.create_RX_pulse(
ordered_pair[1], start=0, relative_phase=0
)
sequence.add(initialize_highfreq)
sequence.add(initialize_lowfreq)
cz, _ = platform.create_CZ_pulse_sequence(

flux_sequence, _ = getattr(platform, f"create_{native}_pulse_sequence")(
qubits=(ordered_pair[1], ordered_pair[0]),
start=initialize_highfreq.finish,
)

sequence.add(cz.get_qubit_pulses(ordered_pair[0]))
sequence.add(cz.get_qubit_pulses(ordered_pair[1]))
sequence.add(flux_sequence.get_qubit_pulses(ordered_pair[0]))
sequence.add(flux_sequence.get_qubit_pulses(ordered_pair[1]))

delay_measurement = duration_max

if platform.couplers:
coupler_pulse = cz.coupler_pulses(
coupler_pulse = flux_sequence.coupler_pulses(
platform.pairs[tuple(ordered_pair)].coupler.name
)
sequence.add(coupler_pulse)
delay_measurement = max(duration_max, coupler_pulse.duration)

if parking:
for pulse in cz:
for pulse in flux_sequence:
if pulse.qubit not in ordered_pair:
pulse.start = COUPLER_PULSE_START
pulse.duration = COUPLER_PULSE_DURATION
Expand All @@ -60,7 +65,7 @@ def chevron_sequence(
# add readout
measure_lowfreq = platform.create_qubit_readout_pulse(
ordered_pair[0],
start=initialize_lowfreq.finish + delay_measurement + dt,
start=initialize_highfreq.finish + delay_measurement + dt,
)
measure_highfreq = platform.create_qubit_readout_pulse(
ordered_pair[1],
Expand Down
Loading

0 comments on commit 16b54b6

Please sign in to comment.