Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add exact tensor network C++ backend to LT #977

Merged
merged 61 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from 59 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
e7bbd43
initial commit
multiphaseCFD Nov 4, 2024
e41be74
Auto update version from '0.39.0-dev51' to '0.39.0-dev53'
ringo-but-quantum Nov 5, 2024
ae9110f
add getMethod public interface
multiphaseCFD Nov 5, 2024
e45b6af
move quantum state creation to tensornetbase class and ensure device …
multiphaseCFD Nov 5, 2024
7df0aea
move getData / getDataVector API from MPS class to TNCudaBase
multiphaseCFD Nov 5, 2024
3fe2b8d
move tensor data from MPSTNCuda to TNCudaBase
multiphaseCFD Nov 5, 2024
4dbcdcf
move basistate set to the base
multiphaseCFD Nov 5, 2024
bd4ba9c
fix typo
multiphaseCFD Nov 5, 2024
8ed779c
method as static data and tidy up
multiphaseCFD Nov 5, 2024
e509ea5
Merge branch 'master' into add_exatn_cpp
multiphaseCFD Nov 6, 2024
cd2c2c6
Auto update version from '0.40.0-dev0' to '0.40.0-dev1'
ringo-but-quantum Nov 6, 2024
594e530
fix exatn initialization
multiphaseCFD Nov 6, 2024
548ebaa
move more methods and data to tncudabase class
multiphaseCFD Nov 6, 2024
46f2e80
tidy up code
multiphaseCFD Nov 6, 2024
aa4e284
rename updateMPSSiteData method
multiphaseCFD Nov 6, 2024
ee4e3f3
skip ci
multiphaseCFD Nov 6, 2024
2825e82
Merge branch 'master' into add_exatn_cpp
multiphaseCFD Nov 8, 2024
57d4536
Auto update version from '0.40.0-dev4' to '0.40.0-dev5'
ringo-but-quantum Nov 8, 2024
570b9bd
Merge branch 'master' into add_exatn_cpp
multiphaseCFD Nov 18, 2024
8b75653
Auto update version from '0.40.0-dev11' to '0.40.0-dev12'
ringo-but-quantum Nov 18, 2024
c32ca00
Add C++ unit tests for Exact Tensor Network backends (#998)
LuisAlfredoNu Nov 28, 2024
4e6b5d3
Auto update version from '0.40.0-dev12' to '0.40.0-dev22'
ringo-but-quantum Nov 28, 2024
90147a1
Merge branch 'master' into add_exatn_cpp
multiphaseCFD Nov 28, 2024
daf97c8
Auto update version from '0.40.0-dev21' to '0.40.0-dev22'
ringo-but-quantum Nov 28, 2024
2e6e272
fix codefactor complains
multiphaseCFD Nov 28, 2024
85ede43
update testHelpersTNCuda
multiphaseCFD Nov 28, 2024
ca23421
Merge branch 'master' into add_exatn_cpp
multiphaseCFD Nov 28, 2024
263cebb
Auto update version from '0.40.0-dev23' to '0.40.0-dev24'
ringo-but-quantum Nov 28, 2024
232b6d5
add changelog entry
multiphaseCFD Nov 28, 2024
c2f1ea5
Update pennylane_lightning/core/src/simulators/lightning_tensor/tncud…
multiphaseCFD Nov 28, 2024
5f7eda8
Update pennylane_lightning/core/src/simulators/lightning_tensor/tncud…
multiphaseCFD Nov 28, 2024
6f862a7
Update pennylane_lightning/core/src/simulators/lightning_tensor/tncud…
multiphaseCFD Nov 28, 2024
3ec8a24
make format
multiphaseCFD Dec 2, 2024
04b5309
remove the setBasisState comment
multiphaseCFD Dec 2, 2024
34393ed
quick fix
multiphaseCFD Dec 2, 2024
26d20f1
default destructor
multiphaseCFD Dec 2, 2024
5b9b05c
apply Joseph's suggestions
multiphaseCFD Dec 3, 2024
1407b9c
Auto update version from '0.40.0-dev24' to '0.40.0-dev25'
ringo-but-quantum Dec 3, 2024
eae05cf
Merge branch 'master' into add_exatn_cpp
multiphaseCFD Dec 3, 2024
d7b8897
Auto update version from '0.40.0-dev24' to '0.40.0-dev25'
ringo-but-quantum Dec 3, 2024
dd8b063
add TODOs
multiphaseCFD Dec 3, 2024
a1482b9
exatn->exacttn
multiphaseCFD Dec 3, 2024
0e34cc1
bug fix
multiphaseCFD Dec 3, 2024
3e2cd56
update docstring
multiphaseCFD Dec 3, 2024
ca98aec
fix naming issues Tensornet->TNCuda, TNCudaBase->TNCuda
multiphaseCFD Dec 3, 2024
31e3a13
const, constexpr
multiphaseCFD Dec 3, 2024
50e4a62
fix changelog
multiphaseCFD Dec 3, 2024
b465401
Merge branch 'master' into add_exatn_cpp
multiphaseCFD Dec 4, 2024
178f110
Auto update version from '0.40.0-dev26' to '0.40.0-dev27'
ringo-but-quantum Dec 4, 2024
4d000f2
Merge branch 'master' into add_exatn_cpp
multiphaseCFD Dec 4, 2024
b1b1a29
Auto update version from '0.40.0-dev27' to '0.40.0-dev28'
ringo-but-quantum Dec 4, 2024
20eefa8
Auto update version from '0.40.0-dev28' to '0.40.0-dev29'
ringo-but-quantum Dec 4, 2024
43a3ae0
Merge branch 'master' into add_exatn_cpp
multiphaseCFD Dec 4, 2024
f8786da
Auto update version from '0.40.0-dev28' to '0.40.0-dev29'
ringo-but-quantum Dec 4, 2024
d59eeb5
update obs instantiation
multiphaseCFD Dec 5, 2024
6df4919
Merge branch 'master' into add_exatn_cpp
multiphaseCFD Dec 5, 2024
ab62e0e
make format
multiphaseCFD Dec 5, 2024
26dc605
Auto update version from '0.40.0-dev29' to '0.40.0-dev30'
ringo-but-quantum Dec 5, 2024
c9157de
Merge branch 'master' into add_exatn_cpp
multiphaseCFD Dec 5, 2024
630d08a
Auto update version from '0.40.0-dev30' to '0.40.0-dev31'
ringo-but-quantum Dec 5, 2024
bfcc9cc
apply Alfredo's suggestions
multiphaseCFD Dec 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

### New features since last release

* Add native N-controlled gate/matrix operations and adjoint support to `lightning.kokkos`.
[(#950)](https://github.com/PennyLaneAI/pennylane-lightning/pull/950)
* Add Exact Tensor Network C++ backend to `lightning.tensor`.
[(#977)](https://github.com/PennyLaneAI/pennylane-lightning/pull/977)

* Add native N-controlled generators and adjoint support to `lightning.gpu`'s single-GPU backend.
[(#970)](https://github.com/PennyLaneAI/pennylane-lightning/pull/970)
Expand All @@ -12,6 +12,9 @@
[(#960)](https://github.com/PennyLaneAI/pennylane-lightning/pull/960)
[(#999)](https://github.com/PennyLaneAI/pennylane-lightning/pull/999)

* Add native N-controlled gate/matrix operations and adjoint support to `lightning.kokkos`.
[(#950)](https://github.com/PennyLaneAI/pennylane-lightning/pull/950)

* Add native N-controlled gates support to `lightning.gpu`'s single-GPU backend.
[(#938)](https://github.com/PennyLaneAI/pennylane-lightning/pull/938)

Expand Down Expand Up @@ -55,6 +58,9 @@
* Update Kokkos version support to 4.4.1 and enable Lightning-Kokkos[CUDA] C++ tests on CI.
[(#1000)](https://github.com/PennyLaneAI/pennylane-lightning/pull/1000)

* Add C++ unit tests for Exact Tensor Network backends.
[(#998)](https://github.com/PennyLaneAI/pennylane-lightning/pull/998)

* Add native BLAS support to the C++ layer via dynamic `scipy-openblas32` loading.
[(#995)](https://github.com/PennyLaneAI/pennylane-lightning/pull/995)

Expand Down
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,8 @@ endif()
foreach(BACKEND ${PL_BACKEND})
message(STATUS "PL_BACKEND: ${BACKEND}")
if("${BACKEND}" STREQUAL "lightning_tensor")
set(PL_TENSOR_METHOD "mps" CACHE STRING "PennyLane LightningTensor MPS simulator.")
set(PL_TENSOR_BACKEND "cutensornet" CACHE STRING "PennyLane LightningTensor backed by cutensornet")
set(PL_TENSOR "${PL_BACKEND}_${PL_TENSOR_METHOD}_${PL_TENSOR_BACKEND}")
set(PL_TENSOR "${PL_BACKEND}_${PL_TENSOR_BACKEND}")
endif()
endforeach()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ include("${pennylane_lightning_SOURCE_DIR}/cmake/support_pltensortncuda.cmake")
findCUDATK(lightning_external_libs)
findCutensornet(lightning_external_libs)

set(LTENSOR_MPS_FILES MPSTNCuda.cpp CACHE INTERNAL "" FORCE)
set(LTENSOR_MPS_FILES MPSTNCuda.cpp ExactTNCuda.cpp MPOTNCuda.cpp CACHE INTERNAL "" FORCE)

add_library(${PL_BACKEND} STATIC ${LTENSOR_MPS_FILES})

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2024 Xanadu Quantum Technologies Inc.

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

// http://www.apache.org/licenses/LICENSE-2.0

// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "ExactTNCuda.hpp"

// explicit instantiation
template class Pennylane::LightningTensor::TNCuda::ExactTNCuda<float>;
template class Pennylane::LightningTensor::TNCuda::ExactTNCuda<double>;
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Copyright 2024 Xanadu Quantum Technologies Inc.

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

// http://www.apache.org/licenses/LICENSE-2.0

// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
* @file MPSTNCuda.hpp
* MPS class with cuTensorNet backend. Note that current implementation only
* support the open boundary condition.
multiphaseCFD marked this conversation as resolved.
Show resolved Hide resolved
*/

#pragma once

#include <vector>

#include "DevTag.hpp"
#include "TNCuda.hpp"
#include "TNCudaBase.hpp"
#include "TensorCuda.hpp"
#include "Util.hpp"

/// @cond DEV
namespace {
using namespace Pennylane::LightningGPU;
using namespace Pennylane::LightningTensor::TNCuda;
using namespace Pennylane::LightningTensor::TNCuda::Util;
} // namespace
/// @endcond

namespace Pennylane::LightningTensor::TNCuda {

/**
* @brief Managed memory Exact Tensor Network class using cutensornet high-level
* APIs.
*
* @tparam Precision Floating-point precision type.
*/

template <class Precision>
class ExactTNCuda final : public TNCuda<Precision, ExactTNCuda<Precision>> {
private:
using BaseType = TNCuda<Precision, ExactTNCuda>;

public:
constexpr static auto method = "exacttn";

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

public:
ExactTNCuda() = delete;

explicit ExactTNCuda(std::size_t numQubits) : BaseType(numQubits) {}

explicit ExactTNCuda(std::size_t numQubits, DevTag<int> dev_tag)
: BaseType(numQubits, dev_tag) {}

~ExactTNCuda() = default;
};
} // namespace Pennylane::LightningTensor::TNCuda
Loading
Loading