tangelo.toolboxes.optimizers package

Submodules

tangelo.toolboxes.optimizers.rotosolve module

tangelo.toolboxes.optimizers.rotosolve.extrapolate_expval(theta, m_0, m_minus, m_plus, phi=0.0)

Extrapolates the expectation value of an observable M with respect to a single parameterized rotation (i.e. RX, RY, RZ) with angle theta. The extrapolation uses samples taken at the angles phi, phi+pi/2, and phi-pi/2. This function uses the formula in Appendix A from arXiv:1905.09692, by Mateusz Ostaszewski et al.

Parameters:
  • theta (float) – Gate rotation angle to extrapolate to

  • m_0 (float) – Expectation value of M mat angle phi

  • m_minus (float) – Expectation value of M mat angle phi - pi/2

  • m_plus (float) – Expectation value of M mat angle phi + pi/2

  • phi (float, optional) – Angle of phi. Defaults to 0.0

Returns:

float – The expectation value of M estimated for theta.

tangelo.toolboxes.optimizers.rotosolve.rotoselect(func, var_params, var_rot_axes, *func_args, ftol=1e-05, maxiter=100)
Optimization procedure for parameterized quantum circuits whose

objective function varies sinusoidally with the parameters. This routine differs from rotosolve by sampling expectation values using the Pauli {X,Y,Z} generators instead of shifted angles of rotation. Based on the work by arXiv:1905.09692, Mateusz Ostaszewski.

Parameters:
  • func (function handle) – The function that performs energy estimation. This function takes variational parameters and parameter rotation axes (list of “RX”, “RY”, “RZ” strings) as input and returns a float.

  • var_params (list) – The variational parameters.

  • var_rot_axes (list) – List of strings (“RX”, “RY”, or “RZ”) corresonding to the axis of rotation for each angle in the list of variational parameters.

  • ftol (float) – Convergence threshold.

  • maxiter (int) – The maximum number of iterations.

  • *func_args (tuple) – Optional arguments to pass to func.

Returns:
  • float – The optimal energy found by the optimizer.

  • list of floats – Optimal parameters.

  • list of strings – Optimal rotation axes.

tangelo.toolboxes.optimizers.rotosolve.rotoselect_step(func, var_params, var_rot_axes, i, *func_args)

Gradient free optimization step using specific points to characterize objective function w.r.t to parameterized rotation axes and rotation angles. Based on formulas in arXiv:1905.09692, Mateusz Ostaszewski

Args:
func (function handle): The function that performs energy

estimation. This function takes variational parameters and parameter rotation axes (list of “RX”, “RY”, “RZ” strings) as input and returns a float.

var_params (list of float): The variational parameters. var_rot_axes (list): List of strings (“RX”, “RY”, or “RZ”)

corresonding to the axis of rotation for each angle in the list of variational parameters.

i (int): Index of the variational parameter to update. *func_args (tuple): Optional arguments to pass to func.

Returns:

list of floats: Optimal parameters list of strs: Optimal rotation axes

tangelo.toolboxes.optimizers.rotosolve.rotosolve(func, var_params, *func_args, ftol=1e-05, maxiter=100, extrapolate=False)
Optimization procedure for parameterized quantum circuits whose

objective function varies sinusoidally with the parameters. Based on the work by arXiv:1905.09692, Mateusz Ostaszewski.

Parameters:
  • func (function handle) – The function that performs energy estimation. This function takes variational parameters as input and returns a float.

  • var_params (list) – The variational parameters.

  • ftol (float) – Convergence threshold.

  • maxiter (int) – The maximum number of iterations.

  • *func_args (tuple) – Optional arguments to pass to func.

  • extrapolate (bool) – If True, the expectation value of func extrapolated from previous calls to rotosolve_step() will be used instead of a function evaluation. This requires only two function evaluations per parameter per iteration, but may be less stable on noisy devices. If False, three evaluations are used per parameter per iteration.

Returns:
  • float – The optimal energy found by the optimizer.

  • list of floats – Optimal parameters.

tangelo.toolboxes.optimizers.rotosolve.rotosolve_step(func, var_params, i, *func_args, phi=0.0, m_phi=None)

Gradient free optimization step using specific points to characterize objective function w.r.t to parameter values. Based on formulas in arXiv:1905.09692, Mateusz Ostaszewski

Args:
func (function handle): The function that performs energy

estimation. This function takes variational params as input and returns a float.

var_params (list of float): The variational parameters. i (int): Index of the variational parameter to update. *func_args (tuple): Optional arguments to pass to func. phi (float): Optional angle phi for extrapolation (default is 0.0). m_phi (float): Optional estimated value of m_phi

Returns:

list of floats: Optimal parameters float: Estimated optimal value of func

Module contents