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 NonParametric & Parametric Gates support to Lightning.Tensor #718

Merged
merged 132 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from 104 commits
Commits
Show all changes
132 commits
Select commit Hold shift + click to select a range
44c84c4
init commit
multiphaseCFD Apr 30, 2024
a1997a3
Auto update version from '0.36.0-dev44' to '0.36.0-dev46'
ringo-but-quantum Apr 30, 2024
8c69e91
typo fix
multiphaseCFD Apr 30, 2024
08736b4
fix last blank line error
multiphaseCFD Apr 30, 2024
3ac6d91
fix codecov warnings
multiphaseCFD Apr 30, 2024
8a594fa
Merge branch 'master' into add_MPSCutn_basis
multiphaseCFD Apr 30, 2024
245974f
fix CI & change ctor interface
multiphaseCFD Apr 30, 2024
3d29627
remove unused methods
multiphaseCFD Apr 30, 2024
00283ba
tidy up code and add more unit tests
multiphaseCFD Apr 30, 2024
b19200f
add testhelper & tidy up code
multiphaseCFD Apr 30, 2024
60f5695
fix typo
multiphaseCFD Apr 30, 2024
c437c3f
set PL_TENSOR in the root cmakelists
multiphaseCFD Apr 30, 2024
6889198
add more tests for tensor classes
multiphaseCFD Apr 30, 2024
a71c2e4
make format
multiphaseCFD Apr 30, 2024
381f95e
fix sitesExtents_ init & add mpscutn tests
multiphaseCFD Apr 30, 2024
6508c34
only test cutnmps cpp layer
multiphaseCFD Apr 30, 2024
b03e93c
further tidy up code
multiphaseCFD Apr 30, 2024
8b0f0f5
update MPS ctor
multiphaseCFD May 1, 2024
597dc58
refactor MPSCutn to allow easy TN extension
multiphaseCFD May 1, 2024
32f5c9f
move methods to CutnBase class & rename maxextent
multiphaseCFD May 1, 2024
fdcbc6c
update docstring
multiphaseCFD May 1, 2024
ea1e0d0
turn on all ci unit tests
multiphaseCFD May 1, 2024
192cc94
fix codefactor complaining
multiphaseCFD May 1, 2024
e658a40
add changelog
multiphaseCFD May 1, 2024
3f8282f
Trigger CI
multiphaseCFD May 1, 2024
46f050a
quick fix for getFreeMemorySize
multiphaseCFD May 1, 2024
4a822eb
fix based on some comments
multiphaseCFD May 2, 2024
5445bbe
size_t->std::size_t
multiphaseCFD May 2, 2024
e606691
set computeState() as protected & make format
multiphaseCFD May 2, 2024
dc55714
copy ctor -> std::move
multiphaseCFD May 2, 2024
27e3dab
safer store for ptr to sitesExtents and tensor
multiphaseCFD May 2, 2024
81e745e
std::vector<void*> ->std::vector<uint64_t*>
multiphaseCFD May 2, 2024
acc870f
update base on comments
multiphaseCFD May 2, 2024
0a91c9e
update docstring
multiphaseCFD May 3, 2024
1318aa5
update memory set
multiphaseCFD May 3, 2024
a127527
make format
multiphaseCFD May 3, 2024
99824ee
size_t->std::size_t for ->GENERATE
multiphaseCFD May 3, 2024
486e8f8
Auto update version from '0.36.0-dev46' to '0.36.0-dev48'
ringo-but-quantum May 3, 2024
8c12697
On-Board Lightning Linux workflows (that are run on PRs) to large run…
rashidnhm May 3, 2024
45fa5c5
Port PR #705 changes (#711)
AmintorDusko May 3, 2024
932c8f9
Merge branch 'master' into add_MPSCutn_basis
multiphaseCFD May 3, 2024
3aa6a15
fix naming comments and drop initHelper_()
multiphaseCFD May 6, 2024
d87a6b8
move MPSStatus to MPS class & update docstrings
multiphaseCFD May 6, 2024
e90750d
udpate tensornetbase ctor
multiphaseCFD May 6, 2024
0d03cf1
Auto update version from '0.36.0-dev48' to '0.36.0-dev49'
ringo-but-quantum May 6, 2024
0befceb
enum to c++ style
multiphaseCFD May 6, 2024
43e1032
Merge branch 'master' into add_MPSCutn_basis
multiphaseCFD May 6, 2024
858defa
update unit tests
multiphaseCFD May 7, 2024
8170f7a
update class name cutn->TNCuda
multiphaseCFD May 7, 2024
e6248b0
Auto update version from '0.36.0-dev49' to '0.37.0-dev2'
ringo-but-quantum May 7, 2024
b6aa4cd
Syncing master with V0.36.0 branch (#715)
AmintorDusko May 7, 2024
cc2688e
Update Linux wheels to use manylinux_2_28 (#667)
AmintorDusko May 7, 2024
5610531
Merge branch 'master' into add_MPSCutn_basis
multiphaseCFD May 7, 2024
d0a8ca7
change filename
multiphaseCFD May 7, 2024
c79104c
make format
multiphaseCFD May 7, 2024
4df1757
Auto update version from '0.37.0-dev2' to '0.37.0-dev3'
ringo-but-quantum May 7, 2024
6c2fbb4
change path name
multiphaseCFD May 7, 2024
01187c1
Accelerate CI parallelizing over OMP configs (#712)
vincentmr May 7, 2024
bafea32
Merge branch 'master' into add_MPSCutn_basis
multiphaseCFD May 7, 2024
4b4af4f
Initial commit
multiphaseCFD May 7, 2024
5c46064
add changelog
multiphaseCFD May 1, 2024
2b8b3c7
Merge branch 'master' into add_MPSCutn_basis
multiphaseCFD May 7, 2024
0c06808
Auto update version from '0.37.0-dev3' to '0.37.0-dev4'
ringo-but-quantum May 7, 2024
c85c2ff
refactor TNCudaGateCache & add appendGateTensorOperator
multiphaseCFD May 8, 2024
8e87882
add tests for 1 & 2 qubits gates
multiphaseCFD May 8, 2024
6721462
add unit tests for 3 qubit gates & update compute state
multiphaseCFD May 8, 2024
a7d13a8
tidy up getDataVector() and remove once call limitation
multiphaseCFD May 8, 2024
10b041f
tidy up code
multiphaseCFD May 8, 2024
03b0434
fix multiple reset()/setbasisstate() & resolve comments
multiphaseCFD May 9, 2024
881004d
Merge branch 'add_MPSCutn_basis' into add_LTensor_nonParam_gate
multiphaseCFD May 9, 2024
67e11bc
add gates sub_directory to build
multiphaseCFD May 9, 2024
f6f1ab7
add initial unit tests for parametric gates
multiphaseCFD May 9, 2024
d708233
add ising gates
multiphaseCFD May 10, 2024
4c4cc75
Merge branch 'master' into add_LTensor_nonParam_gate
multiphaseCFD May 13, 2024
60f873a
update version
multiphaseCFD May 13, 2024
581a758
add controlledPhaseShift
multiphaseCFD May 13, 2024
38347eb
add all the parametric gates besides multiRZ
multiphaseCFD May 14, 2024
8d4620a
Test unsupported gate
multiphaseCFD May 14, 2024
655fe30
allow passing matrix on host to device as operator
multiphaseCFD May 14, 2024
1f4726e
add changelog
multiphaseCFD May 14, 2024
ddfda1a
col-major for LGPU and row-major for LTN
multiphaseCFD May 14, 2024
a79a256
Trigger CI
multiphaseCFD May 14, 2024
791a7e1
Merge branch 'master' into add_LTensor_nonParam_gate
multiphaseCFD May 14, 2024
cf9b1bc
Auto update version from '0.37.0-dev9' to '0.37.0-dev10'
ringo-but-quantum May 14, 2024
61bc4af
tidy up code
multiphaseCFD May 16, 2024
b44adc1
Auto update version from '0.37.0-dev10' to '0.37.0-dev14'
ringo-but-quantum May 16, 2024
89ab6a3
Add `MPSTNCuda` class (#704)
multiphaseCFD May 14, 2024
f9b992e
Fix LQ version checking out in LK-CPU tests (#723)
vincentmr May 15, 2024
f3b1141
Kokkos gate functors are templated over the coefficient interaction f…
vincentmr May 15, 2024
9ade042
Revert default.tensor to lightning.tensor. (#730)
vincentmr May 15, 2024
2a5bfda
tidy up code
multiphaseCFD May 16, 2024
cf36804
Merge branch 'master' into add_LTensor_nonParam_gate
multiphaseCFD May 16, 2024
027a619
Auto update version from '0.37.0-dev13' to '0.37.0-dev14'
ringo-but-quantum May 16, 2024
6774208
tidy up code
multiphaseCFD May 16, 2024
eb3d481
tidy up code
multiphaseCFD May 16, 2024
3e8afa6
tidy up header files
multiphaseCFD May 16, 2024
81dd20c
update docstring
multiphaseCFD May 16, 2024
f0428a6
further tidy up code
multiphaseCFD May 16, 2024
8cdb65c
quick fix
multiphaseCFD May 16, 2024
cb2c8d3
fix typo
multiphaseCFD May 16, 2024
978a93c
Trigger multi-gpu CI
multiphaseCFD May 16, 2024
058b4ac
make format
multiphaseCFD May 16, 2024
673c504
Add todo for applyControlledTensorGate support
multiphaseCFD May 16, 2024
8e94dd7
add required header file
multiphaseCFD May 16, 2024
4e92ee3
set string->fucntor table as static
multiphaseCFD May 17, 2024
6183415
set gate name function map as singleton
multiphaseCFD May 17, 2024
394f1f3
Auto update version from '0.37.0-dev14' to '0.37.0-dev15'
ringo-but-quantum May 17, 2024
69618de
Bump Kokkos version to 4.3.01 (#725)
mlxd May 17, 2024
5647cab
Merge branch 'master' into add_LTensor_nonParam_gate
multiphaseCFD May 17, 2024
61fde58
Auto update version from '0.37.0-dev14' to '0.37.0-dev15'
ringo-but-quantum May 17, 2024
3986e44
Fix PennyLane LightningKokkos and LightningQubits tests for stable/st…
AmintorDusko May 21, 2024
f35a622
Auto update version from '0.37.0-dev15' to '0.37.0-dev16'
ringo-but-quantum May 22, 2024
0a7045d
update unit tests based on comments
multiphaseCFD May 22, 2024
5059bf8
Precision -> PrecisionT
multiphaseCFD May 22, 2024
f4d215a
fix version conflict
multiphaseCFD May 22, 2024
376ce9b
Auto update version from '0.37.0-dev15' to '0.37.0-dev16'
ringo-but-quantum May 22, 2024
53bcf9b
Merge branch 'master' into add_LTensor_nonParam_gate
multiphaseCFD May 22, 2024
5584dc4
resolve some comments
multiphaseCFD May 22, 2024
436e04e
Auto update version from '0.37.0-dev16' to '0.37.0-dev17'
ringo-but-quantum May 22, 2024
793b722
resolve more comments
multiphaseCFD May 23, 2024
0564d68
Merge branch 'master' into add_LTensor_nonParam_gate
multiphaseCFD May 23, 2024
422d6df
Auto update version from '0.37.0-dev16' to '0.37.0-dev17'
ringo-but-quantum May 23, 2024
f1fc0e5
update base on PR#739
multiphaseCFD May 23, 2024
24aae1e
Merge branch 'master' into add_LTensor_nonParam_gate
maliasadi May 23, 2024
99ec44e
Auto update version from '0.37.0-dev17' to '0.37.0-dev18'
ringo-but-quantum May 23, 2024
b5fa077
add docstring for DynamicGateDataAccess
multiphaseCFD May 23, 2024
608b294
Merge branch 'master' into add_LTensor_nonParam_gate
multiphaseCFD May 24, 2024
b8ff166
Auto update version from '0.37.0-dev18' to '0.37.0-dev19'
ringo-but-quantum May 24, 2024
20effcd
Merge branch 'master' into add_LTensor_nonParam_gate
multiphaseCFD May 27, 2024
f28aa0c
update docstring
multiphaseCFD May 27, 2024
8190130
Auto update version from '0.37.0-dev19' to '0.37.0-dev20'
ringo-but-quantum May 27, 2024
68d24b5
Trigger CI
multiphaseCFD May 28, 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
3 changes: 3 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

### New features since last release

* Add gate support to `cutensornet` backed `lightning.tensor` C++ layer.
[(#718)](https://github.com/PennyLaneAI/pennylane-lightning/pull/718)

* Add `cutensornet` backed `MPS` C++ layer to `lightning.tensor`.
[(#704)](https://github.com/PennyLaneAI/pennylane-lightning/pull/704)

Expand Down
2 changes: 1 addition & 1 deletion pennylane_lightning/core/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
Version number (major.minor.patch[-label])
"""

__version__ = "0.37.0-dev13"
__version__ = "0.37.0-dev14"
12 changes: 4 additions & 8 deletions pennylane_lightning/core/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,10 @@ set(COMPONENT_SUBDIRS algorithms
utils
)

if("${PL_BACKEND}" STREQUAL "lightning_tensor")
add_subdirectory(simulators)
add_subdirectory(utils)
else()
foreach(COMP ${COMPONENT_SUBDIRS})
add_subdirectory(${COMP})
endforeach()
endif()
foreach(COMP ${COMPONENT_SUBDIRS})
add_subdirectory(${COMP})
endforeach()


if (BUILD_TESTS)
# Include macros supporting tests.
Expand Down
4 changes: 2 additions & 2 deletions pennylane_lightning/core/src/algorithms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ target_link_libraries(lightning_algorithms INTERFACE lightning_compile_option
lightning_observables
)

if (BUILD_TESTS)
if (BUILD_TESTS AND NOT DEFINED PL_TENSOR)
multiphaseCFD marked this conversation as resolved.
Show resolved Hide resolved
enable_testing()
add_subdirectory("tests")
endif()
endif()
4 changes: 2 additions & 2 deletions pennylane_lightning/core/src/measurements/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ target_link_libraries(lightning_measurements INTERFACE lightning_compile_option
lightning_utils
)

if (BUILD_TESTS)
if (BUILD_TESTS AND NOT DEFINED PL_TENSOR)
multiphaseCFD marked this conversation as resolved.
Show resolved Hide resolved
enable_testing()
add_subdirectory("tests")
endif()
endif()
4 changes: 2 additions & 2 deletions pennylane_lightning/core/src/observables/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ target_link_libraries(lightning_observables INTERFACE lightning_compile_option
)
set_property(TARGET lightning_observables PROPERTY POSITION_INDEPENDENT_CODE ON)

if (BUILD_TESTS)
if (BUILD_TESTS AND NOT DEFINED PL_TENSOR)
enable_testing()
add_subdirectory("tests")
endif()
endif()
4 changes: 2 additions & 2 deletions pennylane_lightning/core/src/simulators/base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ target_link_libraries(lightning_base INTERFACE lightning_compile_options

set_property(TARGET lightning_base PROPERTY POSITION_INDEPENDENT_CODE ON)

if (BUILD_TESTS)
if (BUILD_TESTS AND NOT DEFINED PL_TENSOR)
enable_testing()
add_subdirectory("tests")
endif()
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if("${PL_TENSOR_BACKEND}" STREQUAL "cutensornet" AND NOT TNCUDA_UTILS_ADDED)
add_subdirectory(tncuda)
target_include_directories(${PL_BACKEND}_tensor INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/tncuda)
target_link_libraries(${PL_BACKEND}_tensor INTERFACE tensor_cuda)
set(CUDA_UTILS_ADDED TRUE)
set(TNCUDA_UTILS_ADDED TRUE)
multiphaseCFD marked this conversation as resolved.
Show resolved Hide resolved
multiphaseCFD marked this conversation as resolved.
Show resolved Hide resolved
endif()

target_include_directories(${PL_BACKEND}_tensor INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/base)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#pragma once

#include <functional>
multiphaseCFD marked this conversation as resolved.
Show resolved Hide resolved
#include <vector>

#include "Error.hpp"
Expand All @@ -31,7 +32,7 @@ namespace Pennylane::LightningTensor {
* @tparam Precision Floating point precision.
* @tparam Derived Derived class to instantiate using CRTP.
*/
template <class PrecisionT, class Derived> class TensorBase {
template <class Precision, class Derived> class TensorBase {
multiphaseCFD marked this conversation as resolved.
Show resolved Hide resolved
multiphaseCFD marked this conversation as resolved.
Show resolved Hide resolved
private:
const std::size_t rank_; // A rank N tensor has N modes
std::size_t length_; // Number of elements
Expand All @@ -44,7 +45,6 @@ template <class PrecisionT, class Derived> class TensorBase {
: rank_(rank), modes_(modes), extents_(extents) {
PL_ABORT_IF_NOT(rank_ == extents_.size(),
"Please check if rank or extents are set correctly.");
length_ = 1;
length_ = std::accumulate(extents.begin(), extents.end(),
std::size_t{1}, std::multiplies<>());
}
Expand Down Expand Up @@ -79,7 +79,7 @@ template <class PrecisionT, class Derived> class TensorBase {
/**
* @brief Return the number of elements of a tensor object.
*
* @return std::vector<std::size_t> Number of elements of a tensor object.
* @return std::size_t Number of elements of a tensor object.
*/
[[nodiscard]] std::size_t getLength() const { return length_; }
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@
#include "TensorBase.hpp"
#include "cuda_helpers.hpp"

/// @cond DEV
namespace {
namespace cuUtil = Pennylane::LightningGPU::Util;
using namespace Pennylane::LightningGPU;
} // namespace
/// @endcond

namespace Pennylane::LightningTensor::TNCuda {

Expand All @@ -40,17 +42,17 @@ namespace Pennylane::LightningTensor::TNCuda {
* @tparam Precision Floating point precision.
*/

template <class PrecisionT>
class TensorCuda final : public TensorBase<PrecisionT, TensorCuda<PrecisionT>> {
template <class Precision>
class TensorCuda final : public TensorBase<Precision, TensorCuda<Precision>> {
multiphaseCFD marked this conversation as resolved.
Show resolved Hide resolved
public:
using BaseType = TensorBase<PrecisionT, TensorCuda>;
using CFP_t = decltype(cuUtil::getCudaType(PrecisionT{}));
using BaseType = TensorBase<Precision, TensorCuda>;
using CFP_t = decltype(cuUtil::getCudaType(Precision{}));

explicit TensorCuda(const std::size_t rank,
const std::vector<std::size_t> &modes,
const std::vector<std::size_t> &extents,
const DevTag<int> &dev_tag, bool device_alloc = true)
: TensorBase<PrecisionT, TensorCuda<PrecisionT>>(rank, modes, extents),
: TensorBase<Precision, TensorCuda<Precision>>(rank, modes, extents),
data_buffer_{std::make_shared<DataBuffer<CFP_t>>(
BaseType::getLength(), dev_tag, device_alloc)} {}

Expand All @@ -61,14 +63,16 @@ class TensorCuda final : public TensorBase<PrecisionT, TensorCuda<PrecisionT>> {
/**
* @brief Explicitly copy data from GPU device to host memory.
*
* @param sv Complex data pointer to receive data from device.
* @param host_tensor Complex data pointer to receive data from device.
* @param length Number of elements to copy.
* @param async If true, the copy is asynchronous.
multiphaseCFD marked this conversation as resolved.
Show resolved Hide resolved
*/
inline void CopyGpuDataToHost(std::complex<PrecisionT> *host_sv,
inline void CopyGpuDataToHost(std::complex<Precision> *host_tensor,
std::size_t length,
bool async = false) const {
PL_ABORT_IF_NOT(BaseType::getLength() == length,
"Sizes do not match for Host and GPU data");
data_buffer_->CopyGpuDataToHost(host_sv, length, async);
data_buffer_->CopyGpuDataToHost(host_tensor, length, async);
}

DataBuffer<CFP_t> &getDataBuffer() { return *data_buffer_; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ option(PL_DISABLE_CUDA_SAFETY "Build without CUDA call safety checks" OFF)

target_link_libraries(${PL_TENSOR} PUBLIC lightning_compile_options
lightning_external_libs
${PL_BACKEND}_utils
${PL_BACKEND}_gates
${PL_BACKEND}_tensor
${PL_BACKEND}_tensornetBase
${PL_BACKEND}_utils
)

target_include_directories(${PL_TENSOR} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
Expand All @@ -57,6 +58,7 @@ endif()
# Include all nested sources directories
###############################################################################
set(COMPONENT_SUBDIRS base
gates
utils
)
foreach(COMP ${COMPONENT_SUBDIRS})
Expand Down
Loading
Loading