qibocal.protocols.twpa package

Submodules

qibocal.protocols.twpa.frequency_offset module

Protocol to sweep TWPA signal control parameters (frequency and offset) using sweepers.

class qibocal.protocols.twpa.frequency_offset.TwpaFrequencyOffsetParameters(amplitude: tuple[float, float, float] | tuple[Literal['linspace'], float, float, int] | tuple[Literal['window'], float, float, float] | tuple[Literal['linwindow'], float, float, int] | tuple[Literal['center'], float, float] | tuple[Literal['lincenter'], float, int] | tuple[Literal['asym'], tuple[float, float], float] | tuple[Literal['linasym'], tuple[float, float], int], frequency: tuple[float, float, float] | tuple[Literal['linspace'], float, float, int] | tuple[Literal['window'], float, float, float] | tuple[Literal['linwindow'], float, float, int] | tuple[Literal['center'], float, float] | tuple[Literal['lincenter'], float, int] | tuple[Literal['asym'], tuple[float, float], float] | tuple[Literal['linasym'], tuple[float, float], int], probes: list[float] | None = None, probe_duration: float = 4000.0, probe_amplitude: float = 1.0)[source]

Bases: Parameters

amplitude: tuple[float, float, float] | tuple[Literal['linspace'], float, float, int] | tuple[Literal['window'], float, float, float] | tuple[Literal['linwindow'], float, float, int] | tuple[Literal['center'], float, float] | tuple[Literal['lincenter'], float, int] | tuple[Literal['asym'], tuple[float, float], float] | tuple[Literal['linasym'], tuple[float, float], int]

Range of amplitude (offset) values for TWPA sweep.

frequency: tuple[float, float, float] | tuple[Literal['linspace'], float, float, int] | tuple[Literal['window'], float, float, float] | tuple[Literal['linwindow'], float, float, int] | tuple[Literal['center'], float, float] | tuple[Literal['lincenter'], float, int] | tuple[Literal['asym'], tuple[float, float], float] | tuple[Literal['linasym'], tuple[float, float], int]

Range of TWPA frequency values for sweep.

probes: list[float] | None = None

List of probe frequencies to evaluate (Hz).

If omitted, a single acquisition run is performed where each target is probed exclusively at its own calibrated readout frequency.

probe_duration: float = 4000.0

Probe wave duration.

probe_amplitude: float = 1.0

Probe wave amplitude.

nshots: int

Number of executions on hardware.

relaxation_time: float

Wait time for the qubit to decohere back to the ground state.

class qibocal.protocols.twpa.frequency_offset.TwpaFrequencyOffsetResults(frequency: dict[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], float], offset: dict[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], float], gain: dict[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], float])[source]

Bases: Results

frequency: dict[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], float]

Pump frequency [Hz].

offset: dict[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], float]

Pump offset [a.u.].

gain: dict[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], float]

TWPA gain [dB].

_to_json(path: Path, filename: str)

Helper function to dump to json.

_to_npz(path: Path, filename: str)

Helper function to use np.savez while converting keys into strings.

static load_data(path: Path, filename: str)

Load data stored in a npz file.

static load_params(path: Path, filename: str)

Load parameters stored in a json file.

property params: dict

Convert non-arrays attributes into dict.

save(path: Path, filename: str = 'results')

Store results to file.

class qibocal.protocols.twpa.frequency_offset.TwpaFrequencyOffsetData(data: dict[typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[~_ScalarT]]] = <factory>, frequency: dict[typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], list[float]] = <factory>, offset: dict[typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], list[float]] = <factory>, reference_value: dict[typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], list[list[float]]] = <factory>, probes: list[float] | None = None, power: dict[typing.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], float] = <factory>)[source]

Bases: Data

data: dict[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ndarray[tuple[Any, ...], dtype[_ScalarT]]]

Raw data acquired.

frequency: dict[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], list[float]]

List with twpa frequency values swept.

_to_json(path: Path, filename: str)

Helper function to dump to json.

_to_npz(path: Path, filename: str)

Helper function to use np.savez while converting keys into strings.

static load_data(path: Path, filename: str)

Load data stored in a npz file.

static load_params(path: Path, filename: str)

Load parameters stored in a json file.

property pairs: list[~typing.Annotated[tuple[~types.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ~types.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]], ~pydantic.functional_validators.BeforeValidator(func=~qibocal.calibration.calibration.<lambda>, json_schema_input_type=PydanticUndefined), ~pydantic.functional_serializers.PlainSerializer(func=~qibocal.calibration.calibration.<lambda>, return_type=PydanticUndefined, when_used=always)]]

Access qubit pairs from data structure.

