stanza.device

Module Contents

Classes

NameDescription
DeviceInterface for controlling quantum devices through voltage sweeps and current measurements.

API

1class stanza.device.Device(name: str, device_config: stanza.models.DeviceConfig, channel_configs: dict[str, stanza.base.channels.ChannelConfig], control_instrument: typing.Any | None, measurement_instrument: typing.Any | None, breakout_box_instrument: typing.Any | None = None)

Interface for controlling quantum devices through voltage sweeps and current measurements.

The Device class provides a high-level abstraction for interacting with quantum devices by coordinating between control instruments (for setting voltages) and measurement instruments (for reading currents). It supports various sweep patterns (1D, 2D, N-dimensional) and manages the mapping between logical pad names and physical instrument channels.

Attributes: name: Human-readable name of the device device_config: Configuration object containing device specifications channel_configs: Dictionary mapping pad names to their channel configurations control_instrument: Instrument used for setting voltages (must implement ControlInstrument protocol) measurement_instrument: Instrument used for measuring currents (must implement MeasurementInstrument protocol)

The class distinguishes between different pad types (gates vs contacts) and electrode types (e.g., BARRIER, PLUNGER for gates; SOURCE, DRAIN for contacts), providing convenient properties and methods for filtering and accessing specific electrodes based on their characteristics.

1breakout_lines: list[str]

List of all breakout box line names in the device.

1gates: list[str]

List of all gate pad names in the device.

1contacts: list[str]

List of all contact pad names in the device.

1gpios: list[str]

List of all gpio pad names in the device.

1control_gates: list[str]

List of gate pads that have a control channel configured.

1control_contacts: list[str]

List of contact pads that have a control channel configured.

1control_gpios: list[str]

List of gpio pads that have a control channel configured.

1measurement_gates: list[str]

List of gate pads that have a measurement channel configured.

1measurement_contacts: list[str]

List of contact pads that have a measurement channel configured.

1group_names() -> list[str]

List of configured device group names.

1_get_group(group_name: str) -> stanza.models.DeviceGroup
1group_gates(group_name: str) -> list[str]

List of gate pad names associated with a specific group.

1group_contacts(group_name: str) -> list[str]

List of contact pad names associated with a specific group.

1group_gpios(group_name: str) -> list[str]

List of GPIO pad names associated with a specific group.

1filter_by_group(group_name: str) -> dict[str, stanza.base.channels.ChannelConfig]

Get filtered channel configurations for electrodes in the specified group.

This method returns a dictionary of channel configurations containing only the pads (gates, contacts, gpios) that belong to the specified group. This is useful for getting configuration information about a subset of device pads without creating a separate device instance.

Filtering behavior:

  • Gates: Always explicitly filtered (only listed gates included)
  • Contacts: If specified in group, only those contacts. If omitted, ALL device contacts.
  • GPIOs: If specified in group, only those GPIOs. If omitted, ALL device GPIOs.

Parameters:

group_name
str

Name of the group to filter by. Must exist in device_config.groups.

Returns:

Dictionary mapping pad names to their channel configurations, filtered to include only pads in the specified group.

Raises:

DeviceError: If the specified group does not exist. Example:

Group with explicit GPIO list

control_configs = device.filter_by_group(“control”) control_pads = list(control_configs.keys()) device.jump({pad: 0.5 for pad in control_pads})

Check what pads are in a group

sensor_configs = device.filter_by_group(“sensor”) print(f”Sensor pads: {list(sensor_configs.keys())}”)

1get_gates_by_type(gate_type: str | stanza.models.GateType) -> list[str]

Get the gate electrodes of a given type.

Filters all gate channels in the device to return only those matching the specified gate type (e.g., BARRIER, PLUNGER, SCREENING).

Parameters:

gate_type
str | stanza.models.GateType

The type of gate electrodes to retrieve. Can be provided

Returns:

List of gate electrode names matching the specified type. Returns an empty list if no gates of the specified type are found.

1get_contacts_by_type(contact_type: str | stanza.models.ContactType) -> list[str]

Get the contact electrodes of a given type.

Filters all contact channels in the device to return only those matching the specified contact type (e.g., SOURCE, DRAIN, RESERVOIR).

Parameters:

contact_type
str | stanza.models.ContactType

The type of contact electrodes to retrieve. Can be

Returns:

List of contact electrode names matching the specified type. Returns an empty list if no contacts of the specified type are found.

1is_configured() -> bool

