Open Alex-Preciado opened 10 months ago
@Alex-Preciado I was wondering if I could directly push a branch to the repo.
Hey @sbohloul 👋 , external contributions can only be made through forks. You will need to fork the repo to submit a pull request with your changes. You can find more details here: https://github.com/PennyLaneAI/pennylane-lightning#contributing. Let me know if you any other questions.
Important Note
⚠️ 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 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.