nanotune.tuningstages.tuningstage

class nanotune.tuningstages.tuningstage.TuningStage(stage: str, data_settings: DataSettings, setpoint_settings: SetpointSettings, readout: Readout)[source]

Bases: object

Base class implementing the common sequence of a tuning stage.

Parameters
  • stage – String indicating which stage it implements, e.g. gatecharacterization.

  • data_settings – Dictionary with information about data, e.g. where it should be saved and how it should be normalized. Required fields are ‘db_name’, ‘db_folder’ and ‘normalization_constants’.

  • setpoint_settings – Dictionary with information required to compute setpoints. Necessary keys are ‘current_valid_ranges’, ‘safety_voltage_ranges’, ‘parameters_to_sweep’ and ‘voltage_precision’.

  • readout – Dictionary mapping string identifiers such as ‘transport’ to QCoDeS parameters measuring/returning the desired quantity (e.g. current throught the device).

  • current_valid_ranges – List of voltages ranges (tuples of floats) to measure.

  • safety_voltage_ranges – List of satefy voltages ranges, i.e. safety limits within which gates don’t blow up.

  • fit_class – Abstract property, to be specified in child classes. It is the class that should perform the data fitting, e.g. PinchoffFit.

abstract property fit_class

To be specified in child classes. It is the data fitting class should be used to perform a fit.

abstract conclude_iteration(tuning_result: TuningResult, current_valid_ranges: Sequence[Sequence[float]], safety_voltage_ranges: Sequence[Sequence[float]], current_iteration: int, max_n_iterations: int) Tuple[bool, Sequence[Sequence[float]], List[str]][source]

Method checking if one iteration of a run_stage measurement cycle has been successful.

An iteration of such a measurement cycle takes data, performs a machine learning task, verifies and saves the machine learning result. If a repetition of this cycle is supported, then conclude_iteration determines whether another iteration should take place and which voltage ranges need to be measured. Each child class needs to implement the body of this method, tailoring it to the respective tuning stage.

Parameters
  • tuning_result – Result of the last run_stage measurement cycle.

  • current_valid_ranges – Voltage ranges last swept.

  • safety_voltage_ranges – Safety voltage ranges, i.e. largest possible range that could be swept.

  • current_iteration – Number of current iteration.

  • max_n_iterations – Maximum number of iterations to perform before abandoning.

Returns
  • bool – Whether this is the last iteration and the stage is done/to be stopped.

  • list – New voltage ranges to sweep if the stage is not done.

  • list – List of strings indicating failure modes.

abstract verify_machine_learning_result(ml_result: Dict[str, int]) bool[source]

Verifies if the desired measurement quality or regime has been found. Needs to be implemented by child classed to account for the different regimes or measurements they are dealing with.

Parameters

ml_result – Result returned by machine_learning_task.

Returns

bool – Whether the desired outcome has been found.

abstract machine_learning_task(run_id: int) Dict[str, Any][source]

The machine learning task to perform after a measurement.

Parameters

run_id – QCoDeS data run ID.

save_ml_result(run_id: int, ml_result: Dict[str, int]) None[source]

Saves the result returned by `machine_learning_task`: the extracted features are stored into metadata of the respective dataset.

Parameters
  • run_id – QCoDeS data run ID.

  • ml_result – Result returned by machine_learning_task.

finish_early(current_output_dict: Dict[str, float]) bool[source]

Checks if the current data taking can be stopped. E.g. if the device is pinched off entirely.

Parameters

current_output_dict – Dictionary mapping a string indicating the readout method to the respective value last measured.

Returns

bool – Whether the current data taking procedure can be stopped.

compute_setpoints(current_valid_ranges: Sequence[Sequence[float]]) Sequence[Sequence[float]][source]

Computes setpoints for the next measurement. Unless this method is overwritten in a child class, linearly spaced setpoints are computed.

Parameters

current_valid_ranges – Voltages ranges to sweep.

Returns

list – List of lists with setpoints.

show_result(plot_result: bool, current_id: int, tuning_result: TuningResult) None[source]

Displays tuning result and optionally plots the fitting result.

Parameters
  • plot_result – Bool indicating whether the data fit should be plotted.

  • current_id – QCoDeS data run ID.

  • tuning_result – Result of a tuning stage run.

prepare_nt_metadata() Dict[str, Any][source]

Sets up a metadata dictionary with fields known prior to a measurement set. Wraps `prepare_metadata` in .base_tasks.py.

Returns

dict – Metadata dict with fields known prior to a measurement filled in.

measure(parameters_to_sweep: List[Parameter], parameters_to_measure: List[Parameter], setpoints: List[List[float]]) int[source]

Takes 1D or 2D data and saves relevant metadata into the dataset. Wraps `take_data_add_metadata` in .base_tasks.py.

Parameters

setpoints – Setpoints to measure.

Returns

int – QCoDeS data run ID.

run_stage(iterate: bool = True, max_iterations: int = 10, plot_result: bool = True) TuningResult[source]

Performs iterations of a basic measurement cycle of a tuning stage.

It wraps `iterate_stage` in .base_tasks.py. One measurement cycle does the following subtasks: - computes setpoints - perform the actual measurement, i.e. take data - perform a machine learning task, e.g. classification - validate the machine learning result, e.g. check if a good regime was found - collect all information in a TuningResult instance. At each iteration, `conclude_iteration` check whether another measurement cycle will be performed. At the very end, `clean_up` does the desired post-measurement task.

Parameters
  • iterate

  • max_iterations

  • plot_result

Returns

TuningResult – Tuning results of the last iteration, with the dataids field containing QCoDeS run IDs of all datasets measured.