# ══════════════════════════════════════════════════════════════════════════
# ___ ___ ___ _ _ ___
# / _ \ / __|_ ) | | /_\ | _ )
# | (_) | (__ / / | |__ / _ \| _ \
# \__\_\\___/___| |____/_/ \_\___/
#
# 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:
#
# Matteo Robbiati, robbiati@chalmers.se
# Axel Andersson, axean@chalmers.se
# Michele Faucci Giannelli, faucci@chalmers.se
# ══════════════════════════════════════════════════════════════════════════
# This code is part of Tergite
#
# (C) Copyright Eleftherios Moschandreou 2023, 2024
# (C) Copyright Liangyu Chen 2023, 2024
# (C) Copyright Michele Faucci Giannelli 2024
# (C) Copyright Stefan Hill 2024
#
# 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/readout/ro_frequency_optimization/node.py
"""
Node implementation for readout-frequency optimization.
"""
import numpy as np
from bragi_quantum.experiments.nodes.readout.ro_frequency_optimization.analysis import (
ROThreeStateFrequencyOptimizationAnalysis,
ROTwoStateFrequencyOptimizationAnalysis,
)
from bragi_quantum.experiments.nodes.readout.ro_frequency_optimization.measurement import (
ROFrequencyOptimizationMeasurement,
)
from bragi_quantum.experiments.nodes.readout.ro_frequency_optimization.parameters import (
ROFrequencyOptimizationParameters,
ROThreeStateFrequencyOptimizationQOI,
ROTwoStateFrequencyOptimizationQOI,
)
from bragi_quantum.experiments.nodes.schedule_node import ScheduleQubitNode
from bragi_quantum.experiments.utils.samplespace import resonator_samples
[docs]
class ROTwoStateFrequencyOptimizationNode(ScheduleQubitNode):
"""
Execution node for the 2-state (\\|0>, \\|1>) readout-frequency optimization.
The prepared states are passed as a samplespace (``qubit_states``); the
measurement derives the optimization clock from them, so no ``qubit_state``
schedule keyword is needed (it would clash with the multi-state sweep).
"""
measurement_cls = ROFrequencyOptimizationMeasurement
analysis_cls = ROTwoStateFrequencyOptimizationAnalysis
parameters: ROFrequencyOptimizationParameters
def __init__(
self,
parameters: ROFrequencyOptimizationParameters,
qoi_cls: type[
ROTwoStateFrequencyOptimizationQOI
] = ROTwoStateFrequencyOptimizationQOI,
):
super().__init__(
parameters=parameters,
qoi_cls=qoi_cls,
)
self.schedule_keywords = {"repetitions": self.parameters.repetitions}
self.schedule_samplespace = {
"ro_opt_frequencies": {
qubit: resonator_samples(
qubit,
state=0,
samples=self.parameters_by_qubit[qubit].samples,
half_width=self.parameters_by_qubit[qubit].half_width,
)
for qubit in self.all_qubits
},
"qubit_states": {
qubit: np.array([0, 1], dtype=np.int8) for qubit in self.all_qubits
},
}
[docs]
class ROThreeStateFrequencyOptimizationNode(ScheduleQubitNode):
"""
Execution node for the 3-state (\\|0>, \\|1>, \\|2>) readout-frequency optimization.
"""
measurement_cls = ROFrequencyOptimizationMeasurement
analysis_cls = ROThreeStateFrequencyOptimizationAnalysis
parameters: ROFrequencyOptimizationParameters
def __init__(
self,
parameters: ROFrequencyOptimizationParameters,
qoi_cls: type[
ROThreeStateFrequencyOptimizationQOI
] = ROThreeStateFrequencyOptimizationQOI,
):
super().__init__(
parameters=parameters,
qoi_cls=qoi_cls,
)
self.schedule_keywords = {"repetitions": self.parameters.repetitions}
self.schedule_samplespace = {
"ro_opt_frequencies": {
qubit: resonator_samples(
qubit,
state=1,
samples=self.parameters_by_qubit[qubit].samples,
half_width=self.parameters_by_qubit[qubit].half_width,
)
for qubit in self.all_qubits
},
"qubit_states": {
qubit: np.array([0, 1, 2], dtype=np.int8) for qubit in self.all_qubits
},
}