Source code for bragi_quantum.experiments.nodes.coupler.cz_parametrization.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:
#
#   Axel Andersson, axean@chalmers.se
#   Joel Sandås, joel.sandas@chalmers.se
#   Matteo Robbiati, robbiati@chalmers.se
#   Michele Faucci Giannelli, faucci@chalmers.se
# ══════════════════════════════════════════════════════════════════════════


"""
Node implementation for CZ parametrization with a fixed pulse duration.

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

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_parametrization.analysis import (
    CZParametrizationFixDurationAnalysis,
)
from bragi_quantum.experiments.nodes.coupler.cz_parametrization.measurement import (
    CZParametrizationFixDurationMeasurement,
)
from bragi_quantum.experiments.nodes.coupler.cz_parametrization.parameters import (
    CZParametrizationFixDurationParameters,
    CZParametrizationFixDurationQOI,
)
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 CZParametrizationFixDuration(ScheduleCouplerNode): """ Tests a candidate CZ working-point current by sweeping the coupler's flux pulse frequency and amplitude (duration held fixed). Both qubits of a coupler are excited to |1> and the coupler flux pulse is applied at every (frequency, amplitude) 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. """ measurement_cls = CZParametrizationFixDurationMeasurement analysis_cls = CZParametrizationFixDurationAnalysis parameters: CZParametrizationFixDurationParameters def __init__( self, parameters: CZParametrizationFixDurationParameters, qoi_cls: type[ CZParametrizationFixDurationQOI ] = CZParametrizationFixDurationQOI, ): 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_duration": { coupler: self.parameters_by_coupler[coupler].cz_pulse_duration 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_amplitudes": { coupler: self._amplitude_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 _amplitude_sweep(self, coupler: str) -> np.ndarray: params = self.parameters_by_coupler[coupler] # amp=1.0 rounds up past the AWG gain limit during compilation, so cap # the sweep range itself (rather than clipping individual points # afterwards, which can break the strictly increasing point order). max_amplitude = min(params.amplitude_max, 0.70) return np.linspace(params.amplitude_min, max_amplitude, params.amplitude_bins)