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

Update flux script #981

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
26e172f
feat: Add context manager to start execution
alecandido Jul 28, 2024
e9d6852
feat: Expose update toggle for scripts
alecandido Jul 30, 2024
69a3dea
fix: Make use of update parameter, leave it unaltered by default
alecandido Jul 30, 2024
7f969f8
test: Make single shot script example close to minimal
alecandido Jul 30, 2024
fa232cd
docs: Document minimal script example
alecandido Jul 30, 2024
312ec56
test: Make platform explicit, make use of routine result
alecandido Jul 30, 2024
fc0aac8
test: Replace magic imports with explicitly executor-scoped routines
alecandido Jul 30, 2024
972a65f
feat: Expose missing action attributes to scripts
alecandido Jul 30, 2024
09064f3
test: Replace repeated updates with global option
alecandido Jul 30, 2024
2164de6
feat: Coherence Flux
Jacfomg Jul 30, 2024
0f733aa
fix : comments
Jacfomg Jul 30, 2024
b7c7c33
fix: Furtther comments
Jacfomg Jul 30, 2024
b1c82d1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 30, 2024
6a71ca5
fix: Coherence Flux plotting and paths
Jacfomg Jul 31, 2024
31be4e4
Merge branch 'script_coherence' of https://github.com/qiboteam/qiboca…
Jacfomg Jul 31, 2024
1dd9f53
fix: remove executor for platform
Jacfomg Jul 31, 2024
f5c8768
fix: remove history reset
Jacfomg Jul 31, 2024
13cca48
feat: T1 errors flux
Jacfomg Jul 31, 2024
142255d
fix: comments
Jacfomg Jul 31, 2024
e97f61a
feat: first commit of rb using qua
stavros11 May 23, 2024
e18cb5d
acquisition working
stavros11 Jul 23, 2024
958357a
remove specialized data save and load
stavros11 Jul 24, 2024
7cf7fd5
fix fitting
stavros11 Jul 24, 2024
773c2ba
fix data propagation
stavros11 Jul 24, 2024
dbd1302
fix: use platfrom values for sweetspots and device connections
stavros11 Aug 1, 2024
3da0fc8
feat: add debug as an option
stavros11 Aug 1, 2024
e9772c0
fix: fit and report when save_sequences is False
stavros11 Aug 3, 2024
70e10ae
fix: typo in fit results
stavros11 Aug 3, 2024
8eec1ea
Merge branch 'main' into qua
andrea-pasquale Aug 23, 2024
3dad308
fix: Modify ramsey update
andrea-pasquale Sep 4, 2024
941fd03
Merge branch 'fix_ramsey_update' into qua
andrea-pasquale Sep 4, 2024
c1d58c6
fix: improve script
Edoardo-Pedicillo Sep 5, 2024
4667c52
Merge branch 'main' into fix_script
Edoardo-Pedicillo Sep 5, 2024
f57bd11
feat: add readout characterization
Edoardo-Pedicillo Sep 6, 2024
08cc555
Merge branch 'qua' into fix_script
Edoardo-Pedicillo Sep 6, 2024
214cea7
feat: add rb
Edoardo-Pedicillo Sep 9, 2024
3a0e937
fix:update rb params
Edoardo-Pedicillo Sep 11, 2024
db80b1e
refactor:remove comments
Edoardo-Pedicillo Sep 11, 2024
80ffe26
refactor:remove comments 2
Edoardo-Pedicillo Sep 11, 2024
1dbf292
remove t1_errors_flux.py
Edoardo-Pedicillo Sep 11, 2024
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
201 changes: 201 additions & 0 deletions runcards/coherence_flux.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
from argparse import ArgumentParser
from pathlib import Path
from typing import Optional

import numpy as np
from qibolab import create_platform

from qibocal.auto.execute import Executor
from qibocal.cli.report import report
from qibocal.protocols.flux_dependence.utils import (
transmon_frequency,
transmon_readout_frequency,
)

biases = np.arange(-0.025, 0.025, 0.002)
"bias points to sweep"

# Qubit spectroscopy
freq_width = 10_000_000
"""Width [Hz] for frequency sweep relative to the qubit frequency."""
freq_step = 500_000
"""Frequency [Hz] step for sweep."""
drive_duration = 1000
"""Drive pulse duration [ns]. Same for all qubits."""

