You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
⚠️ This issue is part of an internal assignment and not meant for external contributors.
Details
The expectation value of a quantum gate $U$ for a circuit in the state $| \psi \rangle$ is $\langle \psi | U | \psi \rangle$. In PennyLane-Lightning this is calculated by first applying $U$ to $| \psi \rangle$ to get $| \psi' \rangle$ and then take the inner product with $| \psi \rangle$. That is not optimal since one needs to allocate a copy of $| \psi \rangle$.
Implementation
Modify the expval method in MeasurementsLQubit.hpp (only the one with a const std::string &operation argument) to mimic the Lightning-Kokkos implementation, i.e. write specialized kernels that do not rely on applyMatrix/applyOperation+innerProdC but perform all operations at once. That will be done in a loop over the state vector entries (have a look at the PauliX functor in ExpValFunctors.hpp for example). That loop is embarrassingly parallelizable and should be parallelized as such.
Requirements
A PR must satisfy the following:
Write expval kernels for the Identity, PauliX, PauliY, PauliZ, Hadamard observables.
Parallelize the kernels with C++ threads or OpenMP.
Validate the implementation with C++ & Python tests (you may reuse existing tests, but add some if coverage requires it).
Pass clang-tidy, black and pylint checks.
Include a changelog entry under "Improvements".
Gather benchmark data using the Python interface of PennyLane (old versus new implementation & time versus number of threads for different qubits count) and discuss the performance trends. Put the benchmarking scripts in a Github gist and share the gist in the PR comments.
The text was updated successfully, but these errors were encountered:
multiphaseCFD
changed the title
In place expval kernels for LightningQubit
Expval kernels for LightningQubit
Nov 10, 2023
Important Note
Details
The expectation value of a quantum gate$U$ for a circuit in the state $| \psi \rangle$ is $\langle \psi | U | \psi \rangle$ . In PennyLane-Lightning this is calculated by first applying $U$ to $| \psi \rangle$ to get $| \psi' \rangle$ and then take the inner product with $| \psi \rangle$ . That is not optimal since one needs to allocate a copy of $| \psi \rangle$ .
Implementation
Modify the
expval
method in MeasurementsLQubit.hpp (only the one with aconst std::string &operation
argument) to mimic the Lightning-Kokkos implementation, i.e. write specialized kernels that do not rely onapplyMatrix/applyOperation+innerProdC
but perform all operations at once. That will be done in a loop over the state vector entries (have a look at the PauliX functor in ExpValFunctors.hpp for example). That loop is embarrassingly parallelizable and should be parallelized as such.Requirements
A PR must satisfy the following:
expval
kernels for theIdentity
,PauliX
,PauliY
,PauliZ
,Hadamard
observables.The text was updated successfully, but these errors were encountered: