Source code for bragi_quantum.experiments.nodes.coupler.cz_chevron.node

# ══════════════════════════════════════════════════════════════════════════
#     ___   ___ ___   _      _   ___
#    / _ \ / __|_  ) | |    /_\ | _ )
#   | (_) | (__ / /  | |__ / _ \| _ \
#    \__\_\\___/___| |____/_/ \_\___/
#
#   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:
#
#   Joel Sandås, joel.sandas@chalmers.se
#   Axel Andersson, axean@chalmers.se
#   Matteo Robbiati, robbiati@chalmers.se
#   Michele Faucci Giannelli, faucci@chalmers.se
# ══════════════════════════════════════════════════════════════════════════


"""
Node implementation for the CZ chevron (fixed pulse amplitude).

Ported from tergite-autocalibration (CZChevronNode).
"""

from typing import override

import numpy as np

from bragi_quantum.datalayer.models.qubit import ExtendedTransmon
from bragi_quantum.datalayer.utils.logging import logger
from bragi_quantum.experiments.nodes.coupler.cz_chevron.analysis import (
    CZChevronAnalysis,
)
from bragi_quantum.experiments.nodes.coupler.cz_chevron.measurement import (
    CZChevronMeasurement,
)
from bragi_quantum.experiments.nodes.coupler.cz_chevron.parameters import (
    CZChevronParameters,
    CZChevronQOI,
)
from bragi_quantum.experiments.nodes.coupler.cz_transition_frequency import (
    get_cz_transition_frequency,
)
from bragi_quantum.experiments.nodes.schedule_node import ScheduleCouplerNode


[docs] class CZChevron(ScheduleCouplerNode): """ Tests a candidate CZ working-point current by sweeping the coupler's flux pulse frequency and duration (amplitude held fixed). Both qubits of a coupler are excited to |1> and the coupler flux pulse is applied at every (frequency, duration) point; the analysis looks for the point where population exchanges into the targeted |20> or |02> state (``parameters.cz_transition``), consistently between both qubits — i.e. whether a usable CZ avoided crossing exists at this current — and refines the CZ pulse duration from the resulting oscillation period. """ measurement_cls = CZChevronMeasurement analysis_cls = CZChevronAnalysis parameters: CZChevronParameters def __init__( self, parameters: CZChevronParameters, qoi_cls: type[CZChevronQOI] = CZChevronQOI, ): super().__init__(parameters=parameters, qoi_cls=qoi_cls) valid_couplers = [] for coupler in self.couplers: if ( self._transition_frequency(coupler) > self.parameters.max_transition_frequency ): logger.warning( f"Coupler {coupler} skipped: transition frequency exceeds " f"max_transition_frequency=" f"{self.parameters.max_transition_frequency / 1e6:.3f} MHz." ) continue valid_couplers.append(coupler) self.couplers = valid_couplers self.all_qubits = sorted(set(self.get_coupled_qubits())) self.schedule_keywords = { "repetitions": self.parameters.repetitions, "cz_pulse_amplitude": { coupler: self.parameters_by_coupler[coupler].cz_pulse_amplitude for coupler in self.couplers }, "downconvert_frequency": { coupler: self.parameters_by_coupler[coupler].downconvert_frequency for coupler in self.couplers }, } self.schedule_samplespace = { "cz_pulse_frequencies": { coupler: self._frequency_sweep(coupler) for coupler in self.couplers }, "cz_pulse_durations": { coupler: self._duration_sweep(coupler) for coupler in self.couplers }, } @property def transmons(self) -> dict[str, ExtendedTransmon]: """The coupled qubits' transmons; measured (and read out) by this node.""" return {k: v for k, v in self.device.elements.items() if k in self.all_qubits} @override def _build_measurement(self): return self.measurement_cls(self.transmons, self.edges) def _transition_frequency(self, coupler: str) -> float: """ CZ transition frequency (Hz): the detuning between the |11> state and the targeted |20> / |02> state. Prefers the value saved to Redis by cz_currents_from_spectroscopies; falls back to computing it from the qubits' calibrated 01/12 clock frequencies if Redis has nothing stored yet. """ params = self.parameters_by_coupler[coupler] return get_cz_transition_frequency( device=self.device, redis_connection=self.redis_connection, coupler=coupler, cz_transition=params.cz_transition, cz_half_frequency_wp=params.cz_half_frequency_wp, ) def _frequency_sweep(self, coupler: str) -> np.ndarray: params = self.parameters_by_coupler[coupler] center = self._transition_frequency(coupler) return ( np.linspace( -params.frequency_sweep, params.frequency_sweep, params.frequency_bins ) + center ) def _duration_sweep(self, coupler: str) -> np.ndarray: params = self.parameters_by_coupler[coupler] return np.linspace( params.duration_min, params.duration_max, params.duration_bins )