Check if both instruments are configured.

Verifies that the device has both a control instrument (for setting voltages) and a measurement instrument (for reading currents) properly configured and available for use.

Returns:

True if both control_instrument and measurement_instrument are not None, False otherwise.

1_jump(
2 voltage: float,
3 pad: str,
4 wait_for_settling: bool = False
5) -> None

Set the voltage of a single gate

1jump(
2 pad_voltages: dict[str, float], wait_for_settling: bool = False
3) -> None

Set the voltages of the device.

Parameters:

pad_voltages
dict[str, float]

A dictionary of pads and their voltages.

wait_for_settling
boolDefaults to False

Whether to wait for the device to settle after setting the voltages.

Raises:

DeviceError: If the control instrument is not configured.

1_measure(pad: str) -> float

Measure the current of a single gate

1measure(pad: str | list[str]) -> float | list[float]

Measure the current of the device.

Performs current measurement on one or more pads using the measurement instrument. For multiple pads, attempts to use the instrument’s batch measurement capability if available, otherwise measures sequentially.

Parameters:

pad
str | list[str]

Either a single pad name or a list of pad names to measure.

Returns:

If a single pad name is provided, returns a single float current value. If a list of pad names is provided, returns a list of float current values corresponding to each pad in the input list.

Raises:

DeviceError: If the measurement instrument is not configured, if a specified pad is not found in channel configs, or if a pad has no measure channel configured.

1_check(pad: str) -> float

Check the current voltage of a single gate electrode.

1check(pad: str | list[str]) -> float | list[float]

Check the current voltage of the device.

Reads the current voltage setting from one or more pads using the control instrument. This returns the voltage that the control instrument believes it has set, not a measured value from the device itself.

Parameters:

pad
str | list[str]

Either a single pad name or a list of pad names to check.

Returns:

If a single pad name is provided, returns a single float voltage value. If a list of pad names is provided, returns a list of float voltage values corresponding to each pad in the input list.

Raises:

DeviceError: If the control instrument is not configured, if a specified pad is not found in channel configs, or if a pad has no control channel configured.

1sweep_1d(
2 gate_electrode: str,
3 voltages: list[float],
4 measure_electrode: str,
5 session: stanza.logger.session.LoggerSession | None = None
6) -> tuple[list[float], list[float]]

Sweep a single gate electrode and measure the current of a single contact electrode.

Performs a 1D voltage sweep by stepping through a list of voltages on a specified gate electrode while measuring the current through a contact electrode at each step. Optionally logs the sweep data to a session.

Parameters:

gate_electrode
str

Name of the gate electrode to sweep

voltages
list[float]

List of voltage values to apply to the gate electrode

measure_electrode
str

Name of the contact electrode to measure current from

session
stanza.logger.session.LoggerSession | None

Optional LoggerSession to log the sweep data. If provided,

Returns:

Tuple of (voltage_measurements, current_measurements) where:

  • voltage_measurements: List of actual voltages read from the gate
  • current_measurements: List of measured current values at each voltage
1sweep_2d(
2 gate_1: str,
3 voltages_1: list[float],
4 gate_2: str,
5 voltages_2: list[float],
6 measure_electrode: str,
7 session: stanza.logger.session.LoggerSession | None = None
8) -> tuple[list[list[float]], list[float]]

Sweep two gate electrodes and measure the current of a single contact electrode.

Performs a 2D voltage sweep by iterating through all combinations of voltages on two gate electrodes while measuring current through a contact electrode. The sweep iterates through gate_1 voltages in the outer loop and gate_2 voltages in the inner loop.

Parameters:

gate_1
str

Name of the first gate electrode to sweep

voltages_1
list[float]

List of voltage values for the first gate electrode

gate_2
str

Name of the second gate electrode to sweep

voltages_2
list[float]

List of voltage values for the second gate electrode

measure_electrode
str

Name of the contact electrode to measure current from

session
stanza.logger.session.LoggerSession | None

Optional LoggerSession to log the sweep data. If provided,

Returns:

Tuple of (voltage_measurements, current_measurements) where:

  • voltage_measurements: List of [gate_1_voltage, gate_2_voltage] pairs
  • current_measurements: List of measured current values at each voltage pair
1sweep_all(
2 voltages: list[float],
3 measure_electrode: str,
4 session: stanza.logger.session.LoggerSession | None = None
5) -> tuple[list[list[float]], list[float]]

Sweep all gate electrodes and measure the current of a single contact electrode.

