Source code for bragi_quantum.experiments.nodes.coupler.cz_phases.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 CZ phase calibration.

Ported from tergite-autocalibration (CZConditionalPhaseSSRONode /
CZLocalPhaseSSRONode / CZLocalPhaseSwapSSRONode). Those three node classes
differed only by two booleans on an otherwise-identical measurement and
analysis, so here they collapse into one node class, registered in
nodes.yaml as three ``parameters:``-variants of it (``cz_phases_conditional``,
``cz_phases_local``, ``cz_phases_local_swap``).
"""

from typing import override

import numpy as np

from bragi_quantum.datalayer.models.qubit import ExtendedTransmon
from bragi_quantum.experiments.abstract.parameters import BaseQoi
from bragi_quantum.experiments.nodes.coupler.cz_phases.analysis import CZPhasesAnalysis
from bragi_quantum.experiments.nodes.coupler.cz_phases.measurement import (
    CZPhasesMeasurement,
)
from bragi_quantum.experiments.nodes.coupler.cz_phases.parameters import (
    CZConditionalPhaseQOI,
    CZPhasesParameters,
)
from bragi_quantum.experiments.nodes.schedule_node import ScheduleCouplerNode


[docs] class CZPhases(ScheduleCouplerNode): """ Measures the CZ conditional phase, or (with ``local_phases=True``) one of the two CZ local phases, for each coupler. """ measurement_cls = CZPhasesMeasurement analysis_cls = CZPhasesAnalysis parameters: CZPhasesParameters def __init__( self, parameters: CZPhasesParameters, qoi_cls: type[BaseQoi] = CZConditionalPhaseQOI, ): super().__init__(parameters=parameters, qoi_cls=qoi_cls) self.all_qubits = sorted(set(self.get_coupled_qubits())) ramsey_phases = np.linspace( 0, self.parameters.ramsey_phases_max, self.parameters.ramsey_phases_bins ) self.schedule_keywords = { "repetitions": self.parameters.repetitions, "local_phases": self.parameters.local_phases, "swap_control_and_target": self.parameters.swap_control_and_target, "cz_transition": { coupler: self.parameters_by_coupler[coupler].cz_transition for coupler in self.couplers }, "cz_pulse_frequency": { coupler: float(self.edges[coupler].cz.cz_freq) for coupler in self.couplers }, "cz_pulse_amplitude": { coupler: float(self.edges[coupler].cz.square_amp) for coupler in self.couplers }, "cz_pulse_duration": { coupler: float(self.edges[coupler].cz.square_duration) for coupler in self.couplers }, "control_phase_correction": { coupler: float(self.edges[coupler].cz.control_phase_correction) for coupler in self.couplers }, "target_phase_correction": { coupler: float(self.edges[coupler].cz.target_phase_correction) for coupler in self.couplers }, "downconvert_frequency": { coupler: self.parameters_by_coupler[coupler].downconvert_frequency for coupler in self.couplers }, } self.schedule_samplespace = { "control_ons": {qubit: np.array([0, 1]) for qubit in self.all_qubits}, "ramsey_phases": {qubit: ramsey_phases for qubit in self.all_qubits}, } @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)