# ══════════════════════════════════════════════════════════════════════════
# ___ ___ ___ _ _ ___
# / _ \ / __|_ ) | | /_\ | _ )
# | (_) | (__ / / | |__ / _ \| _ \
# \__\_\\___/___| |____/_/ \_\___/
#
# 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:
#
# Filip Eriksson, filieri@chalmers.se
# Joel Sandås, joel.sandas@chalmers.se
# Matteo Robbiati, robbiati@chalmers.se
# ══════════════════════════════════════════════════════════════════════════
from typing import override
from bragi_quantum.experiments.abstract.parameter_fields import acquisition_field
from bragi_quantum.experiments.abstract.parameters import BaseQoi
from bragi_quantum.experiments.nodes.coupler.cz_parametrization.parameters import (
CZParametrizationFixDurationParameters,
)
[docs]
class CZWallFinderParameters(CZParametrizationFixDurationParameters):
"""
Parameters for the CZ wall finder.
Sweeps the coupler's CZ flux pulse amplitude at a single fixed frequency
(the coupler's CZ transition frequency) to find, per qubit, the amplitude
beyond which the magnitude response departs from its baseline -- a "wall"
past which driving the coupler further is unsafe or uncontrolled. Ported
from tergite-autocalibration (CZWallFinder).
Reuses CZParametrizationFixDuration's fields (``cz_pulse_duration``,
``cz_transition``, ``max_transition_frequency``, ...) and its measurement;
``frequency_sweep`` / ``frequency_bins`` are inherited but unused here --
the frequency sweep always collapses to the single point at the coupler's
CZ transition frequency.
"""
amplitude_max: float = acquisition_field(
default=1.0,
ge=-1,
le=1,
description="End of the amplitude sweep (fullscale); capped at 0.70 to stay "
"under the AWG gain limit.",
)
amplitude_bins: int = acquisition_field(
default=21, description="Number of amplitude points."
)
[docs]
class CZWallFinderQOI(BaseQoi):
"""
Quantities of Interest for the CZ wall finder on one coupler: the wall
amplitude, the more conservative (lower) of its two qubits' wall
amplitudes. Informational only -- there is no device field to update, so
``to_redis_dict`` uses a plain (non-``submodule:field``) key.
"""
coupler_wall_amplitude: float = 1.0
[docs]
def items(self):
"""
Iterate like a mapping so bragi_quantum.datalayer's ``update_redis_trusted_values`` can
inspect the QOI keys when routing coupler results.
"""
return self.to_dict().items()
[docs]
@override
def to_dict(self) -> dict:
return {"coupler_wall_amplitude": self.coupler_wall_amplitude}
[docs]
def to_redis_dict(self) -> dict[str, dict]:
return {
"coupler_wall_amplitude": {
"value": self.coupler_wall_amplitude,
"error": 0.0,
}
}