stanza.routines.builtins.dqd_search.utils

Module Contents

Classes

NameDescription
SweepGeometryRandom sweep configuration in 2D voltage space.
GateIndicesIndices for different gate types in the voltage array.

Functions

NameDescription
build_gate_indicesExtract indices for each gate type from the gate list.
generate_linear_sweepGenerate evenly-spaced points along a line segment.
generate_random_sweepGenerate random sweep that stays within bounds.
build_full_voltagesConstruct full voltage array from plunger sweep voltages.
compute_peak_spacingsCalculate inter-peak spacings in voltage space.
get_global_turn_on_voltageGet global turn-on voltage from results.
_get_gate_characterizationGet combined gate characterization results.
get_voltagesGet voltages for all gates.
get_plunger_gate_boundsGet plunger bounds for all plunger gates.
get_gate_safe_boundsGet safe voltage bounds.
measure_and_classifyMeasure current and classify result.
log_measurementLog measurement data to session.
log_classificationLog classification result to session.

API

1class stanza.routines.builtins.dqd_search.utils.SweepGeometry

Random sweep configuration in 2D voltage space.

1start: numpy.typing.NDArray[numpy.float64]

Value: None

1end: numpy.typing.NDArray[numpy.float64]

Value: None

1direction: numpy.typing.NDArray[numpy.float64]

Value: None

1angle: float

Value: None

1total_distance: float

Value: None

1class stanza.routines.builtins.dqd_search.utils.GateIndices

Indices for different gate types in the voltage array.

1plunger: list[int]

Value: None

1reservoir: list[int]

Value: None

1barrier: list[int]

Value: None

1stanza.routines.builtins.dqd_search.utils.build_gate_indices(
2 gates: list[str], device: stanza.device.Device
3) -> stanza.routines.builtins.dqd_search.utils.GateIndices

Extract indices for each gate type from the gate list.

Parameters:

gates
list[str]

List of gate electrode names.

device
stanza.device.Device

Device instance with get_gate_by_type method.

Returns:

GateIndices with plunger, reservoir, and barrier indices.

1stanza.routines.builtins.dqd_search.utils.generate_linear_sweep(
2 start_point: numpy.typing.NDArray[numpy.float64],
3 direction: numpy.typing.NDArray[numpy.float64],
4 total_sweep_dist: float,
5 n_points: int
6) -> numpy.typing.NDArray[numpy.float64]

Generate evenly-spaced points along a line segment.

Parameters:

start_point
numpy.typing.NDArray[numpy.float64]

(d,) array with starting coordinates.

direction
numpy.typing.NDArray[numpy.float64]

(d,) array with normalized direction vector.

total_sweep_dist
float

Total sweep distance.

n_points
int

Number of points in the trace.

Returns:

(n_points, d) array of coordinates along the line.

1stanza.routines.builtins.dqd_search.utils.generate_random_sweep(
2 x_bounds: tuple[float, float],
3 y_bounds: tuple[float, float],
4 scale: float,
5 num_points: int
6) -> stanza.routines.builtins.dqd_search.utils.SweepGeometry | None

Generate random sweep that stays within bounds.

Parameters:

x_bounds
tuple[float, float]

(min, max) voltage bounds for X axis.

y_bounds
tuple[float, float]

(min, max) voltage bounds for Y axis.

scale
float

Voltage spacing per step.

num_points
int

Number of points in sweep.

Returns:

SweepGeometry if sweep stays in bounds, None otherwise.

1stanza.routines.builtins.dqd_search.utils.build_full_voltages(
2 sweep_voltages: numpy.typing.NDArray[numpy.float64],
3 gates: list[str],
4 gate_idx: stanza.routines.builtins.dqd_search.utils.GateIndices,
5 transition_voltages: dict[str, float],
6 saturation_voltages: dict[str, float],
7 barrier_voltages: dict[str, float] | None = None
8) -> numpy.typing.NDArray[numpy.float64]

Construct full voltage array from plunger sweep voltages.

Works with arbitrary-dimensional sweep arrays (1D, 2D, 3D, etc). Applies fixed voltages to reservoir and barrier gates based on characterization data.

Parameters:

sweep_voltages
numpy.typing.NDArray[numpy.float64]

(…, 2) array of plunger voltages.

gates
list[str]

List of all gate names.

gate_idx
stanza.routines.builtins.dqd_search.utils.GateIndices

Indices for each gate type.

transition_voltages
dict[str, float]

Transition voltages for all gates.

saturation_voltages
dict[str, float]

Saturation voltages for all gates.

barrier_voltages
dict[str, float] | None

Optional explicit barrier voltages (overrides defaults).

Returns:

(…, num_gates) array of voltages.

1stanza.routines.builtins.dqd_search.utils.compute_peak_spacings(
2 peak_indices: numpy.typing.NDArray[numpy.int64],
3 sweep_voltages: numpy.typing.NDArray[numpy.float64]
4) -> numpy.typing.NDArray[numpy.float64] | None

