diff --git a/.github/workflows/compat-docker-latest.yml b/.github/workflows/compat-docker-latest.yml index 447a2170a..f8daf1aa6 100644 --- a/.github/workflows/compat-docker-latest.yml +++ b/.github/workflows/compat-docker-latest.yml @@ -14,7 +14,7 @@ jobs: name: Docker latest - Linux::x86_64 uses: ./.github/workflows/docker_linux_x86_64.yml with: - lightning-version: master + lightning-version: fix_lk_rocm_unused pennylane-version: master push-to-dockerhub: false secrets: inherit # pass all secrets diff --git a/pennylane_lightning/core/src/simulators/lightning_kokkos/gates/BasicGateFunctors.hpp b/pennylane_lightning/core/src/simulators/lightning_kokkos/gates/BasicGateFunctors.hpp index aba3e1f94..5f44391ee 100644 --- a/pennylane_lightning/core/src/simulators/lightning_kokkos/gates/BasicGateFunctors.hpp +++ b/pennylane_lightning/core/src/simulators/lightning_kokkos/gates/BasicGateFunctors.hpp @@ -32,7 +32,6 @@ using Pennylane::LightningKokkos::Util::generateBitPatterns; using Pennylane::LightningKokkos::Util::parity_2_offset; using Pennylane::LightningKokkos::Util::reverseWires; using Pennylane::LightningKokkos::Util::vector2view; -using Pennylane::Util::exp2; } // namespace /// @endcond @@ -59,9 +58,9 @@ template class applyNCNFunctor { const std::vector &controlled_values, const std::vector &wires, FuncT core_function_) : arr(arr_), core_function(core_function_) { - const std::size_t two2N = - exp2(num_qubits - wires.size() - controlled_wires.size()); - dim = exp2(wires.size()); + const std::size_t two2N = Pennylane::Util::exp2( + num_qubits - wires.size() - controlled_wires.size()); + dim = Pennylane::Util::exp2(wires.size()); const auto &[parity_, rev_wires_] = reverseWires(num_qubits, wires, controlled_wires); parity = parity_; @@ -116,7 +115,8 @@ class applyNC1Functor { indices = vector2view(indices_); Kokkos::parallel_for( Kokkos::RangePolicy( - 0, exp2(num_qubits - controlled_wires.size() - wires.size())), + 0, Pennylane::Util::exp2(num_qubits - controlled_wires.size() - + wires.size())), *this); } KOKKOS_FUNCTION void operator()(std::size_t k) const { @@ -148,9 +148,9 @@ class applyNC1Functor { rev_wire_shift((static_cast(1U) << rev_wire)), wire_parity(fillTrailingOnes(rev_wire)), wire_parity_inv(fillLeadingOnes(rev_wire + 1)) { - Kokkos::parallel_for( - Kokkos::RangePolicy(0, exp2(num_qubits - 1)), - *this); + Kokkos::parallel_for(Kokkos::RangePolicy( + 0, Pennylane::Util::exp2(num_qubits - 1)), + *this); } KOKKOS_FUNCTION void operator()(std::size_t k) const { std::size_t i0 = ((k << 1U) & wire_parity_inv) | (wire_parity & k); @@ -645,7 +645,8 @@ class applyNC2Functor { indices = vector2view(indices_); Kokkos::parallel_for( Kokkos::RangePolicy( - 0, exp2(num_qubits - controlled_wires.size() - wires.size())), + 0, Pennylane::Util::exp2(num_qubits - controlled_wires.size() - + wires.size())), *this); } KOKKOS_FUNCTION void operator()(std::size_t k) const { @@ -693,9 +694,9 @@ class applyNC2Functor { parity_high(fillLeadingOnes(rev_wire_max + 1)), parity_middle(fillLeadingOnes(rev_wire_min + 1) & fillTrailingOnes(rev_wire_max)) { - Kokkos::parallel_for( - Kokkos::RangePolicy(0, exp2(num_qubits - 2)), - *this); + Kokkos::parallel_for(Kokkos::RangePolicy( + 0, Pennylane::Util::exp2(num_qubits - 2)), + *this); } KOKKOS_FUNCTION void operator()(std::size_t k) const { std::size_t i00 = ((k << 2U) & parity_high) | @@ -1268,9 +1269,9 @@ template class applyNC3Functor { fillLeadingOnes(rev_wire_min + 1) & fillTrailingOnes(rev_wire_mid); parity_hmiddle = fillLeadingOnes(rev_wire_mid + 1) & fillTrailingOnes(rev_wire_max); - Kokkos::parallel_for( - Kokkos::RangePolicy(0, exp2(num_qubits - 3)), - *this); + Kokkos::parallel_for(Kokkos::RangePolicy( + 0, Pennylane::Util::exp2(num_qubits - 3)), + *this); } KOKKOS_FUNCTION void operator()(std::size_t k) const { std::size_t i000 = ((k << 3U) & parity_high) | @@ -1365,7 +1366,8 @@ class applyNC4Functor { indices = vector2view(indices_); Kokkos::parallel_for( Kokkos::RangePolicy( - 0, exp2(num_qubits - controlled_wires.size() - wires.size())), + 0, Pennylane::Util::exp2(num_qubits - controlled_wires.size() - + wires.size())), *this); } KOKKOS_FUNCTION void operator()(std::size_t k) const { @@ -1474,9 +1476,9 @@ class applyNC4Functor { fillTrailingOnes(rev_wire_max); parity_middle = fillLeadingOnes(rev_wire_min_mid + 1) & fillTrailingOnes(rev_wire_max_mid); - Kokkos::parallel_for( - Kokkos::RangePolicy(0, exp2(num_qubits - 4)), - *this); + Kokkos::parallel_for(Kokkos::RangePolicy( + 0, Pennylane::Util::exp2(num_qubits - 4)), + *this); } KOKKOS_FUNCTION void operator()(std::size_t k) const { std::size_t i0000 = ((k << 4U) & parity_high) | @@ -1700,7 +1702,8 @@ void applyMultiRZ(Kokkos::View *> arr_, (static_cast(1U) << (num_qubits - wire - 1)); } Kokkos::parallel_for( - Kokkos::RangePolicy(0, exp2(num_qubits)), + Kokkos::RangePolicy(0, + Pennylane::Util::exp2(num_qubits)), KOKKOS_LAMBDA(std::size_t k) { arr_(k) *= (Kokkos::Impl::bit_count(k & wires_parity) % 2 == 0) ? shift_0 @@ -1778,7 +1781,8 @@ void applyPauliRot(Kokkos::View *> arr_, get_mask([&word](const int a) { return word[a] == 'Z'; }); const auto count_mask_y = std::popcount(mask_y); Kokkos::parallel_for( - Kokkos::RangePolicy(0, exp2(num_qubits)), + Kokkos::RangePolicy(0, + Pennylane::Util::exp2(num_qubits)), KOKKOS_LAMBDA(std::size_t i0) { std::size_t i1 = i0 ^ mask_xy; if (i0 <= i1) { diff --git a/pennylane_lightning/core/src/simulators/lightning_kokkos/gates/BasicGeneratorFunctors.hpp b/pennylane_lightning/core/src/simulators/lightning_kokkos/gates/BasicGeneratorFunctors.hpp index 8bdc54d76..6b25fdb52 100644 --- a/pennylane_lightning/core/src/simulators/lightning_kokkos/gates/BasicGeneratorFunctors.hpp +++ b/pennylane_lightning/core/src/simulators/lightning_kokkos/gates/BasicGeneratorFunctors.hpp @@ -25,7 +25,6 @@ namespace { using namespace Pennylane::Util; using Kokkos::kokkos_swap; using Pennylane::Gates::GeneratorOperation; -using Pennylane::Util::exp2; } // namespace /// @endcond @@ -347,10 +346,11 @@ void applyGenMultiRZ(Kokkos::View *> arr_, [[maybe_unused]] bool inverse = false) { std::size_t wires_parity = static_cast(0U); for (std::size_t wire : wires) { - wires_parity |= exp2(num_qubits - wire - 1); + wires_parity |= Pennylane::Util::exp2(num_qubits - wire - 1); } Kokkos::parallel_for( - Kokkos::RangePolicy(0, exp2(num_qubits)), + Kokkos::RangePolicy(0, + Pennylane::Util::exp2(num_qubits)), KOKKOS_LAMBDA(std::size_t k) { arr_(k) *= static_cast( 1 - 2 * int(Kokkos::Impl::bit_count(k & wires_parity) % 2)); @@ -412,7 +412,8 @@ template class applyNCGenerator1Functor { indices = vector2view(indices_); Kokkos::parallel_for( Kokkos::RangePolicy( - 0, exp2(num_qubits - controlled_wires.size() - wires.size())), + 0, Pennylane::Util::exp2(num_qubits - controlled_wires.size() - + wires.size())), *this); } KOKKOS_FUNCTION void operator()(std::size_t k) const { @@ -588,7 +589,8 @@ template class applyNCGenerator2Functor { indices = vector2view(indices_); Kokkos::parallel_for( Kokkos::RangePolicy( - 0, exp2(num_qubits - controlled_wires.size() - wires.size())), + 0, Pennylane::Util::exp2(num_qubits - controlled_wires.size() - + wires.size())), *this); } KOKKOS_FUNCTION void operator()(std::size_t k) const { @@ -802,7 +804,8 @@ template class applyNCGenerator4Functor { indices = vector2view(indices_); Kokkos::parallel_for( Kokkos::RangePolicy( - 0, exp2(num_qubits - controlled_wires.size() - wires.size())), + 0, Pennylane::Util::exp2(num_qubits - controlled_wires.size() - + wires.size())), *this); } KOKKOS_FUNCTION void operator()(std::size_t k) const { @@ -899,16 +902,17 @@ void applyNCGenMultiRZ(Kokkos::View *> arr_, std::size_t ctrls_parity = std::accumulate( controlled_wires.begin(), controlled_wires.end(), std::size_t{0}, [num_qubits](std::size_t acc, std::size_t wire) { - return acc | exp2(num_qubits - wire - 1); + return acc | Pennylane::Util::exp2(num_qubits - wire - 1); + }); + std::size_t wires_parity = std::accumulate( + wires.begin(), wires.end(), std::size_t{0}, + [num_qubits](std::size_t acc, std::size_t wire) { + return acc | Pennylane::Util::exp2(num_qubits - wire - 1); }); - std::size_t wires_parity = - std::accumulate(wires.begin(), wires.end(), std::size_t{0}, - [num_qubits](std::size_t acc, std::size_t wire) { - return acc | exp2(num_qubits - wire - 1); - }); Kokkos::parallel_for( - Kokkos::RangePolicy(0, exp2(num_qubits)), + Kokkos::RangePolicy(0, + Pennylane::Util::exp2(num_qubits)), KOKKOS_LAMBDA(std::size_t k) { if (ctrls_mask == (ctrls_parity & k)) { arr_(k) *= static_cast( diff --git a/pennylane_lightning/core/src/simulators/lightning_kokkos/gates/MatrixGateFunctors.hpp b/pennylane_lightning/core/src/simulators/lightning_kokkos/gates/MatrixGateFunctors.hpp index 23f6fcec4..42c019562 100644 --- a/pennylane_lightning/core/src/simulators/lightning_kokkos/gates/MatrixGateFunctors.hpp +++ b/pennylane_lightning/core/src/simulators/lightning_kokkos/gates/MatrixGateFunctors.hpp @@ -30,7 +30,6 @@ using Pennylane::LightningKokkos::Util::parity_2_offset; using Pennylane::LightningKokkos::Util::reverseWires; using Pennylane::LightningKokkos::Util::vector2view; using Pennylane::LightningKokkos::Util::wires2Parity; -using Pennylane::Util::exp2; } // namespace /// @endcond @@ -61,7 +60,7 @@ template struct multiQubitOpFunctor { const KokkosComplexVector &matrix_, const std::vector &wires_) { wires = vector2view(wires_); - dim = exp2(wires_.size()); + dim = Pennylane::Util::exp2(wires_.size()); num_qubits = num_qubits_; arr = arr_; matrix = matrix_; @@ -138,7 +137,7 @@ template struct NCMultiQubitOpFunctor { const std::vector &controlled_wires_, const std::vector &controlled_values_, const std::vector &wires_) { - dim = exp2(wires_.size()); + dim = Pennylane::Util::exp2(wires_.size()); arr = arr_; matrix = matrix_; num_qubits = num_qubits_; @@ -203,7 +202,7 @@ template struct apply1QubitOpFunctor { num_qubits = num_qubits_; rev_wire = num_qubits - wires_[0] - 1; - rev_wire_shift = exp2(rev_wire); + rev_wire_shift = Pennylane::Util::exp2(rev_wire); wire_parity = fillTrailingOnes(rev_wire); wire_parity_inv = fillLeadingOnes(rev_wire + 1); }