Source code for bragi_quantum.experiments.nodes.qubit_control.rabi_oscillations.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
#   Axel Andersson, axean@chalmers.se
#   Hong Quan Trinh, hongq@student.chalmers.se
#   Michele Faucci Giannelli, faucci@chalmers.se
# ══════════════════════════════════════════════════════════════════════════


from typing import Literal, override

from pydantic import Field

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


[docs] class RabiParameters(BaseParameters): """Parameters for Rabi oscillation calibration. The transition field selects the transition: ``transition="01"`` drives 0->1 (the X gate amplitude, ``rxy.amp180``), ``transition="12"`` drives 1->2 (``r12.ef_amp180``). """ transition: Literal["01", "12"] = acquisition_field(default="01", variant=True) # Microwave amplitude sweep — data acquisition min_amplitude: float = acquisition_field( default=-0.9, description="Minimum drive amplitude." ) max_amplitude: float = acquisition_field( default=0.9, description="Maximum drive amplitude." ) amplitude_bins: int = acquisition_field( default=81, description="Number of amplitude steps." ) # Acquisition repetitions: int = acquisition_field( default=1024, description="Number of repetitions (averages) per point." ) # Analysis scaled_uncertainty_analysis_threshold: float = analysis_field( default=2e-2, description="Maximum scaled fit uncertainty for a successful analysis.", ) pi_amplitude_analysis_threshold: float = analysis_field( default=0.95, description="Maximum pi-pulse amplitude for a successful analysis.", )
[docs] class NRabiParameters(RabiParameters): """Parameters for N-Rabi (amplitude-correction) calibration.""" # Narrow correction sweep around the current amp180 — data acquisition min_amplitude: float = acquisition_field( default=-0.09, description="Minimum amplitude correction." ) max_amplitude: float = acquisition_field( default=0.09, description="Maximum amplitude correction." ) amplitude_bins: int = acquisition_field( default=50, description="Number of amplitude-correction steps." ) # Number of X-pulse repetitions per correction trace — data acquisition x_repetitions: list[int] = acquisition_field( default_factory=lambda: [1, 2, 3, 4, 5], description="Numbers of X pulses applied per correction trace.", ) # Analysis sinusoidal_r2_threshold: float = analysis_field( default=0.8, description="Minimum per-slice R² for a slice to enter the joint fit.", ) joint_r2_threshold: float = analysis_field( default=0.75, description=( "Minimum mean R² of the joint sine fit across all valid slices. " "Slightly more permissive than the per-slice threshold because the " "shared correction introduces a constraint that no single slice can " "individually optimise away." ), )
[docs] class RabiBaseQOI(BaseQoi): """Base Quantities of Interest for Rabi oscillations.""" amplitude: float = Field(default=0.0) amplitude_error: float = Field(default=0.0)
[docs] class Rabi01QOI(RabiBaseQOI): """Quantities of Interest for Rabi oscillations (0->1 transition)."""
[docs] @override def to_dict(self) -> dict[str, float]: return {"rxy.amp180": self.amplitude}
[docs] def to_redis_dict(self) -> dict[str, dict[str, float]]: return { "rxy:amp180": {"value": self.amplitude, "error": self.amplitude_error}, }
[docs] class Rabi12QOI(RabiBaseQOI): """Quantities of Interest for Rabi oscillations (1->2 transition)."""
[docs] @override def to_dict(self) -> dict[str, float]: return {"r12.ef_amp180": self.amplitude}
[docs] def to_redis_dict(self) -> dict[str, dict[str, float]]: return { "r12:ef_amp180": {"value": self.amplitude, "error": self.amplitude_error}, }
[docs] class NRabiBaseQOI(RabiBaseQOI): """Base Quantities of Interest for N-Rabi oscillations.""" correction: float = Field(default=0.0) correction_error: float = Field(default=0.0)
[docs] class NRabi01QOI(NRabiBaseQOI): """Quantities of Interest for N-Rabi oscillations (0->1 transition)."""
[docs] @override def to_dict(self) -> dict[str, float]: return {"rxy.amp180": self.amplitude}
[docs] def to_redis_dict(self) -> dict[str, dict[str, float]]: return { "rxy:amp180": {"value": self.amplitude, "error": self.amplitude_error}, "nrabi_correction": { "value": self.correction, "error": self.correction_error, }, }
[docs] class NRabi12QOI(NRabiBaseQOI): """Quantities of Interest for N-Rabi oscillations (1->2 transition)."""
[docs] @override def to_dict(self) -> dict[str, float]: return {"r12.ef_amp180": self.amplitude}
[docs] def to_redis_dict(self) -> dict[str, dict[str, float]]: return { "r12:ef_amp180": {"value": self.amplitude, "error": self.amplitude_error}, "nrabi_correction_12": { "value": self.correction, "error": self.correction_error, }, }