qat.plugins.SeqOptim

class qat.plugins.SeqOptim(ncycles: Optional[int] = 10, coeff: Optional[float] = 1, x0: Optional[ndarray] = None, verbose: Optional[bool] = False, collective: bool = False)

This plugin implements the sequential parameter optimization technique (also known as rotosolve) described in:

It is a particularization of the Optimizer class.

It consists in tuning the parameters of a variational ansatz one after the other, cycling several times through all of them, leveraging the parameter shift rule to find a local minimum with three measurements of the cost function.

Such a method can be used only if all parametrized gates are of the form \(\exp(-i c \theta P/2)\) where \(P\) is a tensor product of Pauli matrices and \(c\) a number that must be entered in the ‘coeff’ field of the plugin (e.g. for rotation matrices \(RX\), \(RY\), \(RZ\), \(c=1\)).

In the current implementation of the plugin, all parameterized gates are assumed to be of the same type (i.e. have the same coefficient \(c\)).

Note

The applicability of the method is not checked for when the batch is received. It belongs to the user to provide a circuit matching the requirements mentioned above.

Parameters
  • ncycles (int, optional) – Number of times the plugin cycles through each angle, defaults to 10. The value to which it should be set so that the cost function converges is however strongly problem-dependent.

  • coeff (Optional[float]) – Rescaling parameter \(c\) for all the circuit’s angles. Defaults to 1.

  • x0 (Optional[np.ndarray]) – Initial value of the parameters. Defaults to None, in which case we assume random initialization.

  • verbose (bool) – whether we want to print intermediary cost function values, defaults to False.

compile(batch: Batch) Batch

Loops a batch through all the plugins present inside the QPU.

Parameters

batch (Batch) – a batch of jobs. If a single job is provided, the job is embedded into a Batch, compiled, and the first result is returned.

Returns

a batch of jobs

Return type

Batch