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

Removing precision sweep #270

Merged
merged 9 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
30 changes: 12 additions & 18 deletions runcards/actions_qq_1q.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,16 @@ format: csv
actions:

# resonator_spectroscopy: # wide
# fast_width: 30_000_000
# fast_step: 1_000_000
# precision_width: 2_000_000
# precision_step: 100_000
# freq_width: 30_000_000
# freq_step: 1_000_000
# software_averages: 1
# points: 5

resonator_spectroscopy: # narrow
fast_width: 10_000_000
fast_step: 500_000
precision_width: 1_000_000
precision_step: 50_000
software_averages: 2
points: 5
# resonator_spectroscopy: # narrow
# freq_width: 10_000_000
# freq_step: 500_000
# software_averages: 2
# points: 5

# resonator_punchout:
# freq_width: 10_000_000
Expand Down Expand Up @@ -51,13 +47,11 @@ actions:



qubit_spectroscopy: # wide
fast_width: 500_000_000
fast_step: 2_000_000
precision_width: 2_000_000
precision_step: 100_000
software_averages: 1
points: 5
# qubit_spectroscopy: # wide
# freq_width: 500_000_000
# freq_step: 2_000_000
# software_averages: 1
# points: 5


# qubit_spectroscopy_flux: # precission
Expand Down
24 changes: 8 additions & 16 deletions runcards/actions_qq_5q.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,14 @@ format: csv
actions:

# resonator_spectroscopy: # wide
# fast_width: 30_000_000
# fast_step: 1_000_000
# precision_width: 2_000_000
# precision_step: 100_000
# freq_width: 30_000_000
# freq_step: 1_000_000
# software_averages: 2
# points: 5

# resonator_spectroscopy: # narrow
# fast_width: 10_000_000
# fast_step: 500_000
# precision_width: 1_000_000
# precision_step: 50_000
# freq_width: 10_000_000
# freq_step: 500_000
# software_averages: 2
# points: 5

Expand Down Expand Up @@ -53,18 +49,14 @@ actions:


# qubit_spectroscopy: # wide
# fast_width: 500_000_000
# fast_step: 2_000_000
# precision_width: 2_000_000
# precision_step: 100_000
# freq_width: 500_000_000
# freq_step: 2_000_000
# software_averages: 1
# points: 5

# qubit_spectroscopy: # narrow
# fast_width: 5_000_000
# fast_step: 500_000
# precision_width: 400_000
# precision_step: 20_000
# freq_width: 5_000_000
# freq_step: 500_000
# software_averages: 2
# points: 5

Expand Down
28 changes: 10 additions & 18 deletions runcards/dummy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,23 @@ format: csv
actions:

# resonator_spectroscopy: # wide
# fast_width: 30_000_000
# fast_step: 1_000_000
# precision_width: 2_000_000
# precision_step: 100_000
# freq_width: 30_000_000
# freq_step: 1_000_000
# software_averages: 1
# points: 5

# resonator_spectroscopy: # narrow
# fast_width: 10_000_000
# fast_step: 500_000
# precision_width: 1_000_000
# precision_step: 50_000
# freq_width: 10_000_000
# freq_step: 500_000
# software_averages: 2
# points: 5

# resonator_punchout:
# freq_width: 10_000_000
# freq_step: 200_000
# freq_step: 2000_000
# min_att: 2
# max_att: 50
# step_att: 2
# step_att: 4
# software_averages: 1
# points: 5

Expand All @@ -52,18 +48,14 @@ actions:


# qubit_spectroscopy: # wide
# fast_width: 500_000_000
# fast_step: 2_000_000
# precision_width: 2_000_000
# precision_step: 100_000
# freq_width: 500_000_000
# freq_step: 2_000_00000
# software_averages: 1
# points: 5

# qubit_spectroscopy: # narrow
# fast_width: 5_000_000
# fast_step: 500_000
# precision_width: 400_000
# precision_step: 20_000
# freq_width: 5_000_000
# freq_step: 500_000
# software_averages: 2
# points: 5

