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

Dump report after each protocol #438

Merged
merged 6 commits into from
Jul 10, 2023
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
1 change: 1 addition & 0 deletions src/qibocal/auto/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,4 @@ def run(self):
if self.platform is not None:
if self.update and task.update:
self.platform.update(completed.results.update)
yield
1 change: 0 additions & 1 deletion src/qibocal/cli/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def command(runcard, folder, force, update):
builder.run()
if update:
builder.dump_platform_runcard()
builder.dump_report()


@click.command(context_settings=CONTEXT_SETTINGS)
Expand Down
4 changes: 2 additions & 2 deletions src/qibocal/cli/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ def _prepare_output(self, runcard):

def run(self):
"""Execute protocols in runcard."""

if self.platform is not None:
self.platform.connect()
self.platform.setup()
self.platform.start()

self.executor.run()
for _ in self.executor.run():
self.dump_report()

if self.platform is not None:
self.platform.stop()
Expand Down
27 changes: 25 additions & 2 deletions src/qibocal/protocols/characterization/resonator_spectroscopy.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from dataclasses import dataclass, field
from dataclasses import dataclass, field, fields
from typing import Optional, Union

import numpy as np
Expand All @@ -9,7 +9,14 @@
from qibolab.qubits import QubitId
from qibolab.sweeper import Parameter, Sweeper, SweeperType

from qibocal.auto.operation import Data, Parameters, Qubits, Results, Routine
from qibocal.auto.operation import (
Data,
Parameters,
ParameterValue,
Qubits,
Results,
Routine,
)

from .utils import PowerLevel, lorentzian_fit, spectroscopy_plot

Expand Down Expand Up @@ -61,6 +68,22 @@ class ResonatorSpectroscopyResults(Results):
)
"""Readout attenuation [dB] for each qubit."""

@property
def update(self):
"""Method overwritten from Results to not update
amplitude when running resonator spectroscopy at
high power."""
up: dict[str, ParameterValue] = {}
if self.bare_frequency == {}:
fields_to_updated = [fld for fld in fields(self) if fld.name != "amplitude"]
else:
fields_to_updated = fields(self)
andrea-pasquale marked this conversation as resolved.
Show resolved Hide resolved
for fld in fields_to_updated:
if "update" in fld.metadata:
up[fld.metadata["update"]] = getattr(self, fld.name)

return up


ResSpecType = np.dtype(
[("freq", np.float64), ("msr", np.float64), ("phase", np.float64)]
Expand Down
6 changes: 0 additions & 6 deletions src/qibocal/protocols/characterization/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def spectroscopy_plot(data, fit: Results, qubit):
qubit_data = data[qubit]

fitting_report = ""

frequencies = qubit_data.freq * HZ_TO_GHZ
fig.add_trace(
go.Scatter(
Expand Down Expand Up @@ -145,14 +144,9 @@ def spectroscopy_plot(data, fit: Results, qubit):
else:
label = "qubit frequency"
freq = fit.frequency

fitting_report += f"{qubit} | {label}: {freq[qubit]*GHZ_TO_HZ:,.0f} Hz<br>"

if fit.amplitude[qubit] is not None:
fitting_report += f"{qubit} | amplitude: {fit.amplitude[qubit]} <br>"
if data.power_level is PowerLevel.high:
# TODO: find better solution for not updating amplitude in high power
fit.amplitude.pop(qubit)

if data.__class__.__name__ == "ResonatorSpectroscopyAttenuationData":
if fit.attenuation[qubit] is not None and fit.attenuation[qubit] != 0:
Expand Down
3 changes: 2 additions & 1 deletion tests/test_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def test_execution(card: pathlib.Path):
"""
testcard = TestCard(**yaml.safe_load(card.read_text(encoding="utf-8")))
executor = Executor.load(testcard.runcard, output=pathlib.Path(tempfile.mkdtemp()))
executor.run()
for _ in executor.run():
pass

assert testcard.validation.result == [step[0] for step in executor.history]
4 changes: 2 additions & 2 deletions tests/test_task_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"freq_width": 10_000_000,
"freq_step": 100_000,
"amplitude": 0.4,
"power_level": "low",
"power_level": "high",
},
},
],
Expand Down Expand Up @@ -99,7 +99,7 @@ def test_update_argument(global_update, local_update):
platform.qubits,
global_update,
)
executor.run()
next(executor.run())
if local_update and global_update:
assert old_readout_frequency != platform.qubits[0].readout_frequency
else:
Expand Down