quri_parts.core.estimator.gradient module#

quri_parts.core.estimator.gradient.numerical_gradient_estimates(op: Operator | PauliLabel, state: _ParametricStateT, params: Sequence[float], estimator: Callable[[Operator | PauliLabel, _ParametricStateT, Sequence[Sequence[float]]], Iterable[Estimate[complex]]], delta: float) Estimates[complex]#

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 – An operator of which expectation value is estimated.

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

  • params – Parameter values for which the gradient is estimated.

  • estimator – An estimator that estimates expectation values of the operator for the parametric states.

  • delta – Step size for numerical differentiation.

Returns:

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

quri_parts.core.estimator.gradient.create_numerical_gradient_estimator(parametric_estimator: Callable[[Operator | PauliLabel, _ParametricStateT, Sequence[Sequence[float]]], Iterable[Estimate[complex]]], delta: float) Callable[[Operator | PauliLabel, _ParametricStateT, Sequence[float]], Estimates[complex]]#

Create a GradientEstimator that estimates gradient values.

The gradient estimates are configured with arguments as follows.

Parameters:
  • parametric_estimator – An estimator that estimates expectation values of the operator for the parametric states.

  • delta – Step size for numerical differentiation.

quri_parts.core.estimator.gradient.parameter_shift_gradient_estimates(op: Operator | PauliLabel, state: _ParametricStateT, params: Sequence[float], estimator: Callable[[Operator | PauliLabel, _ParametricStateT, Sequence[Sequence[float]]], Iterable[Estimate[complex]]]) Estimates[complex]#

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 – An operator of which expectation value is estimated.

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

  • params – Parameter values for which the gradient is estimated.

  • estimator – 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).

quri_parts.core.estimator.gradient.create_parameter_shift_gradient_estimator(parametric_estimator: Callable[[Operator | PauliLabel, _ParametricStateT, Sequence[Sequence[float]]], Iterable[Estimate[complex]]]) Callable[[Operator | PauliLabel, _ParametricStateT, Sequence[float]], Estimates[complex]]#