Source code for bragi_quantum.experiments.nodes.qubit_control.ramsey_fringes.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
#   Adrián Navarro Fuentes, adrianfu@chalmers.se
# ══════════════════════════════════════════════════════════════════════════


from typing import Literal, override

import numpy as np
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 RamseyParameters(BaseParameters): """Parameters for Ramsey-fringes (detuning) calibration. The transition field selects the transition: ``transition="01"`` corrects f01, ``transition="12"`` corrects f12. """ transition: Literal["01", "12"] = acquisition_field(default="01", variant=True) # Ramsey delays (s) between the two pi/2 pulses — data acquisition. ramsey_delays: list[float] = acquisition_field( default_factory=lambda: np.arange(4e-9, 2048e-9, 64e-9).tolist(), description="Delays between the two pi/2 pulses, in seconds.", ) # Artificial detunings (Hz) applied via the recovery phase — data acquisition. artificial_detunings: list[float] = acquisition_field( default_factory=lambda: (np.linspace(-2.1, 2.2, 4) * 1e6).tolist(), description="Artificial detunings applied per Ramsey trace, in Hz.", ) # Acquisition repetitions: int = acquisition_field( default=1024, description="Number of repetitions (averages) per point." ) # Which pulse sequence was actually run. "x90_x90" (original, sign-blind: # the population response is an even cos(2*pi*detuning*t), so a single # trace can't recover the detuning's sign) or "x90_y90" (second pulse # rotated 90 deg, making the response sign-carrying — see analysis.py). # Defaults to "x90_x90" to match every dataset recorded before this field # existed; the actual forward default for new acquisitions is set per-node # in nodes.yaml (same pattern as `state`/`transition`), not here. sequence: Literal["x90_x90", "x90_y90"] = acquisition_field( default="x90_x90", variant=True, description="Ramsey pulse sequence run: 'x90_x90' or 'x90_y90'.", ) # Analysis analysis_sequence: Literal["x90_x90", "x90_y90"] | None = analysis_field( default=None, description="Override which fit strategy to use, independent of " "`sequence` — e.g. to force the sign-agnostic folded fit on data " "whose recorded sequence is missing or unknown. Falls back to " "`sequence` when unset.", ) min_r_squared_detune_fit: float = analysis_field( default=0.85, description="Minimum R^2 for a per-detuning Ramsey fit to be accepted.", ) minimum_relative_error_from_fits: float = analysis_field( default=0.02, description="Floor on the relative error of each fitted detuning.", ) min_r_squared_line_fit: float = analysis_field( default=0.9, description="Minimum R^2 (coefficient of determination, fitted vs. " "artificial detuning) accepted for the linear detuning fit. Unlike " "reduced chi-squared, R^2 doesn't depend on the per-point error " "floor, so its scale is fixed regardless of qubit/detuning spread.", )
[docs] class RamseyBaseQOI(BaseQoi): """Base Quantities of Interest for Ramsey fringes.""" frequency: float = Field(default=0.0) frequency_error: float = Field(default=0.0) chi2: float = Field(default=0.0) r_squared: float = Field( default=0.0, description="Coefficient of determination; gates is_successful." )
[docs] class Ramsey01QOI(RamseyBaseQOI): """Quantities of Interest for Ramsey fringes (0->1 transition)."""
[docs] @override def to_dict(self) -> dict[str, float]: return {"clock_freqs.f01": self.frequency}
[docs] def to_redis_dict(self) -> dict[str, dict[str, float]]: return { "clock_freqs:f01": { "value": self.frequency, "error": self.frequency_error, }, }
[docs] class Ramsey12QOI(RamseyBaseQOI): """Quantities of Interest for Ramsey fringes (1->2 transition)."""
[docs] @override def to_dict(self) -> dict[str, float]: return {"clock_freqs.f12": self.frequency}
[docs] def to_redis_dict(self) -> dict[str, dict[str, float]]: return { "clock_freqs:f12": { "value": self.frequency, "error": self.frequency_error, }, }