property params: dict

Convert non-arrays attributes into dict.

property qubits: list[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]]

Access qubits from data structure.

register_qubit(dtype, data_keys, data_dict)

Store output for single qubit.

Parameters:
  • data_keys (tuple) – Keys of Data.data.

  • data_dict (dict) – The keys are the fields of dtype and

  • arrays. (the values are the related)

save(path: Path, filename: str = 'data')

Store data to file.

offset: dict[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], list[float]]

List with twpa offset values swept.

reference_value: dict[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], list[list[float]]]

Reference values with TWPA off for each probe frequency.

Reference measurements are I/Q points themselves, as the acquired data.

probes: list[float] | None = None

List of probe frequencies evaluated.

None if native readout frequencies were used.

power: dict[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], float]

Configured base pump power [dB] for each target.

reference_value_array(qubit: Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]) → ndarray[tuple[Any, ...], dtype[_ScalarT]][source]

Return reference value as a numpy array.

The shape is (nprobes, 2), with nprobes the number of probes used, and 2 for the I/Q measurements.

averaged_gain(qubit: Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]) → ndarray[tuple[Any, ...], dtype[_ScalarT]][source]
qibocal.protocols.twpa.frequency_offset._acquisition(params: TwpaFrequencyOffsetParameters, platform: CalibrationPlatform, targets: list[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]]) → TwpaFrequencyOffsetData[source]

Acquire reference scan and 2D gain landscape, for each probe.

First perform a scan over the readout probe with the TWPA off, then sweep the TWPA amplitude (offset) and frequency concurrently using a 2D sweeper.

Note on the probe frequencies handling: The TWPA gain oscillates quite fast in the probe frequency. Instead of obtaining the best gain on average across an arbitrary continuous frequency range, we optimize specifically for the frequencies of the expected readout resonators. When params.probes is omitted (None), the protocol performs a single acquisition run where each target qubit is updated and probed exclusively at its own calibrated readout frequency. When params.probes is provided as a discrete list of frequencies, the protocol iterates over each probe frequency in software, applying it to all targets across successive runs. Because not all control electronics support sweeping an arbitrary on-board list of values, this multi-probe evaluation is implemented as a software loop. The primary speed-up is achieved through the on-board 2D hardware sweep over the TWPA pump signal parameters (amplitude and frequency).

qibocal.protocols.twpa.frequency_offset._fit(data: TwpaFrequencyOffsetData) → TwpaFrequencyOffsetResults[source]

Maximize measured gain.

After computing the averaged gain across evaluated probes, select the corresponding TWPA frequency and offset that maximizes the gain for each qubit.

qibocal.protocols.twpa.frequency_offset._plot(data: TwpaFrequencyOffsetData, fit: TwpaFrequencyOffsetResults | None, target: Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])])[source]

Plot average gain, and report fit results - if any.

The visualization displays the averaged TWPA gain across evaluated probe frequencies as a 2D heatmap versus pump frequency (horizontal axis) and pump amplitude/offset (primary vertical axis). If fit results are available, the optimal working point is highlighted with a marker in the plot and legend.

To relate the dimensionless amplitude offset to the effective pump power in dB, a secondary vertical axis is rendered on the right edge. Its tick positions and labels are generated dynamically from the platform pump power and the logarithmic offset scaling. Because Plotly requires an associated trace to render secondary layout axes, an invisible dummy scatter trace is attached to this secondary scale.

qibocal.protocols.twpa.frequency_offset.twpa_frequency_offset = Protocol(acquisition=<function _acquisition>, fit=<function _fit>, report=<function _plot>, update=None, two_qubit_gates=False)

Resonator TWPA Frequency and Offset Sweeper Protocol object.

qibocal.protocols.twpa.frequency_offset.twpa_sweep = Protocol(acquisition=<function _acquisition>, fit=<function _fit>, report=<function _plot>, update=None, two_qubit_gates=False)

Alias for twpa_frequency_offset.

qibocal.protocols.twpa.twpa module

Protocol to calibrate TWPA power and frequency for a specific probe frequency.

class qibocal.protocols.twpa.twpa.TwpaCalibrationParameters(freq_width: float, freq_step: float, twpa_freq_width: int, twpa_freq_step: int, twpa_pow_width: int, twpa_pow_step: int, nshots: int | None = None, relaxation_time: int | None = None)[source]

Bases: Parameters

TwpaCalibration runcard inputs.

freq_width: float

Width for frequency sweep of readout pulse (Hz).

freq_step: float

Frequency step for sweep of readout pulse (Hz).

twpa_freq_width: int

Width for TPWA frequency sweep (Hz).

