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

(LK-C-Base) Add native controlled operation support for Lightning Kokkos #950

Merged
merged 65 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
fd9df9f
initial commit
josephleekl Oct 18, 2024
942c841
Auto update version from '0.39.0-dev46' to '0.39.0-dev47'
ringo-but-quantum Oct 18, 2024
39785ee
Merge branch 'master' into lk-control-base
josephleekl Oct 18, 2024
035bea0
Auto update version from '0.39.0-dev47' to '0.39.0-dev48'
ringo-but-quantum Oct 18, 2024
ba5439e
Merge branch 'master' into lk-control-base
josephleekl Oct 24, 2024
78d4f7b
Auto update version from '0.39.0-dev48' to '0.39.0-dev49'
ringo-but-quantum Oct 24, 2024
4526b00
Merge branch 'master' into lk-control-base
josephleekl Nov 8, 2024
a964795
merge with master
josephleekl Nov 8, 2024
0f5beee
Auto update version from '0.40.0-dev4' to '0.40.0-dev5'
ringo-but-quantum Nov 8, 2024
6536bb6
(LK-C-1) Add controlled 1-qubit named-gate (e.g. NCPauliX) support to…
josephleekl Nov 8, 2024
e89065f
Auto update version from '0.40.0-dev5' to '0.40.0-dev6'
ringo-but-quantum Nov 8, 2024
1979bd7
(LK-C-2) Add controlled named 2/4-qubit gate (e.g. NCIsingXX) support…
josephleekl Nov 12, 2024
0acc148
Auto update version from '0.40.0-dev4' to '0.40.0-dev7'
ringo-but-quantum Nov 12, 2024
d7aecd7
(LK-C-3) Add controlled MultiRZ support to Lightning Kokkos (#954)
josephleekl Nov 13, 2024
7ea9296
Auto update version from '0.40.0-dev7' to '0.40.0-dev9'
ringo-but-quantum Nov 13, 2024
56b1d04
Merge branch 'master' into lk-control-base
josephleekl Nov 15, 2024
eb2ac82
format
josephleekl Nov 15, 2024
8e578b1
fix code factor
josephleekl Nov 15, 2024
7b5713e
Auto update version from '0.40.0-dev9' to '0.40.0-dev10'
ringo-but-quantum Nov 15, 2024
b00dbf9
Merge branch 'master' into lk-control-base
josephleekl Nov 19, 2024
5ab8064
Auto update version from '0.40.0-dev11' to '0.40.0-dev12'
ringo-but-quantum Nov 19, 2024
bde6107
(LK-C-4) Add controlled QubitUnitary support to Lightning Kokkos (#…
josephleekl Nov 19, 2024
8834735
(LK-C-5) Add controlled generator (1-qubit) support for Lightning Kok…
josephleekl Nov 22, 2024
2fd51fe
Auto update version from '0.40.0-dev12' to '0.40.0-dev14'
ringo-but-quantum Nov 22, 2024
873c6fb
(LK-C-6) Add controlled generator (multi-qubit) support for Lightning…
josephleekl Nov 22, 2024
f5f83bc
Auto update version from '0.40.0-dev14' to '0.40.0-dev15'
ringo-but-quantum Nov 22, 2024
04a7c84
(LK-C-7) Add controlled adjoint support for Lightning Kokkos (#965)
josephleekl Nov 22, 2024
ee93769
Merge branch 'master' into lk-control-base
josephleekl Nov 25, 2024
f084bf3
update changelog
josephleekl Nov 25, 2024
391ad57
fix codefactor complaint
josephleekl Nov 25, 2024
da99d67
Merge branch 'master' into lk-control-base
josephleekl Nov 25, 2024
772e7e3
Auto update version from '0.40.0-dev15' to '0.40.0-dev16'
ringo-but-quantum Nov 25, 2024
7b029b5
add controlled op in catalyst lightningkokkossimulator
josephleekl Nov 25, 2024
9c415e2
update simulator + test
josephleekl Nov 25, 2024
242d39a
Merge branch 'master' into lk-control-base
josephleekl Nov 25, 2024
7ca95b6
Auto update version from '0.40.0-dev16' to '0.40.0-dev17'
ringo-but-quantum Nov 25, 2024
094aebc
Merge branch 'master' into lk-control-base
josephleekl Nov 26, 2024
568c3ca
fix lkokkos merge tests
josephleekl Nov 26, 2024
c392a72
util add blankline
josephleekl Nov 26, 2024
27ee7e5
use m_pi_2 constant for test
josephleekl Nov 26, 2024
b48662a
update controlled toffoli test name
josephleekl Nov 26, 2024
71e3d24
use dynamic section for tests
josephleekl Nov 26, 2024
4d8126d
Auto update version from '0.40.0-dev17' to '0.40.0-dev18'
ringo-but-quantum Nov 26, 2024
7885941
remove using std::size_t
josephleekl Nov 26, 2024
664a706
implement comments
josephleekl Nov 28, 2024
6b54cd2
Auto update version from '0.40.0-dev18' to '0.40.0-dev22'
ringo-but-quantum Nov 28, 2024
d8b62ab
implement comments
josephleekl Nov 28, 2024
8db2fd8
remove old c(globalphase)
josephleekl Nov 28, 2024
b678095
Auto update version from '0.40.0-dev22' to '0.40.0-dev24'
ringo-but-quantum Nov 28, 2024
19ffddc
format
josephleekl Nov 28, 2024
647ef52
clean up doc comments
josephleekl Nov 29, 2024
a4df6c0
update ctrl/adj nested comment
josephleekl Nov 29, 2024
95cd1db
update non-const pointer applycontrolledmatrix and add test
josephleekl Nov 29, 2024
f0ac952
format
josephleekl Nov 29, 2024
f42ea8b
update scratch level exploration comment
josephleekl Nov 29, 2024
f4f2527
precompute mask in controlbitpatterns calc
josephleekl Nov 29, 2024
fd27096
Merge branch 'master' into lk-control-base
josephleekl Nov 29, 2024
e33fc53
implement shuli comments
josephleekl Dec 2, 2024
083dc97
implement shuli comments
josephleekl Dec 2, 2024
3a03af2
Update pennylane_lightning/core/src/simulators/lightning_kokkos/utils…
josephleekl Dec 3, 2024
7d04fd3
Auto update version from '0.40.0-dev24' to '0.40.0-dev25'
ringo-but-quantum Dec 3, 2024
2bd4058
Merge branch 'master' into lk-control-base
josephleekl Dec 3, 2024
5cdc1fa
update controlBitPatterns case
josephleekl Dec 3, 2024
0d2e228
Auto update version from '0.40.0-dev25' to '0.40.0-dev26'
ringo-but-quantum Dec 3, 2024
9582e93
Merge branch 'master' into lk-control-base
josephleekl Dec 3, 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 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 generators and adjoint support to `lightning.gpu`'s single-GPU backend.
[(#970)](https://github.com/PennyLaneAI/pennylane-lightning/pull/970)

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.40.0-dev23"
__version__ = "0.40.0-dev24"
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ using namespace Pennylane::Util;

#ifdef _ENABLE_PLQUBIT
constexpr bool BACKEND_FOUND = true;
constexpr bool SUPPORTS_CTRL = true;

#include "AdjointJacobianLQubit.hpp"
#include "ObservablesLQubit.hpp"
Expand All @@ -41,7 +40,6 @@ using namespace Pennylane::LightningQubit::Observables;

#elif _ENABLE_PLKOKKOS == 1
constexpr bool BACKEND_FOUND = true;
constexpr bool SUPPORTS_CTRL = false;

#include "AdjointJacobianKokkos.hpp"
#include "ObservablesKokkos.hpp"
Expand All @@ -57,7 +55,6 @@ using namespace Pennylane::LightningKokkos::Observables;

#elif _ENABLE_PLGPU == 1
constexpr bool BACKEND_FOUND = true;
constexpr bool SUPPORTS_CTRL = true;
#include "AdjointJacobianGPU.hpp"
#include "ObservablesGPU.hpp"
#include "TestHelpersStateVectors.hpp"
Expand All @@ -72,7 +69,6 @@ using namespace Pennylane::LightningGPU::Observables;

#else
constexpr bool BACKEND_FOUND = false;
constexpr bool SUPPORTS_CTRL = false;
using TestStateVectorBackends = Pennylane::Util::TypeList<void>;

template <class StateVector> struct StateVectorToName {};
Expand Down Expand Up @@ -140,41 +136,38 @@ template <typename TypeList> void testAdjointJacobian() {

DYNAMIC_SECTION("Op=PhaseShift, Obs=Y - "
<< StateVectorToName<StateVectorT>::name) {
if (SUPPORTS_CTRL) {
const std::vector<std::size_t> tp{0};
const std::size_t num_qubits = GENERATE(2, 3, 4);

const std::size_t num_params = 3;
const std::size_t num_obs = 1;
const auto obs = std::make_shared<NamedObs<StateVectorT>>(
"PauliY", std::vector<std::size_t>{num_qubits - 1});
std::vector<PrecisionT> jacobian(num_obs * tp.size(), 0);
const std::vector<std::size_t> tp{0};
const std::size_t num_qubits = GENERATE(2, 3, 4);

const std::size_t num_params = 3;
const std::size_t num_obs = 1;
const auto obs = std::make_shared<NamedObs<StateVectorT>>(
"PauliY", std::vector<std::size_t>{num_qubits - 1});
std::vector<PrecisionT> jacobian(num_obs * tp.size(), 0);

for (const auto &p : param) {
std::vector<std::vector<std::size_t>> controls{
std::vector<std::size_t>(num_qubits - 1)};
std::iota(controls[0].begin(), controls[0].end(), 0);
std::vector<std::vector<bool>> control_values{
std::vector<bool>(num_qubits - 1, true)};
auto ops = OpsData<StateVectorT>(
{"PhaseShift"}, {{p}}, {{num_qubits - 1}}, {false}, {{}},
controls, control_values);

for (const auto &p : param) {
std::vector<std::vector<std::size_t>> controls{
std::vector<std::size_t>(num_qubits - 1)};
std::iota(controls[0].begin(), controls[0].end(), 0);
std::vector<std::vector<bool>> control_values{
std::vector<bool>(num_qubits - 1, true)};
auto ops = OpsData<StateVectorT>(
{"PhaseShift"}, {{p}}, {{num_qubits - 1}}, {false},
{{}}, controls, control_values);

std::vector<ComplexT> cdata(1U << num_qubits);
cdata[cdata.size() - 2] =
Pennylane::Util::INVSQRT2<PrecisionT>();
cdata[cdata.size() - 1] =
Pennylane::Util::INVSQRT2<PrecisionT>();

StateVectorT psi(cdata.data(), cdata.size());
JacobianData<StateVectorT> tape{
num_params, psi.getLength(), psi.getData(), {obs}, ops,
tp};
adj.adjointJacobian(std::span{jacobian}, tape, psi, true);

CAPTURE(jacobian);
CHECK(cos(p) == Approx(jacobian[0]));
}
std::vector<ComplexT> cdata(1U << num_qubits);
cdata[cdata.size() - 2] =
Pennylane::Util::INVSQRT2<PrecisionT>();
cdata[cdata.size() - 1] =
Pennylane::Util::INVSQRT2<PrecisionT>();

StateVectorT psi(cdata.data(), cdata.size());
JacobianData<StateVectorT> tape{
num_params, psi.getLength(), psi.getData(), {obs}, ops, tp};
adj.adjointJacobian(std::span{jacobian}, tape, psi, true);

CAPTURE(jacobian);
CHECK(cos(p) == Approx(jacobian[0]));
}
}

Expand Down Expand Up @@ -671,4 +664,4 @@ TEST_CASE("Algorithms::adjointJacobian", "[Algorithms]") {
if constexpr (BACKEND_FOUND) {
testAdjointJacobian<TestStateVectorBackends>();
}
}
}
Loading
Loading