Skip to content

Commit

Permalink
Bump Kokkos version to 4.3.01 (#725)
Browse files Browse the repository at this point in the history
* Bump Kokkos version

* Auto update version from '0.37.0-dev6' to '0.37.0-dev8'

* Auto update version from '0.37.0-dev8' to '0.37.0-dev9'

* Replace all Kokkos versions with 4.3 to update cache

* Auto update version from '0.37.0-dev9' to '0.37.0-dev10'

* Update changelog

* Auto update version from '0.37.0-dev11' to '0.37.0-dev12'

* Auto update version from '0.37.0-dev12' to '0.37.0-dev13'

* Fix warning: moving a temporary object prevents copy elision

* Ensure kokkos_swap used throughout

* Auto update version from '0.37.0-dev13' to '0.37.0-dev14'

---------

Co-authored-by: ringo-but-quantum <github-ringo-but-quantum@xanadu.ai>
  • Loading branch information
2 people authored and multiphaseCFD committed May 17, 2024
1 parent 394f1f3 commit 69618de
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 31 deletions.
3 changes: 3 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

### Improvements

* Updated Kokkos version and support to 4.3.01.
[(#725)](https://github.com/PennyLaneAI/pennylane-lightning/pull/725)

* Lightning-Kokkos' functors are rewritten as functions wrapping around generic gate and generator functors templated over a coefficient interaction function. This reduces boilerplate while clarifying how the various kernels differ from one another.
[(#640)](https://github.com/PennyLaneAI/pennylane-lightning/pull/640)

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_and_cache_Kokkos_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

- name: Kokkos version
id: kokkos_version
run: echo "kokkos_version=[\"4.2.00\"]" >> $GITHUB_OUTPUT
run: echo "kokkos_version=[\"4.3.01\"]" >> $GITHUB_OUTPUT

outputs:
exec_model: ${{ steps.exec_model.outputs.exec_model }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/set_wheel_build_matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:

- name: Kokkos version
id: kokkos_version
run: echo "kokkos_version=[\"4.2.00\"]" >> $GITHUB_OUTPUT
run: echo "kokkos_version=[\"4.3.01\"]" >> $GITHUB_OUTPUT

outputs:
python_version: ${{ steps.pyver.outputs.python_version }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests_lkcuda_cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
matrix:
os: [ubuntu-22.04]
exec_model: ["CUDA"]
kokkos_version: ["4.2.00"]
kokkos_version: ["4.3.01"]

steps:
- name: Validate GPU version and installed compiler
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:
os: [ubuntu-22.04]
pl_backend: ["lightning_kokkos"]
exec_model: ["CUDA"]
kokkos_version: ["4.2.00"]
kokkos_version: ["4.3.01"]

name: C++ Tests (${{ matrix.pl_backend }}, kokkos-${{ matrix.kokkos_version }}, model-${{ matrix.exec_model }})
runs-on:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests_lkcuda_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
matrix:
os: [ubuntu-22.04]
exec_model: ["CUDA"]
kokkos_version: ["4.2.00"]
kokkos_version: ["4.3.01"]

steps:
- name: Validate GPU version and installed compiler
Expand Down Expand Up @@ -110,7 +110,7 @@ jobs:
os: [ubuntu-22.04]
pl_backend: ["lightning_kokkos", "all"]
exec_model: ["CUDA"]
kokkos_version: ["4.2.00"]
kokkos_version: ["4.3.01"]

name: Python Tests (${{ matrix.pl_backend }}, kokkos-${{ matrix.kokkos_version }}, model-${{ matrix.exec_model }})
runs-on:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests_windows_cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:

- name: Kokkos version
id: kokkos_version
run: echo "kokkos_version=[\"4.2.00\"]" >> $GITHUB_OUTPUT
run: echo "kokkos_version=[\"4.3.01\"]" >> $GITHUB_OUTPUT

outputs:
exec_model: ${{ steps.exec_model.outputs.exec_model }}
Expand Down
2 changes: 1 addition & 1 deletion cmake/support_kokkos.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Include this file only once
include_guard()

set(KOKKOS_VERSION 4.2.00)
set(KOKKOS_VERSION 4.3.01)

# Macro to aid in finding Kokkos with 3 potential install options:
# 1. Fully integrated Kokkos packages and CMake module files
Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ ARG AMD_ARCH=AMD_GFX90A
ARG CUDA_ARCH=AMPERE80
ARG CUDA_INSTALLER=https://developer.download.nvidia.com/compute/cuda/12.2.2/local_installers/cuda_12.2.2_535.104.05_linux.run
ARG GCC_VERSION=11
ARG KOKKOS_VERSION=4.2.00
ARG LIGHTNING_VERSION=v0.34.0
ARG KOKKOS_VERSION=4.3.01
ARG LIGHTNING_VERSION=v0.36.0
ARG ROCM_INSTALLER=https://repo.radeon.com/amdgpu-install/5.7/ubuntu/jammy/amdgpu-install_5.7.50700-1_all.deb
RUN apt-get update \
&& apt-get install --no-install-recommends -y \
Expand Down
2 changes: 1 addition & 1 deletion pennylane_lightning/core/src/gates/Gates.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ row-major format.
*/
template <template <typename...> class ComplexT, typename T>
static auto getCRot(T phi, T theta, T omega) -> std::vector<ComplexT<T>> {
const auto rot{std::move(getRot<ComplexT, T>(phi, theta, omega))};
const auto rot{getRot<ComplexT, T>(phi, theta, omega)};
return {ONE<ComplexT, T>(),
ZERO<ComplexT, T>(),
ZERO<ComplexT, T>(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/// @cond DEV
namespace {
using namespace Pennylane::Util;
using Kokkos::Experimental::swap;
using Kokkos::kokkos_swap;
using Pennylane::Gates::GateOperation;
} // namespace
/// @endcond
Expand Down Expand Up @@ -70,9 +70,8 @@ void applyPauliX(Kokkos::View<Kokkos::complex<PrecisionT> *> arr_,
applyNC1Functor(
ExecutionSpace{}, arr_, num_qubits, wires,
KOKKOS_LAMBDA(Kokkos::View<Kokkos::complex<PrecisionT> *> arr,
const std::size_t i0, const std::size_t i1) {
Kokkos::Experimental::swap(arr(i0), arr(i1));
});
const std::size_t i0,
const std::size_t i1) { kokkos_swap(arr(i0), arr(i1)); });
}

template <class ExecutionSpace, class PrecisionT>
Expand Down Expand Up @@ -319,7 +318,7 @@ void applyCNOT(Kokkos::View<Kokkos::complex<PrecisionT> *> arr_,
[[maybe_unused]] const std::size_t i00,
[[maybe_unused]] const std::size_t i01,
const std::size_t i10, const std::size_t i11) {
Kokkos::Experimental::swap(arr(i10), arr(i11));
kokkos_swap(arr(i10), arr(i11));
});
}

Expand Down Expand Up @@ -369,7 +368,7 @@ void applySWAP(Kokkos::View<Kokkos::complex<PrecisionT> *> arr_,
[[maybe_unused]] const std::size_t i00,
const std::size_t i01, const std::size_t i10,
[[maybe_unused]] const std::size_t i11) {
swap(arr(i10), arr(i01));
kokkos_swap(arr(i10), arr(i01));
});
}

Expand Down Expand Up @@ -766,7 +765,7 @@ void applyCSWAP(Kokkos::View<Kokkos::complex<PrecisionT> *> arr_,
[[maybe_unused]] const std::size_t i100,
const std::size_t i101, const std::size_t i110,
[[maybe_unused]] const std::size_t i111) {
swap(arr(i101), arr(i110));
kokkos_swap(arr(i101), arr(i110));
});
}

Expand All @@ -785,8 +784,9 @@ void applyToffoli(Kokkos::View<Kokkos::complex<PrecisionT> *> arr_,
[[maybe_unused]] const std::size_t i011,
[[maybe_unused]] const std::size_t i100,
[[maybe_unused]] const std::size_t i101,
const std::size_t i110,
const std::size_t i111) { swap(arr(i111), arr(i110)); });
const std::size_t i110, const std::size_t i111) {
kokkos_swap(arr(i111), arr(i110));
});
}

