Template Class VectorJacobianProduct

Inheritance Relationships

Base Type

  • public AdjointJacobianBase< StateVectorT, VectorJacobianProduct< StateVectorT > >

Class Documentation

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

Vector Jacobian Product (VJP) functor.

Template Parameters

StateVectorT – State vector type.

Public Functions

inline void operator()(std::span<ComplexT> jac, const JacobianData<StateVectorT> &jd, std::span<const ComplexT> dy, bool apply_operations = false)

Compute vector Jacobian product for a statevector Jacobian.

Product of statevector Jacobian \(J_{ij} = \partial_{\theta_j} \psi_{\pmb{\theta}}(i)\) and a vector, i.e. this function returns \(w = v^\dagger J\). This is equivalent to

\[w_j = \langle v | \partial_{\theta_j} \psi_{\pmb{\theta}} \rangle\]

where \(\pmb{\theta}=(\theta_1, \theta_2, \cdots)\) is a list of all parameters and $v = dy$.

Note that \(J\) is \(2^n \times m\) matrix where \(n\) is the number of qubits and \(m\) is the number of trainable parameters in the tape. Thus the result vector is length \(m\).

Parameters
  • jac – Preallocated vector for Jacobian data results.

  • jd – Jacobian data

  • vec – A cotangent vector of size 2^n

  • apply_operations – Assume the given state is an input state and apply operations if true