quri_parts.core.estimator.gradient module#

numerical_gradient_estimates(op, state, params, estimator, delta)#

Estimate a gradient of an expectation value of a given operator for a parametric state with respect to the state parameter by a numerical differentiation.

The gradient estimates are configured with arguments as follows.

Parameters:
  • op (Estimatable) – An operator of which expectation value is estimated.

  • state (_ParametricStateT) – A parametric quantum state on which the operator expectation is evaluated.

  • params (Sequence[float]) – Parameter values for which the gradient is estimated.

  • estimator (ConcurrentParametricQuantumEstimator[_ParametricStateT]) – An estimator that estimates expectation values of the operator for the parametric states.

  • delta (float) – Step size for numerical differentiation.

Returns:

The estimated values (can be accessed with values) with errors of estimation (can be accessed with error_matrix).

Return type:

Estimates[complex]

create_numerical_gradient_estimator(parametric_estimator, delta)#

Create a GradientEstimator that estimates gradient values.

The gradient estimates are configured with arguments as follows.

Parameters:
  • parametric_estimator (ConcurrentParametricQuantumEstimator[_ParametricStateT]) – An estimator that estimates expectation values of the operator for the parametric states.

  • delta (float) – Step size for numerical differentiation.

Return type:

GradientEstimator[_ParametricStateT]

parameter_shift_gradient_estimates(op, state, params, estimator)#

Estimate a gradient of an expectation value of a given operator for a parametric state with respect to the state parameter by the parameter shift rule.

The gradient estimates are configured with arguments as follows.

Parameters:
  • op (Estimatable) – An operator of which expectation value is estimated.

  • state (_ParametricStateT) – A parametric quantum state on which the operator expectation is evaluated.

  • params (Sequence[float]) – Parameter values for which the gradient is estimated.

  • estimator (ConcurrentParametricQuantumEstimator[_ParametricStateT]) – An estimator that estimates expectation values of the operator for the parametric states.

Returns:

The estimated values (can be accessed with values) with errors of estimation (can be accessed with error_matrix).

Return type:

Estimates[complex]

create_parameter_shift_gradient_estimator(parametric_estimator)#
Parameters:

parametric_estimator (ConcurrentParametricQuantumEstimator[_ParametricStateT]) –

Return type:

GradientEstimator[_ParametricStateT]