# ══════════════════════════════════════════════════════════════════════════
# ___ ___ ___ _ _ ___
# / _ \ / __|_ ) | | /_\ | _ )
# | (_) | (__ / / | |__ / _ \| _ \
# \__\_\\___/___| |____/_/ \_\___/
#
# 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
# ══════════════════════════════════════════════════════════════════════════
"""
Node implementation for Punchout (readout amplitude) calibration.
"""
import numpy as np
from bragi_quantum.experiments.nodes.readout.punchout.analysis import PunchoutAnalysis
from bragi_quantum.experiments.nodes.readout.punchout.measurement import (
PunchoutMeasurement,
)
from bragi_quantum.experiments.nodes.readout.punchout.parameters import (
PunchoutBaseQOI,
PunchoutParameters,
PunchoutQOI,
)
from bragi_quantum.experiments.nodes.schedule_node import ScheduleQubitNode
from bragi_quantum.experiments.utils.samplespace import resonator_samples
[docs]
class Punchout(ScheduleQubitNode):
"""
Execution node for performing Punchout.
A single node class handles the 0, 1 and 2 readout clocks (``state``) and
both end point methods (``bin_mode``, see ``PunchoutParameters``). The
analysis class and QOI class are injected at construction time, mirroring
the resonator spectroscopy interface used by the orchestrator.
Inherits from ScheduleNode to automatically leverage ActiveSession for
hardware and datastore state, injecting keywords and sample spaces into
the measurement schedule.
"""
measurement_cls = PunchoutMeasurement
analysis_cls = PunchoutAnalysis
# Type hinting for strict Pydantic parameter enforcement
parameters: PunchoutParameters
def __init__(
self,
parameters: PunchoutParameters,
qoi_cls: type[PunchoutBaseQOI] = PunchoutQOI,
):
"""
Initializes the punchout node.
Args:
parameters: Validated experimental parameters.
qoi_cls: The QOI class used to store results.
"""
super().__init__(
parameters=parameters,
qoi_cls=qoi_cls,
)
# Define static keywords to be passed to the schedule function
self.schedule_keywords = {
"readout_state": self.parameters.readout_state,
"repetitions": self.parameters.repetitions,
"bin_mode": self.parameters.bin_mode,
"low_amplitude_bins": self.parameters.low_amplitude_bins,
}
self.schedule_samplespace = {
"ro_amplitudes": {
qubit: self._amplitude_samples(self.parameters_by_qubit[qubit])
for qubit in self.all_qubits
},
"ro_frequencies": {
qubit: resonator_samples(
qubit,
state=self.parameters_by_qubit[qubit].readout_state,
samples=self.parameters_by_qubit[qubit].samples,
half_width=self.parameters_by_qubit[qubit].half_width,
)
for qubit in self.all_qubits
},
}
def _amplitude_samples(self, parameters: PunchoutParameters) -> np.ndarray:
"""Build the two-segment readout-amplitude sweep (dense at low power)."""
return np.concatenate(
[
np.linspace(
parameters.min_amplitude,
parameters.crossover_amplitude,
parameters.low_amplitude_bins,
endpoint=False,
),
np.linspace(
parameters.crossover_amplitude,
parameters.max_amplitude,
parameters.high_amplitude_bins,
),
]
)