template <class PrecisionT, class FuncT> class applyNC4Functor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/// @cond DEV
namespace {
using namespace Pennylane::Util;
using Kokkos::Experimental::swap;
using Kokkos::kokkos_swap;
using Pennylane::Gates::GeneratorOperation;
} // namespace
/// @endcond
Expand Down Expand Up @@ -76,7 +76,7 @@ void applyGenCRX(Kokkos::View<Kokkos::complex<PrecisionT> *> arr_,
const std::size_t i10, const std::size_t i11) {
arr(i00) = ZERO<Kokkos::complex, PrecisionT>();
arr(i01) = ZERO<Kokkos::complex, PrecisionT>();
swap(arr(i10), arr(i11));
kokkos_swap(arr(i10), arr(i11));
});
}

Expand Down Expand Up @@ -129,8 +129,8 @@ void applyGenIsingXX(
KOKKOS_LAMBDA(Kokkos::View<Kokkos::complex<PrecisionT> *> arr,
const std::size_t i00, const std::size_t i01,
const std::size_t i10, const std::size_t i11) {
swap(arr(i00), arr(i11));
swap(arr(i10), arr(i01));
kokkos_swap(arr(i00), arr(i11));
kokkos_swap(arr(i10), arr(i01));
});
}

Expand All @@ -145,7 +145,7 @@ void applyGenIsingXY(
KOKKOS_LAMBDA(Kokkos::View<Kokkos::complex<PrecisionT> *> arr,
const std::size_t i00, const std::size_t i01,
const std::size_t i10, const std::size_t i11) {
swap(arr(i10), arr(i01));
kokkos_swap(arr(i10), arr(i01));
arr(i00) = ZERO<Kokkos::complex, PrecisionT>();
arr(i11) = ZERO<Kokkos::complex, PrecisionT>();
});
Expand All @@ -165,7 +165,7 @@ void applyGenIsingYY(
const auto v00 = arr(i00);
arr(i00) = -arr(i11);
arr(i11) = -v00;
swap(arr(i10), arr(i01));
kokkos_swap(arr(i10), arr(i01));
});
}

