Source code for bragi_quantum.experiments.nodes.readout.ro_amplitude_optimization.parameters

# ══════════════════════════════════════════════════════════════════════════
#     ___   ___ ___   _      _   ___
#    / _ \ / __|_  ) | |    /_\ | _ )
#   | (_) | (__ / /  | |__ / _ \| _ \
#    \__\_\\___/___| |____/_/ \_\___/
#
#   QC2 @ CHALMERS CALIBRATION TOOLKIT
#   (c) 2026 Chalmers University of Technology and Project Contributors
# ──────────────────────────────────────────────────────────────────────────
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       https://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
# ──────────────────────────────────────────────────────────────────────────
#   CONTRIBUTORS list:
#
#   Matteo Robbiati, robbiati@chalmers.se
#   Michele Faucci Giannelli, faucci@chalmers.se
#   Axel Andersson, axean@chalmers.se
# ══════════════════════════════════════════════════════════════════════════


"""Parameters and QOI classes for readout amplitude optimisation."""

from typing import Any, override

from bragi_quantum.experiments.abstract.parameter_fields import acquisition_field
from bragi_quantum.experiments.abstract.parameters import (
    BaseParameters,
    BaseQoi,
)


[docs] class ROAmplitudeOptimizationParameters(BaseParameters): """Configuration for readout amplitude optimisation nodes.""" # All data acquisition — sweep sizing / averaging, fixed by the measurement. repetitions: int = acquisition_field(default=1024) amplitude_bins: int = acquisition_field(default=30) amplitude_lower_fraction: float = acquisition_field(default=0.25) amplitude_upper_fraction: float = acquisition_field(default=1.2)
[docs] class ROTwoStateAmplitudeOptimizationQOI(BaseQoi): """QOI for the 2-state (\\|0>, \\|1>) RO amplitude optimisation.""" amplitude: float = 0.0 rotation: float = 0.0 threshold: float = 0.0 fidelity: float = 0.0 lda_coef_0: float = 0.0 lda_coef_1: float = 0.0 lda_intercept: float = 0.0 center_I_0: float = 0.0 center_Q_0: float = 0.0 center_I_1: float = 0.0 center_Q_1: float = 0.0
[docs] @override def to_dict(self) -> dict[str, Any]: return { "measure_2state_opt.pulse_amp": self.amplitude, "measure_2state_opt.acq_rotation": self.rotation, "measure_2state_opt.acq_threshold": self.threshold, }
[docs] def to_redis_dict(self) -> dict[str, dict[str, float]]: return { # Device attributes — loaded back by load_calibration_state "measure_2state_opt:pulse_amp": {"value": self.amplitude, "error": 0.0}, "measure_2state_opt:acq_rotation": {"value": self.rotation, "error": 0.0}, "measure_2state_opt:acq_threshold": {"value": self.threshold, "error": 0.0}, # Diagnostic — persisted in Redis / extended_state for tracing; silently # skipped by load_calibration_state (no matching device attribute) "measure_2state_opt:fidelity": {"value": self.fidelity, "error": 0.0}, "measure_2state_opt:lda_coef_0": {"value": self.lda_coef_0, "error": 0.0}, "measure_2state_opt:lda_coef_1": {"value": self.lda_coef_1, "error": 0.0}, "measure_2state_opt:lda_intercept": { "value": self.lda_intercept, "error": 0.0, }, "measure_2state_opt:center_I_0": {"value": self.center_I_0, "error": 0.0}, "measure_2state_opt:center_Q_0": {"value": self.center_Q_0, "error": 0.0}, "measure_2state_opt:center_I_1": {"value": self.center_I_1, "error": 0.0}, "measure_2state_opt:center_Q_1": {"value": self.center_Q_1, "error": 0.0}, }
[docs] class ROThreeStateAmplitudeOptimizationQOI(BaseQoi): """QOI for the 3-state (\\|0>, \\|1>, \\|2>) RO amplitude optimisation.""" amplitude: float = 0.0 centroid_I: float = 0.0 centroid_Q: float = 0.0 omega_01: float = 0.0 omega_12: float = 0.0 omega_20: float = 0.0 inv_cm_opt: str = "" fidelity: float = 0.0
[docs] @override def to_dict(self) -> dict[str, Any]: return { "measure_3state_opt.pulse_amp": self.amplitude, "measure_3state_opt.acq_rotation": self.omega_01, }
[docs] def to_redis_dict(self) -> dict[str, dict[str, float]]: return { # Device attributes — loaded back by load_calibration_state "measure_3state_opt:pulse_amp": {"value": self.amplitude, "error": 0.0}, "measure_3state_opt:acq_rotation": {"value": self.omega_01, "error": 0.0}, # Diagnostic — persisted for tracing; silently skipped on reload "measure_3state_opt:centroid_I": {"value": self.centroid_I, "error": 0.0}, "measure_3state_opt:centroid_Q": {"value": self.centroid_Q, "error": 0.0}, "measure_3state_opt:omega_12": {"value": self.omega_12, "error": 0.0}, "measure_3state_opt:omega_20": {"value": self.omega_20, "error": 0.0}, "measure_3state_opt:fidelity": {"value": self.fidelity, "error": 0.0}, # inv_cm_opt is a string — cannot be stored as float in Redis hash }