twpa_freq_step: int

TPWA frequency step (Hz).

twpa_pow_width: int

Width for TPWA power sweep (dBm).

twpa_pow_step: int

TPWA power step (dBm).

nshots: int | None = None

Number of shots.

relaxation_time: int | None = None

Relaxation time (ns).

class qibocal.protocols.twpa.twpa.TwpaCalibrationResults(data: dict[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ndarray[tuple[Any, ...], dtype[_ScalarT]]], twpa_frequency: dict[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], float], twpa_power: dict[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], float])[source]

Bases: Results

TwpaCalibration outputs.

data: dict[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ndarray[tuple[Any, ...], dtype[_ScalarT]]]

Array with average gain for each qubit.

twpa_frequency: dict[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], float]

TWPA frequency [GHz].

_to_json(path: Path, filename: str)

Helper function to dump to json.

_to_npz(path: Path, filename: str)

Helper function to use np.savez while converting keys into strings.

static load_data(path: Path, filename: str)

Load data stored in a npz file.

static load_params(path: Path, filename: str)

Load parameters stored in a json file.

property params: dict

Convert non-arrays attributes into dict.

save(path: Path, filename: str = 'results')

Store results to file.

twpa_power: dict[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], float]

TWPA power [dBm].

class qibocal.protocols.twpa.twpa.TwpaCalibrationData(data: dict[~types.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ~numpy.ndarray[tuple[~typing.Any, ...], ~numpy.dtype[~numpy._typing._array_like._ScalarT]]] = <factory>, twpa_frequency: dict[~types.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], list[float]] = <class 'list'>, twpa_power: dict[~types.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], list[float]] = <class 'list'>, reference_value: dict[~types.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], list[float]] = <class 'list'>)[source]

Bases: Data

TwpaCalibration data acquisition.

_to_json(path: Path, filename: str)

Helper function to dump to json.

_to_npz(path: Path, filename: str)

Helper function to use np.savez while converting keys into strings.

static load_data(path: Path, filename: str)

Load data stored in a npz file.

static load_params(path: Path, filename: str)

Load parameters stored in a json file.

property pairs: list[~typing.Annotated[tuple[~types.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ~types.Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]], ~pydantic.functional_validators.BeforeValidator(func=~qibocal.calibration.calibration.<lambda>, json_schema_input_type=PydanticUndefined), ~pydantic.functional_serializers.PlainSerializer(func=~qibocal.calibration.calibration.<lambda>, return_type=PydanticUndefined, when_used=always)]]

Access qubit pairs from data structure.

property params: dict

Convert non-arrays attributes into dict.

property qubits: list[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]]

Access qubits from data structure.

register_qubit(dtype, data_keys, data_dict)

Store output for single qubit.

Parameters:
  • data_keys (tuple) – Keys of Data.data.

  • data_dict (dict) – The keys are the fields of dtype and

  • arrays. (the values are the related)

save(path: Path, filename: str = 'data')

Store data to file.

data: dict[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])], ndarray[tuple[Any, ...], dtype[_ScalarT]]]

Raw data acquired.

twpa_frequency

List with twpa frequency values swept.

alias of list

twpa_power

List with twpa power values swept.

alias of list

reference_value

Values for readout frequency sweep with TWPA off.

alias of list

reference_value_array(qubit: Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]) → ndarray[tuple[Any, ...], dtype[_ScalarT]][source]

Return reference value as a numpy array.

qibocal.protocols.twpa.twpa._acquisition(params: TwpaCalibrationParameters, platform: Platform, targets: list[Annotated[int | str, FieldInfo(annotation=NoneType, required=True, metadata=[_PydanticGeneralMetadata(union_mode='left_to_right')])]]) → TwpaCalibrationData[source]

Acquisition function for TwpaCalibration.

First perform a scan over the readout probe with the TWPA off, then we sweep the TWPA power and frequency. The gain is computed as the norm of the complex readout signal divided the norm of the complex readout signal without TWPA.

qibocal.protocols.twpa.twpa._fit(data: TwpaCalibrationData) → TwpaCalibrationResults[source]

Post-processing function for TwpaCalibration.

After computing the averaged gain we select the corresponding twpa frequency and power that maximizes the gain for each qubit.

qibocal.protocols.twpa.twpa._plot(data: TwpaCalibrationData, fit: TwpaCalibrationResults, target)[source]

Plotting for TwpaCalibration.

qibocal.protocols.twpa.twpa.twpa_calibration = Protocol(acquisition=<function _acquisition>, fit=<function _fit>, report=<function _plot>, update=None, two_qubit_gates=False)

Resonator TWPA Frequency Protocol object.