From 7571eb430476b85d00900dd357eb88e51d155da5 Mon Sep 17 00:00:00 2001 From: Ali Asadi <10773383+maliasadi@users.noreply.github.com> Date: Wed, 25 Sep 2024 13:34:18 -0400 Subject: [PATCH] Deprecate PI gates implementation --- .github/CHANGELOG.md | 3 +++ doc/benchmark.rst | 3 --- doc/lightning_qubit/development/add_gate_kernel.rst | 4 +--- .../development/avx_kernels/build_system.rst | 5 ++--- .../core/src/simulators/lightning_qubit/gates/KernelMap.hpp | 6 ++---- .../lightning_qubit/gates/tests/Test_Internal.cpp | 1 - pennylane_lightning/core/src/utils/TestKernels.hpp | 2 -- 7 files changed, 8 insertions(+), 16 deletions(-) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index e8e5540baa..f64cf14142 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -23,6 +23,9 @@ ### Breaking changes +* Deprecate PI gates implementation. + [(#923)](https://github.com/PennyLaneAI/pennylane-lightning/pull/923) + * Update MacOS wheel builds to require Monterey (12.0) or greater for x86_64 and ARM. [(#901)](https://github.com/PennyLaneAI/pennylane-lightning/pull/901) diff --git a/doc/benchmark.rst b/doc/benchmark.rst index 132862c38c..92384c67dd 100644 --- a/doc/benchmark.rst +++ b/doc/benchmark.rst @@ -30,9 +30,6 @@ One can also choose a specific datatype by providing an option: $ ./benchmarks/plot_gate_benchmark.py --precision float ./bench_result.json # Results for std::complex $ ./benchmarks/plot_gate_benchmark.py --precision double ./bench_result.json # Results for std::complex - -Currently, we have two different kernels in ``Lightning Qubit`` named ``PI`` and ``LM``. For difference between two kernels, see the documents :cpp:class:`Pennylane::Gates::GateImplementationsPI` and :cpp:class:`Pennylane::Gates::GateImplementationsLM`. - Here are some example plots: .. image:: ./_static/benchmark/PauliX.png diff --git a/doc/lightning_qubit/development/add_gate_kernel.rst b/doc/lightning_qubit/development/add_gate_kernel.rst index fb600454d1..09f9177bf6 100644 --- a/doc/lightning_qubit/development/add_gate_kernel.rst +++ b/doc/lightning_qubit/development/add_gate_kernel.rst @@ -40,7 +40,7 @@ This can be done by modifying two files: // file: gates/KernelType.hpp namespace Pennylane { - enum class KernelType { PI, LM, MyKernel /* This is added */, None }; + enum class KernelType { LM, MyKernel /* This is added */, None }; /* Rest of the file */ @@ -53,7 +53,6 @@ and // file: gates/AvailableKernels.hpp namespace Pennylane { using AvailableKernels = Util::TypeList; } // namespace Pennylane @@ -111,7 +110,6 @@ To test your own kernel implementations, you can go to ``tests/TestKernels.hpp`` .. code-block:: cpp using TestKernels = Pennylane::Util::TypeList; It will automatically test your gate implementation. diff --git a/doc/lightning_qubit/development/avx_kernels/build_system.rst b/doc/lightning_qubit/development/avx_kernels/build_system.rst index 575d9c9795..7a4941624d 100644 --- a/doc/lightning_qubit/development/avx_kernels/build_system.rst +++ b/doc/lightning_qubit/development/avx_kernels/build_system.rst @@ -8,11 +8,10 @@ when the library is loaded, and it is used at runtime when it is the most suitab To support AVX2 and AVX512 kernels, we always compile those kernels if the target system is UNIX on x86-64. Specifically, we made separate C++ files for AVX2 and AVX512 kernels and build them as a static library with the corresponding compile options. This is handled by CMake. One can check ``gates/CMakeLists.txt`` file for details. -One caveat is that we want to make sure that default kernels (``KernelType::PI`` and ``KernelType::LM``) are only instantiated once with specific compiler flags during the compile process. +One caveat is that we want to make sure that default ``KernelType::LM`` kernels are only instantiated once with specific compiler flags during the compile process. This is important as the linker sometimes cannot choose the right instantiation when there are multiple instantiations of the same template class. This problem does not arise when all instantiations are compiled with the same options, but with the AVX2/512 kernels, we use different compile options for each translation unit. We solve this problem by adding explicit instantiation declarations in the header files for these kernels -(:ref:`file_pennylane_lightning_core_src_simulators_lightning_qubit_gates_cpu_kernels_GateImplementationsLM.hpp` and -:ref:`file_pennylane_lightning_core_src_simulators_lightning_qubit_gates_cpu_kernels_GateImplementationsPI.hpp`) +(:ref:`file_pennylane_lightning_core_src_simulators_lightning_qubit_gates_cpu_kernels_GateImplementationsLM.hpp`) and compile them as a separate static library. With this, the AVX2/512 kernels are always included in the binary when compiled for UNIX-compatible OSs on x86-64 architecture. diff --git a/pennylane_lightning/core/src/simulators/lightning_qubit/gates/KernelMap.hpp b/pennylane_lightning/core/src/simulators/lightning_qubit/gates/KernelMap.hpp index b84a0b8b81..e920f72263 100644 --- a/pennylane_lightning/core/src/simulators/lightning_qubit/gates/KernelMap.hpp +++ b/pennylane_lightning/core/src/simulators/lightning_qubit/gates/KernelMap.hpp @@ -242,11 +242,9 @@ class OperationKernelMap { : allowed_kernels_{ // LCOV_EXCL_START {CPUMemoryModel::Unaligned, {KernelType::LM}}, - {CPUMemoryModel::Aligned256, - {KernelType::LM, KernelType::AVX2}}, + {CPUMemoryModel::Aligned256, {KernelType::LM, KernelType::AVX2}}, {CPUMemoryModel::Aligned512, - {KernelType::LM, KernelType::AVX2, - KernelType::AVX512}}, + {KernelType::LM, KernelType::AVX2, KernelType::AVX512}}, // LCOV_EXCL_STOP } {} diff --git a/pennylane_lightning/core/src/simulators/lightning_qubit/gates/tests/Test_Internal.cpp b/pennylane_lightning/core/src/simulators/lightning_qubit/gates/tests/Test_Internal.cpp index fa7ff8117f..00fa3b2ffd 100644 --- a/pennylane_lightning/core/src/simulators/lightning_qubit/gates/tests/Test_Internal.cpp +++ b/pennylane_lightning/core/src/simulators/lightning_qubit/gates/tests/Test_Internal.cpp @@ -29,7 +29,6 @@ /// @cond DEV namespace { -using namespace Pennylane::LightningQubit; using namespace Pennylane::Util; } // namespace /// @endcond diff --git a/pennylane_lightning/core/src/utils/TestKernels.hpp b/pennylane_lightning/core/src/utils/TestKernels.hpp index 8bf42d93d0..d15ae71256 100644 --- a/pennylane_lightning/core/src/utils/TestKernels.hpp +++ b/pennylane_lightning/core/src/utils/TestKernels.hpp @@ -22,9 +22,7 @@ #include "TypeList.hpp" #include "cpu_kernels/GateImplementationsLM.hpp" -#include "cpu_kernels/GateImplementationsPI.hpp" using TestKernels = Pennylane::Util::TypeList< - Pennylane::LightningQubit::Gates::GateImplementationsPI, Pennylane::LightningQubit::Gates::GateImplementationsLM, void>; #endif \ No newline at end of file