Skip to content

Commit

Permalink
tidy up C++ layer
Browse files Browse the repository at this point in the history
  • Loading branch information
multiphaseCFD committed Sep 9, 2024
1 parent bff79c2 commit d1ba7d5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### New features since last release

* Add Matrix Product Operator (MPO) for all gates support to `lightning.tensor`.
* Add Matrix Product Operator (MPO) for all gates support to `lightning.tensor`. Note current C++ implementation only works for MPO sites data provided by users.
[(#859)](https://github.com/PennyLaneAI/pennylane-lightning/pull/859)

* Add shot measurement support to `lightning.tensor`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,14 @@ namespace Pennylane::LightningTensor::TNCuda {
the life time of the tensor network it's applied to. Note that the gate tensor
should be permuted to ascending order and decomposed into MPO sites before
passing to this class.
* @tparam PrecisionT Floating point type.
*/
template <class PrecisionT> class MPOTNCuda {
private:
using ComplexT = std::complex<PrecisionT>;
using CFP_t = decltype(cuUtil::getCudaType(PrecisionT{}));

// std::vector<std::size_t> wires_; // pennylane wires convention

cutensornetNetworkOperator_t MPOOperator_;
cuDoubleComplex coeff_ =
make_cuDoubleComplex(1.0, 0.0); // default coefficient
Expand Down Expand Up @@ -110,7 +109,7 @@ template <class PrecisionT> class MPOTNCuda {
*
* @return std::vector<void *>
*/
[[nodiscard]] auto getTensorsDataPtr() -> std::vector<void *> {
[[nodiscard]] auto getTensorsDataPtr_() -> std::vector<void *> {
std::vector<void *> tensorsDataPtr(numMPOSites_);
for (std::size_t i = 0; i < numMPOSites_; i++) {
tensorsDataPtr[i] = reinterpret_cast<void *>(
Expand Down Expand Up @@ -253,7 +252,7 @@ template <class PrecisionT> class MPOTNCuda {
getModeExtentsPtr_().data(),
/* const int64_t *tensorModeStrides[] */ nullptr,
/* const void * */
const_cast<const void **>(getTensorsDataPtr().data()),
const_cast<const void **>(getTensorsDataPtr_().data()),
/* cutensornetBoundaryCondition_t */ boundaryCondition_,
/* int64_t * */ &componentIdx_));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ class MPSTNCuda final : public TNCudaBase<Precision, MPSTNCuda<Precision>> {

// MPO configurations
// Note that CUTENSORNET_STATE_MPO_APPLICATION_INEXACT is applied if the
// `cutoff` value is not set to 0 for the MPO application
// `cutoff` value is not set to 0 for the MPO application.
cutensornetStateMPOApplication_t mpo_attribute =
(cutoff == 0) ? CUTENSORNET_STATE_MPO_APPLICATION_EXACT
: CUTENSORNET_STATE_MPO_APPLICATION_INEXACT;
Expand Down
2 changes: 1 addition & 1 deletion pennylane_lightning/lightning_tensor/_tensornet.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def _apply_MPO(self, gate_matrix, wires):

matrix = gate_matrix.astype(self._c_dtype)

max_mpo_bond_dim = 2 ** len(wires) # Full decomposition
max_mpo_bond_dim = 2 ** len(wires) # Exact SVD decomposition for MPO

tensor_shape = [2] * len(wires) * 2

Expand Down

0 comments on commit d1ba7d5

Please sign in to comment.