# Rabi amp signal
min_amp_factor = 0.0
"""Minimum amplitude multiplicative factor."""
max_amp_factor = 1.5
"""Maximum amplitude multiplicative factor."""
step_amp_factor = 0.01
"""Step amplitude multiplicative factor."""

# Flipping
nflips_max = 200
"""Maximum number of flips ([RX(pi) - RX(pi)] sequences). """
nflips_step = 10
"""Flip step."""

# T1 signal
delay_before_readout_start = 16
"""Initial delay before readout [ns]."""
delay_before_readout_end = 100_000
"""Final delay before readout [ns]."""
delay_before_readout_step = 4_000
"""Step delay before readout [ns]."""

# Ramsey signal
detuning = 3_000_000
"""Frequency detuning [Hz]."""
delay_between_pulses_start = 16
"""Initial delay between RX(pi/2) pulses in ns."""
delay_between_pulses_end = 1_000
"""Final delay between RX(pi/2) pulses in ns."""
delay_between_pulses_step = 5
"""Step delay between RX(pi/2) pulses in ns."""

# T2 and Ramsey signal
delay_between_pulses_start_T2 = 16
"""Initial delay between RX(pi/2) pulses in ns."""
delay_between_pulses_end_T2 = 80_000
"""Final delay between RX(pi/2) pulses in ns."""
delay_between_pulses_step_T2 = 500
"""Step delay between RX(pi/2) pulses in ns."""
single_shot_T2: bool = False
"""If ``True`` save single shot signal data."""

# Optional qubit spectroscopy
drive_amplitude: Optional[float] = 0.1
"""Drive pulse amplitude (optional). Same for all qubits."""
hardware_average: bool = True
"""By default hardware average will be performed."""
# Optional rabi amp signal
pulse_length: Optional[float] = 40
"""RX pulse duration [ns]."""
# Optional T1 signal
single_shot_T1: bool = False
"""If ``True`` save single shot signal data."""


parser = ArgumentParser()
parser.add_argument("--target", nargs="+", required=True, help="Target qubit")
parser.add_argument("--platform", type=str, required=True, help="Platform name")
parser.add_argument(
"--path", type=str, default="TTESTCoherenceFlux1", help="Path for the output"
)
args = parser.parse_args()

targets = args.target
path = args.path


fit_function = transmon_frequency
platform = create_platform(args.platform)

for target in targets:
params_qubit = {
"w_max": platform.qubits[target].drive_frequency,
"xj": 0,
"d": platform.qubits[target].asymmetry,
"normalization": platform.qubits[target].crosstalk_matrix[target],
"offset": -platform.qubits[target].sweetspot
* platform.qubits[target].crosstalk_matrix[target],
"crosstalk_element": 1,
"charging_energy": platform.qubits[target].Ec,
}

# NOTE: Center around the sweetspot
centered_biases = biases + platform.qubits[target].sweetspot

for i, bias in enumerate(centered_biases):
with Executor.open(
f"myexec_{i}",
path=args.path / Path(f"flux_{bias}"),
platform=args.platform,
targets=[target],
update=True,
force=True,
) as e:

# Change the flux
e.platform.qubits[target].flux.offset = bias

# Change the qubit frequency
qubit_frequency = fit_function(bias, **params_qubit) # * 1e9

res_frequency = transmon_readout_frequency(
bias,
**params_qubit,
g=platform.qubits[target].g,
resonator_freq=platform.qubits[target].bare_resonator_frequency,
)
e.platform.qubits[target].drive_frequency = qubit_frequency
e.platform.qubits[target].native_gates.RX.frequency = qubit_frequency

res_spectroscopy_output = e.resonator_spectroscopy(
freq_width=freq_width,
freq_step=freq_step,
power_level="low",
relaxation_time=2000,
nshots=1024,
)
rabi_output = e.rabi_amplitude_signal(
min_amp_factor=min_amp_factor,
max_amp_factor=max_amp_factor,
step_amp_factor=step_amp_factor,
pulse_length=e.platform.qubits[target].native_gates.RX.duration,
)

