Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rabi and chevron fixes #961

Merged
merged 3 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/qibocal/protocols/rabi/amplitude.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def _fit(data: RabiAmplitudeData) -> RabiAmplitudeResults:
y = qubit_data.prob

period = fallback_period(guess_period(x, y))
pguess = [0.5, 0.5, period, 0]
pguess = [0.5, 0.5, period, np.pi]
try:
popt, perr, pi_pulse_parameter = utils.fit_amplitude_function(
x,
Expand Down
2 changes: 1 addition & 1 deletion src/qibocal/protocols/rabi/amplitude_signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def _fit(data: RabiAmplitudeSignalData) -> RabiAmplitudeSignalResults:
y = (voltages - y_min) / (y_max - y_min)

period = fallback_period(guess_period(x, y))
pguess = [0.5, 1, period, 0]
pguess = [0.5, 0.5, period, np.pi]
try:
popt, _, pi_pulse_parameter = utils.fit_amplitude_function(
x,
Expand Down
4 changes: 2 additions & 2 deletions src/qibocal/protocols/rabi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@ def fit_amplitude_function(
p0=guess,
maxfev=100000,
bounds=(
[0, 0, 0, -np.pi],
[1, 1, np.inf, np.pi],
[0, 0, 0, 0],
[1, 1, np.inf, 2 * np.pi],
),
sigma=sigma,
)
Expand Down
11 changes: 8 additions & 3 deletions src/qibocal/protocols/two_qubit_interaction/chevron/chevron.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,17 @@ def _fit(data: ChevronData) -> ChevronResults:
amplitude, index, delta = fit_flux_amplitude(signal_matrix, amps, times)
# estimate duration by rabi curve at amplitude previously estimated
y = signal_matrix[index, :].ravel()

try:
popt, _ = curve_fit(
chevron_fit, times, y, p0=[delta, 0, np.mean(y), np.mean(y)]
chevron_fit,
times,
y,
p0=[delta * 2 * np.pi, np.pi, np.mean(y), np.mean(y)],
bounds=(
[0, -2 * np.pi, np.min(y), np.min(y)],
[np.inf, 2 * np.pi, np.max(y), np.max(y)],
),
)

# duration can be estimated as the period of the oscillation
duration = 1 / (popt[0] / 2 / np.pi)
amplitudes[pair] = amplitude
Expand Down
15 changes: 6 additions & 9 deletions src/qibocal/protocols/two_qubit_interaction/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from statistics import median_high

import numpy as np
from qibolab.platform import Platform
from qibolab.qubits import QubitId, QubitPairId
Expand All @@ -23,10 +21,8 @@ def fit_flux_amplitude(matrix, amps, times):

Given the pattern of a chevron plot (see for example Fig. 2 here
https://arxiv.org/pdf/1907.04818.pdf). This function estimates
the CZ amplitude by finding the amplitude which gives the highest
oscillation period. In case there are multiple values with the same
period, given the symmetry, the median value is chosen.
The FFT also gives a first estimate for the duration of the CZ gate.
the CZ amplitude by finding the amplitude which gives the standard
deviation, indicating that there are oscillation along the z axis.

Args:
matrix (np.ndarray): signal matrix
Expand All @@ -42,13 +38,14 @@ def fit_flux_amplitude(matrix, amps, times):
size_amp = len(amps)
time_step = times[1] - times[0]
fs = []
std = []
for i in range(size_amp):
y = matrix[i, :]
period = fallback_period(guess_period(times, y))
fs.append(1 / period)
std.append(np.std(y))

low_freq_interval = np.where(fs == np.min(fs))
amplitude = median_high(amps[::-1][low_freq_interval])
amplitude = amps[np.argmax(std)]
delta = fs[np.argmax(std)]
index = int(np.where(np.unique(amps) == amplitude)[0])
delta = np.min(fs)
return amplitude, index, delta