Expand Down
122 changes: 14 additions & 108 deletions src/qibocal/calibrations/characterization/qubit_spectroscopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@
def qubit_spectroscopy(
platform: AbstractPlatform,
qubits: dict,
fast_width,
fast_step,
precision_width,
precision_step,
freq_width: int,
freq_step: int,
software_averages=1,
points=10,
):
Expand All @@ -29,10 +27,8 @@ def qubit_spectroscopy(
platform (AbstractPlatform): Qibolab platform object
qubits (dict): Dict of target Qubit objects to perform the action
fast_start (int): Initial frequency in HZ to perform the qubit fast sweep
fast_width (int): Width frequency in HZ to perform the high resolution sweep
fast_step (int): Step frequency in HZ for the high resolution sweep
precision_width (int): Width frequency in HZ to perform the precision resolution sweep
precision_step (int): Step frequency in HZ for the precission resolution sweep
freq_width (int): Width frequency in HZ to perform the high resolution sweep
freq_step (int): Step frequency in HZ for the high resolution sweep
software_averages (int): Number of executions of the routine for averaging results
points (int): Save data results in a file every number of points

Expand Down Expand Up @@ -77,13 +73,13 @@ def qubit_spectroscopy(
sequence.add(ro_pulses[qubit])

# define the parameter to sweep and its range:
delta_frequency_range = np.arange(-fast_width // 2, fast_width // 2, fast_step)
delta_frequency_range = np.arange(-freq_width // 2, freq_width // 2, freq_step)

# create a DataUnits object to store the results,
# DataUnits stores by default MSR, phase, i, q
# additionally include qubit frequency
fast_sweep_data = DataUnits(
name="fast_sweep_data",
data = DataUnits(
name="data",
quantities={"frequency": "Hz"},
options=["qubit", "iteration"],
)
Expand All @@ -96,11 +92,11 @@ def qubit_spectroscopy(
# save data as often as defined by points
if count % points == 0 and count > 0:
# save data
yield fast_sweep_data
yield data
# calculate and save fit
yield lorentzian_fit(
fast_sweep_data,
x="frequency[Hz]",
data,
x="frequency[GHz]",
y="MSR[uV]",
qubits=qubits,
resonator_type=platform.resonator_type,
Expand All @@ -127,103 +123,13 @@ def qubit_spectroscopy(
"iteration": iteration,
}
)
fast_sweep_data.add(r)
data.add(r)
count += 1
# finally, save the remaining data and fits
yield fast_sweep_data
yield lorentzian_fit(
fast_sweep_data,
x="frequency[Hz]",
y="MSR[uV]",
qubits=qubits,
resonator_type=platform.resonator_type,
labels=["drive_frequency", "peak_voltage"],
)

# store max/min peaks as new frequencies
for qubit in qubits:
qubit_data = (
fast_sweep_data.df[fast_sweep_data.df["qubit"] == qubit]
.drop(columns=["qubit", "iteration"])
.groupby("frequency", as_index=False)
.mean()
)
if platform.resonator_type == "3D":
qubits[qubit].drive_frequency = (
qubit_data["frequency"][
np.argmin(qubit_data["MSR"].pint.to("V").pint.magnitude)
]
.to("Hz")
.magnitude
)
else:
qubits[qubit].drive_frequency = (
qubit_data["frequency"][
np.argmax(qubit_data["MSR"].pint.to("V").pint.magnitude)
]
.to("Hz")
.magnitude
)

# run a precision sweep around the newly detected frequencies

delta_frequency_range = np.arange(
-precision_width // 2, precision_width // 2, precision_step
)

# create a second DataUnits object to store the results,
precision_sweep_data = DataUnits(
name="precision_sweep_data",
quantities={"frequency": "Hz"},
options=["qubit", "iteration"],
)

# repeat the experiment as many times as defined by software_averages
count = 0
for iteration in range(software_averages):
# sweep the parameter
for delta_freq in delta_frequency_range:
# save data as often as defined by points
if count % points == 0 and count > 0:
# save data
yield precision_sweep_data
# calculate and save fit
yield lorentzian_fit(
precision_sweep_data,
x="frequency[Hz]",
y="MSR[uV]",
qubits=qubits,
resonator_type=platform.resonator_type,
labels=["resonator_freq", "peak_voltage"],
)
# reconfigure the instrument based on the new resonator frequency
# in this case setting the local oscillators
# the pulse sequence does not need to be modified between executions
for qubit in qubits:
qd_pulses[qubit].frequency = delta_freq + qubits[qubit].drive_frequency

# execute the pulse sequence
results = platform.execute_pulse_sequence(sequence)

# retrieve the results for every qubit
for ro_pulse in ro_pulses.values():
# average msr, phase, i and q over the number of shots defined in the runcard
r = results[ro_pulse.serial].to_dict()
# store the results
r.update(
{
"frequency[Hz]": qd_pulses[ro_pulse.qubit].frequency,
"qubit": ro_pulse.qubit,
"iteration": iteration,
}
)
precision_sweep_data.add(r)
count += 1
# finally, save the remaining data and fits
yield precision_sweep_data
yield data
yield lorentzian_fit(
precision_sweep_data,
x="frequency[Hz]",
data,
x="frequency[GHz]",
y="MSR[uV]",
qubits=qubits,
resonator_type=platform.resonator_type,
Expand Down
Loading