CircuitOptimizer

This class allows for low level calls which are wrapped in a Python class having the same name and a simpler API (see Circuit Optimizer).

class exqalibur.CircuitOptimizer

CircuitOptimizer fits a unitary matrix on an interferometer containing variable parameters.

A gradient descent algorithm is used to get as close as possible to the unitary matrix. The distance between the target and the result is computed with fidelity.

Parameters:
  • target_matrix – Unitary matrix to fit

  • serial_circuit – Byte representation of a unitary circuit serialised with the specialised protobuf call

  • empty_modes – Optional list of modes where there won’t be any input. Knowing this information makes the gradient descent easier (quicker, better fidelity on the remaining columns)

property fidelity
Returns:

The computed fidelity for the latest optimisation

optimize(*args, **kwargs)

Overloaded function.

  1. optimize(self: exqalibur.CircuitOptimizer, max_trials: typing.SupportsInt = 4) -> bytes

Start the gradient descent algorithm multiple times, from arbitrary starting points.

Parameters:

max_trials – Number of gradient descent algorithms to run (default 4). Several CPU cores may be used to run them parallely (see exqalibur.Config for additional information)

Returns:

Byte representation of the optimised circuit, serialised with the specialised protobuf call

  1. optimize(self: exqalibur.CircuitOptimizer, first_guess: collections.abc.Sequence[typing.SupportsFloat] = []) -> bytes

Start the gradient descent algorithm from guessed starting points.

Parameters:

first_guess – Guessed optimized parameters

Returns:

Byte representation of the optimised circuit, serialised with the specialised protobuf call

set_max_eval_per_trial(self: exqalibur.CircuitOptimizer, max_eval: SupportsInt) None

Set a maximum number of iterations in a single gradient descent.

Parameters:

max_eval – Number of iterations which stops a trial when exceeded

set_max_time_per_trial(self: exqalibur.CircuitOptimizer, max_time: SupportsFloat) None

Set a time limit for a single gradient descent.

Parameters:

max_time – Time (in seconds) which stops the trial when exceeded

set_threshold(self: exqalibur.CircuitOptimizer, threshold: SupportsFloat) None

Set a fidelity threshold.

Gradient descent algorithm will try to match this threshold before stopping.

Parameters:

threshold – Fidelity threshold (typically 1e-6)