Expand Down Expand Up @@ -201,7 +201,7 @@ void applyGenSingleExcitation(
arr(i01) *= IMAG<Kokkos::complex, PrecisionT>();
arr(i10) *= -IMAG<Kokkos::complex, PrecisionT>();
arr(i11) = ZERO<Kokkos::complex, PrecisionT>();
swap(arr(i10), arr(i01));
kokkos_swap(arr(i10), arr(i01));
});
}

Expand All @@ -219,7 +219,7 @@ void applyGenSingleExcitationMinus(
[[maybe_unused]] const std::size_t i11) {
arr(i01) *= IMAG<Kokkos::complex, PrecisionT>();
arr(i10) *= -IMAG<Kokkos::complex, PrecisionT>();
swap(arr(i10), arr(i01));
kokkos_swap(arr(i10), arr(i01));
});
}

Expand All @@ -239,7 +239,7 @@ void applyGenSingleExcitationPlus(
arr(i01) *= IMAG<Kokkos::complex, PrecisionT>();
arr(i10) *= -IMAG<Kokkos::complex, PrecisionT>();
arr(i11) *= -1;
swap(arr(i10), arr(i01));
kokkos_swap(arr(i10), arr(i01));
});
}

Expand Down Expand Up @@ -307,7 +307,7 @@ void applyGenDoubleExcitationMinus(
[[maybe_unused]] const std::size_t i1111) {
arr(i0011) *= IMAG<Kokkos::complex, PrecisionT>();
arr(i1100) *= -IMAG<Kokkos::complex, PrecisionT>();
swap(arr(i1100), arr(i0011));
kokkos_swap(arr(i1100), arr(i0011));
});
}

Expand Down Expand Up @@ -337,7 +337,7 @@ void applyGenDoubleExcitationPlus(
[[maybe_unused]] const std::size_t i1111) {
arr(i0011) *= -IMAG<Kokkos::complex, PrecisionT>();
arr(i1100) *= IMAG<Kokkos::complex, PrecisionT>();
swap(arr(i1100), arr(i0011));
kokkos_swap(arr(i1100), arr(i0011));
});
}

Expand Down

0 comments on commit 69618de

Please sign in to comment.