Skip to content

Commit

Permalink
Deprecate PI gates implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
maliasadi committed Sep 25, 2024
1 parent 3db3c2c commit 7571eb4
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 0 additions & 3 deletions doc/benchmark.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>
$ ./benchmarks/plot_gate_benchmark.py --precision double ./bench_result.json # Results for std::complex<double>
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
Expand Down
4 changes: 1 addition & 3 deletions doc/lightning_qubit/development/add_gate_kernel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -53,7 +53,6 @@ and
// file: gates/AvailableKernels.hpp
namespace Pennylane {
using AvailableKernels = Util::TypeList<GateImplementationsLM,
GateImplementationsPI,
MyGateImplementation /* This is added*/,
void>;
} // namespace Pennylane
Expand Down Expand Up @@ -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<Pennylane::Gates::GateImplementationsLM,
Pennylane::Gates::GateImplementationsPI,
MyGateImplementation /*This is added */, void>;
It will automatically test your gate implementation.
Expand Down
5 changes: 2 additions & 3 deletions doc/lightning_qubit/development/avx_kernels/build_system.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
} {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

/// @cond DEV
namespace {
using namespace Pennylane::LightningQubit;
using namespace Pennylane::Util;
} // namespace
/// @endcond
Expand Down
2 changes: 0 additions & 2 deletions pennylane_lightning/core/src/utils/TestKernels.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7571eb4

Please sign in to comment.