if rabi_output.results.amplitude[target] > 0.5:
print(
f"Rabi fit has pi pulse amplitude {rabi_output.results.amplitude[target]}, greater than 0.5 not possible for QM. Skipping to next bias point."
)
e.platform.qubits[target].native_gates.RX.amplitude = (
0.5 # FIXME: For QM this should be 0.5
)

report(e.path, e.history)
continue

classification_output = e.single_shot_classification(nshots=5000)
ramsey_output = e.ramsey(
delay_between_pulses_start=delay_between_pulses_start,
delay_between_pulses_end=delay_between_pulses_end,
delay_between_pulses_step=delay_between_pulses_step,
detuning=detuning,
)

ramsey_output = e.ramsey(
delay_between_pulses_start=delay_between_pulses_start,
delay_between_pulses_end=delay_between_pulses_end,
delay_between_pulses_step=delay_between_pulses_step,
detuning=detuning,
)
classification_output = e.single_shot_classification(nshots=5000)
t1_output = e.t1(
delay_before_readout_start=delay_before_readout_start,
delay_before_readout_end=delay_before_readout_end,
delay_before_readout_step=delay_before_readout_step,
single_shot=single_shot_T1,
)

ramsey_t2_output = e.ramsey(
delay_between_pulses_start=delay_between_pulses_start_T2,
delay_between_pulses_end=delay_between_pulses_end_T2,
delay_between_pulses_step=delay_between_pulses_step_T2,
detuning=0,
)
readout_characterization_out = e.readout_characterization(
delay=1000,
nshots=5000,
)
rb_out = e.rb_ondevice(
num_of_sequences=10000,
max_circuit_depth=1000,
delta_clifford=20,
n_avg=1,
save_sequences=False,
apply_inverse=True,
)
report(e.path, e.history)
2 changes: 1 addition & 1 deletion src/qibocal/auto/operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def load_data(path: Path, filename: str):
"""Load data stored in a npz file."""
file = path / f"{filename}.npz"
if file.is_file():
raw_data_dict = dict(np.load(file))
raw_data_dict = dict(np.load(file, allow_pickle=True))
data_dict = {}

for data_key, array in raw_data_dict.items():
Expand Down
1 change: 0 additions & 1 deletion src/qibocal/auto/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ def update_platform(platform: Platform, path: Path):
platpath = path / PLATFORM
if platpath.is_dir():
platpath = path / UPDATED_PLATFORM

platpath.mkdir(parents=True, exist_ok=True)
dump_platform(platform, platpath)

Expand Down
19 changes: 11 additions & 8 deletions src/qibocal/cli/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,17 @@ def plotter(
completed node on specific target.
"""
figures, fitting_report = generate_figures_and_report(node, target)
buffer = io.StringIO()
html_list = []
for figure in figures:
figure.write_html(buffer, include_plotlyjs=False, full_html=False)
buffer.seek(0)
html_list.append(buffer.read())
buffer.close()
all_html = "".join(html_list)
if isinstance(figures[0], str):
all_html = "".join(figures)
else:
buffer = io.StringIO()
html_list = []
for figure in figures:
figure.write_html(buffer, include_plotlyjs=False, full_html=False)
buffer.seek(0)
html_list.append(buffer.read())
buffer.close()
all_html = "".join(html_list)
return all_html, fitting_report


Expand Down
2 changes: 2 additions & 0 deletions src/qibocal/protocols/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from .flux_dependence.qubit_flux_tracking import qubit_flux_tracking
from .flux_dependence.resonator_crosstalk import resonator_crosstalk
from .flux_dependence.resonator_flux_dependence import resonator_flux
from .qua import rb_ondevice
from .qubit_power_spectroscopy import qubit_power_spectroscopy
from .qubit_spectroscopy import qubit_spectroscopy
from .qubit_spectroscopy_ef import qubit_spectroscopy_ef
Expand Down Expand Up @@ -146,6 +147,7 @@
"rabi_length_frequency",
"rabi_length_frequency_signal",
"standard_rb_2q",
"rb_ondevice",
"standard_rb_2q_inter",
"optimize_two_qubit_gate",
]
1 change: 1 addition & 0 deletions src/qibocal/protocols/qua/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .rb_ondevice import rb_ondevice
Loading
Loading