Source code for bragi_quantum.experiments.nodes.coupler.resonator_spectroscopy_vs_current.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
#   Abdullah-Al Amin, alamina@chalmers.se
#   Matteo Robbiati, robbiati@chalmers.se
#   Michele Faucci Giannelli, faucci@chalmers.se
#   Yanchen Lin, linya@chalmers.se
# ══════════════════════════════════════════════════════════════════════════


# This code is part of Tergite
#
# (C) Copyright Eleftherios Moschandreou 2023, 2024
# (C) Copyright Michele Faucci Giannelli 2024, 2025
# (C) Copyright Stefan Hill 2024, 2025
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
#
# Modified from tergite-autocalibration
# (https://github.com/tergite/tergite-autocalibration), file:
#   tergite_autocalibration/lib/nodes/coupler/spectroscopy/node.py


"""
Node implementation for Resonator Spectroscopy vs coupler DC current.

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

from typing import Any, 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.resonator_spectroscopy_vs_current.analysis import (
    ResonatorSpectroscopyVsCurrentAnalysis,
)
from bragi_quantum.experiments.nodes.coupler.resonator_spectroscopy_vs_current.parameters import (
    ResonatorSpectroscopyVsCurrentParameters,
    ResonatorSpectroscopyVsCurrentQOI,
)
from bragi_quantum.experiments.nodes.external_parameter_node import (
    ExternalParameterFixedScheduleCouplerNode,
)
from bragi_quantum.experiments.nodes.readout.resonator_spectroscopy.measurement import (
    ResonatorSpectroscopyMeasurement,
)
from bragi_quantum.experiments.utils.samplespace import resonator_samples


[docs] class ResonatorSpectroscopyVsCurrent(ExternalParameterFixedScheduleCouplerNode): """ Resonator spectroscopy on both qubits of each coupler while sweeping the coupler's DC bias current via the SPI rack. The resonator schedule is compiled once; for every current in the external samplespace the coupler DACs are ramped and the schedule is re-executed. The analysis tracks the fitted resonator frequency versus current and reports the currents at which the coupler crosses the resonator. """ measurement_cls = ResonatorSpectroscopyMeasurement analysis_cls = ResonatorSpectroscopyVsCurrentAnalysis parameters: ResonatorSpectroscopyVsCurrentParameters def __init__( self, parameters: ResonatorSpectroscopyVsCurrentParameters, qoi_cls: type[ ResonatorSpectroscopyVsCurrentQOI ] = ResonatorSpectroscopyVsCurrentQOI, ): super().__init__( parameters=parameters, qoi_cls=qoi_cls, ) self.schedule_keywords = { "readout_state": self.parameters.readout_state, "repetitions": self.parameters.repetitions, } self.schedule_samplespace = { "ro_frequencies": { qubit: resonator_samples( qubit, state=self.parameters.readout_state, samples=self.parameters.samples, half_width=self.parameters.half_width, ) for qubit in self.all_qubits } } self.external_samplespace = { "dc_currents": { coupler: np.arange( self.parameters.min_current, self.parameters.max_current, self.parameters.current_step, ) 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): # The measured schedule is a plain resonator spectroscopy on the # coupled qubits; the coupler only enters through the DC bias. return self.measurement_cls(self.transmons)
[docs] @override def pre_measurement_operation(self, reduced_ext_space: dict[str, Any]) -> None: """Ramp the coupler DACs to this iteration's currents before measuring.""" if self.spi_manager is None: raise RuntimeError( "No SPI DAC handler in the active session — the DC-current sweep " "requires the device template's spi.yaml and measurement mode. If " "this is unexpected, check if SessionOptions.spi_serial_port was " "explicitly set to None." ) self.spi_manager.set_dac_currents(reduced_ext_space["dc_currents"])
[docs] @override def final_operation(self) -> None: """Ramp all swept coupler DACs back to zero after the sweep.""" logger.info("Ramping coupler currents back to 0 A.") self.spi_manager.set_dac_currents({coupler: 0.0 for coupler in self.couplers})