Performs a voltage sweep by setting all control gates to the same voltage at each step, while measuring current through a contact electrode. This is useful for characterizing device response to overall gate bias.

Parameters:

voltages
list[float]

List of voltage values to apply to all control gates simultaneously

measure_electrode
str

Name of the contact electrode to measure current from

session
stanza.logger.session.LoggerSession | None

Optional LoggerSession to log the sweep data. If provided,

Returns:

Tuple of (voltage_measurements, current_measurements) where:

  • voltage_measurements: List of lists, each containing voltage values for all control gates at that sweep step
  • current_measurements: List of measured current values at each voltage
1sweep_nd(
2 gate_electrodes: list[str],
3 voltages: list[list[float]],
4 measure_electrode: str,
5 session: stanza.logger.session.LoggerSession | None = None
6) -> tuple[list[list[float]], list[float]]

Sweep multiple gate electrodes and measure the current of a single contact electrode.

Performs an N-dimensional voltage sweep where each specified gate can have a different voltage at each sweep step. This provides maximum flexibility for arbitrary multi-gate sweeps and trajectories through voltage space.

Parameters:

gate_electrodes
list[str]

List of gate electrode names to sweep

voltages
list[list[float]]

List of voltage lists, where each inner list contains the

measure_electrode
str

Name of the contact electrode to measure current from

session
stanza.logger.session.LoggerSession | None

Optional LoggerSession to log the sweep data. If provided,

Returns:

Tuple of (voltage_measurements, current_measurements) where:

  • voltage_measurements: List of lists, each containing the actual voltage values read from each gate at that sweep step
  • current_measurements: List of measured current values at each voltage combination
1zero(type: str | stanza.models.PadType = PadType.ALL) -> None

Set all controllable gates and/or controllable contacts to 0V.

Safely brings specified electrodes to ground voltage (0V) with settling time and verification. This is typically used for device initialization or safe shutdown.

Parameters:

type
str | stanza.models.PadTypeDefaults to PadType.ALL

Specifies which pads to zero. Options are:

Raises:

DeviceError: If an invalid pad type is provided, or if any pad fails to reach 0V within tolerance (1e-6V) after the operation.

1ground_breakout_lines() -> None

Ground all breakout box lines.

This method sets all breakout box lines to a grounded state.

Raises:

DeviceError: If the breakout box instrument is not configured.

1unground_breakout_lines() -> None

Unground all breakout box lines.

This method sets all breakout box lines to an ungrounded state.

Raises:

DeviceError: If the breakout box instrument is not configured.

1connect_breakout_lines() -> None

Connect all breakout box lines.

This method connects all breakout box lines to the instrument.

Raises:

DeviceError: If the breakout box instrument is not configured.

1disconnect_breakout_lines() -> None

Disconnect all breakout box lines.

This method disconnects all breakout box lines from the instrument.

Raises:

DeviceError: If the breakout box instrument is not configured.

1_get_lines_by_channel(has_channel: collections.abc.Callable[[stanza.base.channels.ChannelConfig], bool]) -> list[str]

Filter breakout box lines by channel type.

This method filters the breakout box lines by the channel type.

Parameters:

has_channel
collections.abc.Callable[[stanza.base.channels.ChannelConfig], bool]

A callable that returns True if the channel has the specified type.

Returns:

A list of breakout box lines that have the specified channel type.

1_apply_breakout_connection(
2 lines: list[str],
3 instrument: stanza.base.protocols.ControlInstrument | stanza.base.protocols.MeasurementInstrument | None,
4 instrument_name: str,
5 connection_method: collections.abc.Callable[[list[str], int], None]
6) -> None

Apply connection method to a list of lines for a specific instrument.

This method applies the connection method to a list of lines for a specific instrument.

Parameters:

lines
list[str]

A list of breakout box lines to apply the connection method to.

instrument
stanza.base.protocols.ControlInstrument | stanza.base.protocols.MeasurementInstrument | None

The instrument to apply the connection method to.

instrument_name
str

The name of the instrument.

connection_method
collections.abc.Callable[[list[str], int], None]

The connection method to apply.

1_set_breakout_connection(connection_method: collections.abc.Callable[[list[str], int], None]) -> None

Set breakout box connection state for all lines, grouped by instrument type.

This method sets the breakout box connection state for all lines, grouped by instrument type.

Parameters:

connection_method
collections.abc.Callable[[list[str], int], None]

The connection method to apply to the control and measurement instruments.