From 593bd146a23a8f126bd93efa1f273e5673a4eae9 Mon Sep 17 00:00:00 2001 From: Shuli Shu <08cnbj@gmail.com> Date: Tue, 17 Dec 2024 13:27:07 -0500 Subject: [PATCH 1/5] init commit --- .../lightning_tensor/tncuda/MPSTNCuda.hpp | 17 +++---------- .../lightning_tensor/tncuda/TNCuda.hpp | 24 ------------------- 2 files changed, 3 insertions(+), 38 deletions(-) diff --git a/pennylane_lightning/core/src/simulators/lightning_tensor/tncuda/MPSTNCuda.hpp b/pennylane_lightning/core/src/simulators/lightning_tensor/tncuda/MPSTNCuda.hpp index d2c77eeea..631244159 100644 --- a/pennylane_lightning/core/src/simulators/lightning_tensor/tncuda/MPSTNCuda.hpp +++ b/pennylane_lightning/core/src/simulators/lightning_tensor/tncuda/MPSTNCuda.hpp @@ -238,20 +238,9 @@ class MPSTNCuda final : public TNCuda> { const_cast(BaseType::getSitesExtentsPtr().data()), reinterpret_cast(BaseType::getTensorsOutDataPtr().data())); - // TODO: This is a dummy tensor update to allow multiple calls to the - // `append_mps_final_state` method as well as appending additional - // operations to the graph. This is a temporary solution and this line - // can be removed in the future when the `cutensornet` backend allows - // multiple calls to the `cutensornetStateFinalizeMPS` method. For more - // details, please see the `cutensornet` high-level API workflow logic - // [here] - // (https://docs.nvidia.com/cuda/cuquantum/latest/cutensornet/api/functions.html#high-level-tensor-network-api). - // In order to proceed with the following gate operations or - // measurements after calling the `cutensornetStateCompute()` API, we - // have to call the `cutensornetStateUpdateTensor()` API, which is - // wrapped inside the `dummy_tensor_update()` method. - // - BaseType::dummy_tensor_update(); + PL_CUTENSORNET_IS_SUCCESS(cutensornetStateCaptureMPS( + /* const cutensornetHandle_t */ BaseType::getTNCudaHandle(), + /* cutensornetState_t */ BaseType::getQuantumState())); } }; } // namespace Pennylane::LightningTensor::TNCuda diff --git a/pennylane_lightning/core/src/simulators/lightning_tensor/tncuda/TNCuda.hpp b/pennylane_lightning/core/src/simulators/lightning_tensor/tncuda/TNCuda.hpp index f268af047..fb249f051 100644 --- a/pennylane_lightning/core/src/simulators/lightning_tensor/tncuda/TNCuda.hpp +++ b/pennylane_lightning/core/src/simulators/lightning_tensor/tncuda/TNCuda.hpp @@ -528,30 +528,6 @@ class TNCuda : public TNCudaBase { return sitesExtentsPtr_int64; } - /** - * @brief Dummy tensor operator update to allow multiple calls of - * appendMPSFinalize. This is a workaround to avoid the issue of the - * cutensornet library not allowing multiple calls of appendMPSFinalize. - * - * This function either appends a new `Identity` gate to the graph when the - * gate cache is empty or update the existing gate operator by itself. - */ - void dummy_tensor_update() { - if (identiy_gate_ids_.empty()) { - applyOperation("Identity", {0}, false); - } - - PL_CUTENSORNET_IS_SUCCESS(cutensornetStateUpdateTensorOperator( - /* const cutensornetHandle_t */ BaseType::getTNCudaHandle(), - /* cutensornetState_t */ BaseType::getQuantumState(), - /* int64_t tensorId*/ - static_cast(identiy_gate_ids_.front()), - /* void* */ - static_cast( - gate_cache_->get_gate_device_ptr(identiy_gate_ids_.front())), - /* int32_t unitary*/ 1)); - } - /** * @brief Save quantumState information to data provided by a user * From 78566ea9a228b09063611e631d88ee45d7dfa2e9 Mon Sep 17 00:00:00 2001 From: ringo-but-quantum Date: Tue, 17 Dec 2024 18:28:16 +0000 Subject: [PATCH 2/5] Auto update version from '0.40.0-dev37' to '0.40.0-dev38' --- pennylane_lightning/core/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pennylane_lightning/core/_version.py b/pennylane_lightning/core/_version.py index 87a488e55..48a152c2d 100644 --- a/pennylane_lightning/core/_version.py +++ b/pennylane_lightning/core/_version.py @@ -16,4 +16,4 @@ Version number (major.minor.patch[-label]) """ -__version__ = "0.40.0-dev37" +__version__ = "0.40.0-dev38" From 034c8667472ecf94552e4e94e63e624ee174a66f Mon Sep 17 00:00:00 2001 From: Shuli Shu <08cnbj@gmail.com> Date: Tue, 17 Dec 2024 13:31:43 -0500 Subject: [PATCH 3/5] update changelog --- .github/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index f1f0d74eb..450625b31 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -29,6 +29,9 @@ ### Improvements +* Replace the `dummy_tensor_update` method with the `cutensornetStateCaptureMPS`API to ensure that further gates apply is allowed after the `cutensornetStateCompute` call. + [(#1028)](https://github.com/PennyLaneAI/pennylane-lightning/pull/1028/) + * Update the python layer UI of Lightning Tensor. [(#1022)](https://github.com/PennyLaneAI/pennylane-lightning/pull/1022/) From 8476d92da4690ebc5279d236d0f9ad0cb768b449 Mon Sep 17 00:00:00 2001 From: ringo-but-quantum Date: Wed, 18 Dec 2024 15:55:28 +0000 Subject: [PATCH 4/5] Auto update version from '0.40.0-dev38' to '0.40.0-dev39' --- pennylane_lightning/core/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pennylane_lightning/core/_version.py b/pennylane_lightning/core/_version.py index 48a152c2d..e50c1c959 100644 --- a/pennylane_lightning/core/_version.py +++ b/pennylane_lightning/core/_version.py @@ -16,4 +16,4 @@ Version number (major.minor.patch[-label]) """ -__version__ = "0.40.0-dev38" +__version__ = "0.40.0-dev39" From 346cf3746939b9376931c7082357fee95a24007e Mon Sep 17 00:00:00 2001 From: ringo-but-quantum Date: Wed, 18 Dec 2024 17:26:09 +0000 Subject: [PATCH 5/5] Auto update version from '0.40.0-dev39' to '0.40.0-dev40' --- pennylane_lightning/core/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pennylane_lightning/core/_version.py b/pennylane_lightning/core/_version.py index e50c1c959..0e752dbe5 100644 --- a/pennylane_lightning/core/_version.py +++ b/pennylane_lightning/core/_version.py @@ -16,4 +16,4 @@ Version number (major.minor.patch[-label]) """ -__version__ = "0.40.0-dev39" +__version__ = "0.40.0-dev40"