Optimizers

C1 - Optimal control

Object that deals with the open loop optimal control.

class c3.optimizers.c1.C1(dir_path, fid_func, fid_subspace, pmap, callback_fids=[], algorithm=None, store_unitaries=False, options={}, run_name=None, interactive=True)[source]

Bases: c3.optimizers.optimizer.Optimizer

Object that deals with the open loop optimal control.

Parameters
  • dir_path (str) – Filepath to save results

  • fid_func (callable) – infidelity function to be minimized

  • fid_subspace (list) – Indeces identifying the subspace to be compared

  • pmap (ParameterMap) – Identifiers for the parameter vector

  • callback_fids (list of callable) – Additional fidelity function to be evaluated and stored for reference

  • algorithm (callable) – From the algorithm library Save plots of control signals

  • store_unitaries (boolean) – Store propagators as text and pickle

  • options (dict) – Options to be passed to the algorithm

  • run_name (str) – User specified name for the run, will be used as root folder

goal_run(current_params: tensorflow.python.framework.ops.Tensor) → tf.float64[source]

Evaluate the goal function for current parameters.

Parameters

current_params (tf.Tensor) – Vector representing the current parameter values.

Returns

Value of the goal function

Return type

tf.float64

include_model()[source]
load_model_parameters(adjust_exp: str) → None[source]
log_setup() → None[source]

Create the folders to store data.

Parameters
  • dir_path (str) – Filepath

  • run_name (str) – User specified name for the run

optimize_controls() → None[source]

Apply a search algorithm to your gateset given a fidelity function.

C2 - Calibration

Object that deals with the closed loop optimal control.

class c3.optimizers.c2.C2(dir_path, eval_func, pmap, algorithm, exp_right=None, options={}, run_name=None)[source]

Bases: c3.optimizers.optimizer.Optimizer

Object that deals with the closed loop optimal control.

Parameters
  • dir_path (str) – Filepath to save results

  • eval_func (callable) – infidelity function to be minimized

  • pmap (ParameterMap) – Identifiers for the parameter vector

  • algorithm (callable) – From the algorithm library

  • options (dict) – Options to be passed to the algorithm

  • run_name (str) – User specified name for the run, will be used as root folder

goal_run(current_params)[source]

Evaluate the goal function for current parameters.

Parameters

current_params (tf.Tensor) – Vector representing the current parameter values.

Returns

Value of the goal function

Return type

tf.float64

log_pickle(params, seqs, results, results_std, shots)[source]

Save a pickled version of the performed experiment, suitable for model learning.

Parameters
  • params (tf.Tensor) – Vector of parameter values

  • seqs (list) – Strings identifying the performed instructions

  • results (list) – Values of the goal function

  • results_std (list) – Standard deviation of the results, in the case of noisy data

  • shots (list) – Number of repetitions used in averaging noisy data

log_setup() → None[source]

Create the folders to store data.

Parameters
  • dir_path (str) – Filepath

  • run_name (str) – User specified name for the run

optimize_controls() → None[source]

Apply a search algorithm to your gateset given a fidelity function.

set_eval_func(eval_func)[source]

Setter for the eval function.

Parameters

eval_func (callable) – Function to be evaluated

C3 - Characterization

Optimizer module

Optimizer object, where the optimal control is done.

class c3.optimizers.optimizer.Optimizer(pmap, algorithm=None, store_unitaries=False)[source]

Bases: object

General optimizer class from which specific classes are inherited.

Parameters
  • algorithm (callable) – From the algorithm library

  • plot_dynamics (boolean) – Save plots of time-resolved dynamics in dir_path

  • plot_pulses (boolean) – Save plots of control signals

  • store_unitaries (boolean) – Store propagators as text and pickle

end_log() → None[source]

Finish the log by recording current time and total runtime.

fct_to_min(input_parameters: Union[numpy.ndarray, tensorflow.python.ops.variables.Variable]) → Union[numpy.ndarray, tensorflow.python.ops.variables.Variable][source]

Wrapper for the goal function.

Parameters

x ([np.array, tf.Variable]) – Vector of parameters in the optimizer friendly way.

Returns

Value of the goal function. Float if input is np.array else tf.Variable

Return type

[float, tf.Variable]

fct_to_min_autograd(x)[source]

Wrapper for the goal function, including evaluation and storage of the gradient.

Parameters
xnp.array

Vector of parameters in the optimizer friendly way.

float

Value of the goal function.

goal_run(current_params: Union[numpy.ndarray, tensorflow.python.ops.variables.Variable]) → Union[numpy.ndarray, tensorflow.python.ops.variables.Variable][source]

Placeholder for the goal function. To be implemented by inherited classes.

goal_run_with_grad(current_params)[source]
load_best(init_point) → None[source]

Load a previous parameter point to start the optimization from. Legacy wrapper. Method moved to Parametermap.

Parameters

init_point (str) – File location of the initial point

log_best_unitary() → None[source]

Save the best unitary in the log.

log_parameters() → None[source]

Log the current status. Write parameters to log. Update the current best parameters. Call plotting functions as set up.

lookup_gradient(x)[source]

Return the stored gradient for a given parameter set.

Parameters

x (np.array) – Parameter set.

Returns

Value of the gradient.

Return type

np.array

replace_logdir(new_logdir)[source]

Specify a new filepath to store the log.

Parameters

new_logdir

set_algorithm(algorithm: Callable) → None[source]
set_created_by(config) → None[source]

Store the config file location used to created this optimizer.

set_exp(exp) → None[source]
start_log() → None[source]

Initialize the log with current time.

Sensitivity analysis

Object that deals with the sensitivity test.

class c3.optimizers.sensitivity.SET(dir_path, fom, estimator_list, sampling, batch_sizes, pmap, state_labels=None, sweep_map=None, sweep_bounds=None, algorithm=None, run_name=None, same_dyn=False, options={})[source]

Bases: c3.optimizers.optimizer.Optimizer

Object that deals with the sensitivity test.

Parameters
  • dir_path (str) – Filepath to save results

  • fom (callable) – Figure of merit

  • sampling (str) – Sampling method from the sampling library

  • batch_sizes (list) – Number of points to select from each dataset

  • sweep_map (list) – Identifiers to be swept

  • state_labels (list) – Identifiers for the qubit subspaces

  • algorithm (callable) – From the algorithm library

  • options (dict) – Options to be passed to the algorithm

  • same_dyn (boolean) –

    ?

  • run_name (str) – User specified name for the run, will be used as root folder

goal_run(current_params)[source]

Evaluate the figure of merit for the current model parameters.

Parameters

val (tf.Tensor) – Current model parameters

Returns

Figure of merit

Return type

tf.float64

log_setup(dir_path, run_name) → None[source]

Create the folders to store data.

Parameters
  • dir_path (str) – Filepath

  • run_name (str) – User specified name for the run

read_data(datafiles)[source]

Open data files and read in experiment results.

Parameters

datafiles (list of str) – List of paths for files that contain learning data.

select_from_data(batch_size)[source]

Select a subset of each dataset to compute the goal function on.

Parameters

batch_size (int) – Number of points to select

Returns

Indeces of the selected data points.

Return type

list

sensitivity()[source]

Run the sensitivity analysis.

Module contents