Skip to content

Commit

Permalink
Kokkos gate functors are templated over the coefficient interaction f…
Browse files Browse the repository at this point in the history
…unction (#640)

* Example of applyNC1Functor

* Auto update version

* WIP

* Rewrite 1-gate functors.

* Refactor 2-gate functors.

* WIP

* Finish gate functor refactor.

* Prune gate functor modules.

* Auto update version

* Remove whitespace.

* Fix globalphase.

* shots=20000 => shots=40000

* run isort with python3.9

* WIP gen

* Rewrite generators in terms of applyNCN.

* Auto update version

* trigger ci

* Auto update version

* trigger ci

* Update changelog [skip ci].

* Kokkos views can be copied.

* Auto update version

* Auto update version

* Remove empty line.

* Auto update version

* trigger ci

* Auto update version

* trigger ci

* Update pennylane_lightning/core/src/simulators/lightning_kokkos/gates/BasicGateFunctors.hpp

Co-authored-by: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>

* Update pennylane_lightning/core/src/simulators/lightning_kokkos/gates/BasicGeneratorFunctors.hpp

Co-authored-by: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>

* Update pennylane_lightning/core/src/simulators/lightning_kokkos/gates/MatrixGateFunctors.hpp

Co-authored-by: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>

* Auto update version

* Update pennylane_lightning/core/src/simulators/lightning_kokkos/gates/BasicGeneratorFunctors.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Update pennylane_lightning/core/src/simulators/lightning_kokkos/gates/MatrixGateFunctors.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Upgrade gates module and use it to test CRX, etc.

* Update pennylane_lightning/core/src/simulators/lightning_kokkos/gates/BasicGateFunctors.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Cover 3-qubit case.

* Auto update version

* trigger ci

* Add tests for applyXOperation.

* Auto update version

* trigger ci

* Update SVK.

* Auto update version

* trigger ci

* Auto update version

* Auto update version

* Remove obsolete generator functors module.

* Revert pennylane_lightning/core/src/utils/config.h

* Auto update version from '0.36.0-dev34' to '0.36.0-dev35'

* Auto update version from '0.37.0-dev0' to '0.37.0-dev1'

* Remove obsolete workflow.

* Auto update version from '0.37.0-dev1' to '0.37.0-dev2'

* Auto update version from '0.37.0-dev2' to '0.37.0-dev3'

* Auto update version from '0.37.0-dev3' to '0.37.0-dev4'

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

* Apply Shuli's suggestions.

* Add Rot/CRot matrix tests.

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

* Revert couple changes.

* Update pennylane_lightning/core/src/gates/Gates.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Update pennylane_lightning/core/src/gates/Gates.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Update pennylane_lightning/core/src/gates/Gates.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Update pennylane_lightning/core/src/gates/Gates.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Update pennylane_lightning/core/src/gates/Gates.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Update pennylane_lightning/core/src/gates/Gates.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Update pennylane_lightning/core/src/gates/Gates.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Update pennylane_lightning/core/src/gates/Gates.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Update pennylane_lightning/core/src/gates/Gates.hpp

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>

* Revert --shots=40000

* Format & size_t => std::size_t.

---------

Co-authored-by: Dev version update bot <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Amintor Dusko <87949283+AmintorDusko@users.noreply.github.com>
Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>
Co-authored-by: ringo-but-quantum <github-ringo-but-quantum@xanadu.ai>
  • Loading branch information
5 people authored May 15, 2024
1 parent e535094 commit aa30de7
Show file tree
Hide file tree
Showing 24 changed files with 2,769 additions and 3,981 deletions.
3 changes: 3 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

### Improvements

* 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)

* Update C++ and Python GitHub actions names to include the matrix info.
[(#717)](https://github.com/PennyLaneAI/pennylane-lightning/pull/717)

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.37.0-dev11"
__version__ = "0.37.0-dev12"
342 changes: 281 additions & 61 deletions pennylane_lightning/core/src/gates/Gates.hpp

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class AdjointJacobian final
ops.getOpsWires()[op_idx],
!ops.getOpsInverses()[op_idx]) *
(ops.getOpsInverses()[op_idx] ? -1 : 1);
for (size_t obs_idx = 0; obs_idx < num_observables;
for (std::size_t obs_idx = 0; obs_idx < num_observables;
obs_idx++) {
const std::size_t idx =
trainableParamNumber + obs_idx * tp_size;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ TEMPLATE_PRODUCT_TEST_CASE(

std::uniform_real_distribution<PrecisionT> dist(-1.0, 1.0);

for (size_t k = 0; k < n_terms; k++) {
for (std::size_t k = 0; k < n_terms; k++) {
auto term_pauli = randomIntVector(re, num_qubits, 0, 3);

std::vector<std::shared_ptr<Observable<StateVectorT>>> term_comp;
for (size_t i = 0; i < num_qubits; i++) {
for (std::size_t i = 0; i < num_qubits; i++) {
if (term_pauli[i] == 0) {
continue;
}
Expand All @@ -86,7 +86,7 @@ TEMPLATE_PRODUCT_TEST_CASE(
coeffs.emplace_back(dist(re));
terms.emplace_back(TensorProdObs<StateVectorT>::create(term_comp));
}
std::vector<ComplexT> psi(size_t{1} << num_qubits);
std::vector<ComplexT> psi(std::size_t{1} << num_qubits);
std::normal_distribution<PrecisionT> ndist;
for (auto &e : psi) {
e = ndist(re);
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
// limitations under the License.
#pragma once

#include "GateFunctorsGenerator.hpp"
#include "GateFunctorsNonparam.hpp"
#include "GateFunctorsParam.hpp"
#include "BasicGateFunctors.hpp"
#include "BasicGeneratorFunctors.hpp"
#include "MatrixGateFunctors.hpp"
Loading

0 comments on commit aa30de7

Please sign in to comment.