stanza.device
Module Contents
Classes
API
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.
List of all breakout box line names in the device.
List of all gate pad names in the device.
List of all contact pad names in the device.
List of all gpio pad names in the device.
List of gate pads that have a control channel configured.
List of contact pads that have a control channel configured.
List of gpio pads that have a control channel configured.
List of gate pads that have a measurement channel configured.
List of contact pads that have a measurement channel configured.
List of configured device group names.
List of gate pad names associated with a specific group.
List of contact pad names associated with a specific group.
List of GPIO pad names associated with a specific group.
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:
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())}”)
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:
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.
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:
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.
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.
Set the voltage of a single gate
Set the voltages of the device.
Parameters:
A dictionary of pads and their voltages.
Whether to wait for the device to settle after setting the voltages.
Raises:
DeviceError: If the control instrument is not configured.
Measure the current of a single gate
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:
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.
Check the current voltage of a single gate electrode.
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:
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.
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:
Name of the gate electrode to sweep
List of voltage values to apply to the gate electrode
Name of the contact electrode to measure current from
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
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:
Name of the first gate electrode to sweep
List of voltage values for the first gate electrode
Name of the second gate electrode to sweep
List of voltage values for the second gate electrode
Name of the contact electrode to measure current from
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
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:
List of voltage values to apply to all control gates simultaneously
Name of the contact electrode to measure current from
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
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:
List of gate electrode names to sweep
List of voltage lists, where each inner list contains the
Name of the contact electrode to measure current from
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
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:
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.
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.
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.
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.
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.
Filter breakout box lines by channel type.
This method filters the breakout box lines by the channel type.
Parameters:
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.
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:
A list of breakout box lines to apply the connection method to.
The instrument to apply the connection method to.
The name of the instrument.
The connection method to apply.
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:
The connection method to apply to the control and measurement instruments.

