Template Class AdjointJacobianMPI

Inheritance Relationships

Base Type

  • public AdjointJacobianBase< StateVectorT, AdjointJacobianMPI< StateVectorT > >

Class Documentation

template<class StateVectorT>
class AdjointJacobianMPI : public AdjointJacobianBase<StateVectorT, AdjointJacobianMPI<StateVectorT>>

GPU-enabled adjoint Jacobian evaluator following the method of arXiV:2009.02823.

Template Parameters

StateVectorT – State vector type.

Public Functions

AdjointJacobianMPI() = default
inline void adjointJacobian_serial(std::span<PrecisionT> jac, const JacobianDataMPI<StateVectorT> &jd, bool apply_operations = false)

Batches the adjoint_jacobian method over the available GPUs.

Parameters
  • jac – Preallocated vector for Jacobian data results.

  • jd – JacobianData represents the QuantumTape to differentiate.

  • apply_operations – Indicate whether to apply operations to psi prior to calculation.

inline void adjointJacobian(std::span<PrecisionT> jac, const JacobianDataMPI<StateVectorT> &jd, const StateVectorT &ref_data, bool apply_operations = false)

Calculates the Jacobian for the statevector for the selected set of parametric gates.

For the statevector data associated with psi of length num_elements, we make internal copies to a StateVectorCudaManaged<T> object, with one per required observable. The operations will be applied to the internal statevector copies, with the operation indices participating in the gradient calculations given in trainableParams, and the overall number of parameters for the gradient calculation provided within num_params. The resulting row-major ordered jac matrix representation will be of size jd.getSizeStateVec() * jd.getObservables().size(). OpenMP is used to enable independent operations to be offloaded to threads.

Note

Only gates with pre-defined generators can be differentiated. For example, QubitUnitary is not differentiable as there is no generator defined for this gate.

Parameters
  • jac – Preallocated vector for Jacobian data results.

  • jd – JacobianData represents the QuantumTape to differentiate.

  • ref_data – Reference to a StateVectorT object.

  • apply_operations – Indicate whether to apply operations to psi prior to calculation.