Template Class MPSTNCuda

Inheritance Relationships

Base Type

Class Documentation

template<class Precision>
class MPSTNCuda : public Pennylane::LightningTensor::TNCuda::TNCudaBase<Precision, MPSTNCuda<Precision>>

Managed memory MPS class using cutensornet high-level APIs backed.

Template Parameters

Precision – Floating-point precision type.

Public Types

using CFP_t = decltype(cuUtil::getCudaType(Precision{}))
using ComplexT = std::complex<Precision>
using PrecisionT = Precision

Public Functions

MPSTNCuda() = delete
inline explicit MPSTNCuda(const std::size_t numQubits, const std::size_t maxBondDim)
inline explicit MPSTNCuda(const std::size_t numQubits, const std::size_t maxBondDim, DevTag<int> dev_tag)
~MPSTNCuda() = default
inline auto getMaxBondDim() const -> std::size_t

Get the max bond dimension.

Returns

std::size_t

inline auto getSitesExtentsPtr() -> std::vector<int64_t const*>

Get a vector of pointers to extents of each site.

Returns

std::vector<int64_t const *> Note int64_t const* is required by cutensornet backend.

inline auto getTensorsDataPtr() -> std::vector<uint64_t*>

Get a vector of pointers to tensor data of each site.

Returns

std::vector<uint64_t *>

inline auto getTensorsOutDataPtr() -> std::vector<CFP_t*>

Get a vector of pointers to tensor data of each site.

Returns

std::vector<CFP_t *>

inline void reset()

Set current quantum state as zero state.

inline void updateMPSSiteData(const std::size_t site_idx, const ComplexT *host_data, std::size_t host_data_size)

Update the ith MPS site data.

Parameters
  • site_idx – Index of the MPS site.

  • host_data – Pointer to the data on host.

  • host_data_size – Length of the data.

inline void setBasisState(const std::vector<std::size_t> &basisState)

Update quantum state with a basis state. NOTE: This API assumes the bond vector is a standard basis vector ([1,0,0,……]) and current implementation only works for qubit systems.

Parameters

basisState – Vector representation of a basis state.

inline void applyMPOOperation(const std::vector<std::vector<ComplexT>> &tensors, const std::vector<std::size_t> &wires, const std::size_t max_mpo_bond_dim)

Apply an MPO operator with the gate’s MPO decomposition data provided by the user to the compute graph.

This API only works for the MPS backend.

Parameters
  • tensors – The MPO representation of a gate. Each element in the outer vector represents a MPO tensor site.

  • wires – The wire indices of the gate acts on. The size of this vector should match the size of the tensors vector.

  • max_mpo_bond_dim – The maximum bond dimension of the MPO operator.

inline void append_mps_final_state(double cutoff = 0, std::string cutoff_mode = "abs")

Append MPS final state to the quantum circuit.

Parameters
  • cutoff – Cutoff value for SVD decomposition. Default is 0.

  • cutoff_mode – Cutoff mode for SVD decomposition. Default is “abs”.

inline void getData(ComplexT *res, const std::size_t res_length)

Get the full state vector representation of a MPS quantum state. Note that users/developers should be responsible to ensure that there is sufficient memory on the host to store the full state vector.

Parameters
  • res – Pointer to the host memory to store the full state vector

  • res_length – Length of the result vector

inline auto getDataVector() -> std::vector<ComplexT>

Get the full state vector representation of a MPS quantum state.

Returns

std::vector<ComplexT> Full state vector representation of MPS quantum state on host