Calculate inter-peak spacings in voltage space.

Parameters:

peak_indices
numpy.typing.NDArray[numpy.int64]

Indices of detected peaks.

sweep_voltages
numpy.typing.NDArray[numpy.float64]

(num_points, 2) array of voltage coordinates.

Returns:

Array of inter-peak spacings, or None if fewer than 3 peaks.

1stanza.routines.builtins.dqd_search.utils.get_global_turn_on_voltage(results: stanza.registry.ResultsRegistry) -> float

Get global turn-on voltage from results.

Parameters:

results
stanza.registry.ResultsRegistry

ResultsRegistry instance.

Returns:

Global turn-on voltage.

Raises:

ValueError: If global accumulation results not found.

1stanza.routines.builtins.dqd_search.utils._get_gate_characterization(results: stanza.registry.ResultsRegistry) -> dict[str, dict[str, float]]

Get combined gate characterization results.

Parameters:

results
stanza.registry.ResultsRegistry

ResultsRegistry instance.

Returns:

Combined dict of reservoir and finger gate characterization.

Raises:

ValueError: If characterization results not found.

1stanza.routines.builtins.dqd_search.utils.get_voltages(
2 gates: list[str],
3 key: str,
4 results: stanza.registry.ResultsRegistry
5) -> dict[str, float]

Get voltages for all gates.

Parameters:

gates
list[str]

List of gate names.

key
str

Key to extract (“saturation_voltage”, “cutoff_voltage”, or “transition_voltage”).

results
stanza.registry.ResultsRegistry

ResultsRegistry instance.

Returns:

Dict mapping gate names to voltages.

1stanza.routines.builtins.dqd_search.utils.get_plunger_gate_bounds(
2 plunger_gates: list[str], results: stanza.registry.ResultsRegistry
3) -> dict[str, tuple[float, float]]

Get plunger bounds for all plunger gates.

Parameters:

plunger_gates
list[str]

List of plunger gate names.

results
stanza.registry.ResultsRegistry

ResultsRegistry instance.

Returns:

Dict mapping plunger gate names to (min, max) voltage bounds.

1stanza.routines.builtins.dqd_search.utils.get_gate_safe_bounds(results: stanza.registry.ResultsRegistry) -> tuple[float, float]

Get safe voltage bounds.

Parameters:

results
stanza.registry.ResultsRegistry

ResultsRegistry instance.

Returns:

(min, max) safe voltage bounds.

Raises:

ValueError: If leakage test results not found.

1stanza.routines.builtins.dqd_search.utils.measure_and_classify(
2 device: stanza.device.Device,
3 client: conductorquantum.base_client.BaseConductorQuantum,
4 gates: list[str],
5 voltages: numpy.typing.NDArray[numpy.float64],
6 measure_electrode: str,
7 model: str,
8 reshape: tuple[int, ...] | None = None
9) -> tuple[numpy.typing.NDArray[numpy.float64], bool, float]

Measure current and classify result.

Performs device measurement sweep and classifies the resulting current data using a specified ML model.

Parameters:

device
stanza.device.Device

Device instance.

client
conductorquantum.base_client.BaseConductorQuantum

Models client.

gates
list[str]

Gate electrode names.

voltages
numpy.typing.NDArray[numpy.float64]

Voltage array.

measure_electrode
str

Current measurement electrode.

model
str

Classification model name.

reshape
tuple[int, ...] | None

Optional reshape dimensions for output.

Returns:

Tuple of (currents, classification, score).

1stanza.routines.builtins.dqd_search.utils.log_measurement(
2 session: stanza.logger.session.LoggerSession | None,
3 name: str,
4 measurement_id: str,
5 data: dict[str, typing.Any],
6 metadata: dict[str, typing.Any],
7 routine_name: str
8) -> None

Log measurement data to session.

Parameters:

session
stanza.logger.session.LoggerSession | None

Logger session instance (optional).

name
str

Measurement name.

measurement_id
str

Unique measurement identifier.

data
dict[str, typing.Any]

Measurement data dict.

metadata
dict[str, typing.Any]

Measurement metadata dict.

routine_name
str

Name of the routine performing the measurement.

1stanza.routines.builtins.dqd_search.utils.log_classification(
2 session: stanza.logger.session.LoggerSession | None,
3 measurement_id: str,
4 measurement_type: str,
5 classification: bool,
6 score: float,
7 metadata: dict[str, typing.Any],
8 routine_name: str
9) -> None

Log classification result to session.

Parameters:

session
stanza.logger.session.LoggerSession | None

Logger session instance (optional).

measurement_id
str

Unique measurement identifier.

measurement_type
str

Type of measurement being classified.

classification
bool

Classification result (True/False).

score
float

Classification confidence score.

metadata
dict[str, typing.Any]

Classification metadata dict.

routine_name
str

Name of the routine performing the classification.