PennyLaneAI / pennylane-lightning

The PennyLane-Lightning plugin provides a fast state-vector simulator written in C++ for use with PennyLane
https://docs.pennylane.ai/projects/lightning
Apache License 2.0
91 stars 40 forks source link

Parallelize `apply_Sparse_Matrix` in lightning.qubit #991

Open tomlqc opened 1 week ago

tomlqc commented 1 week ago

Important Note

⚠️ This issue is part of an internal assignment and not meant for external contributors

Context

Compressed Sparse Row (CSR) matrix-vector product quickly computes the resulting vector entry-by-entry by ignoring the zero entries in a matrix. In Lightning, CSR matrix-vector products are used when computing the expectation value or variance of SparseHamiltonian observables. The core routine apply_Sparse_Matrix is implemented in the SparseLinAlg.hpp header file.

The goal of this task is to parallelize apply_Sparse_Matrix with C++ threads or OpenMP.

Requirements

The multi-threading support for the apply_Sparse_Matrix method has to be implemented in the lightning.qubit C++ backend, see pennylane_lightning/core/src/simulators/lightning_qubit/utils/SparseLinAlg.hpp

A PR must satisfy the following:

Don't hesitate to ask for clarification or raise any concerns regarding the issue. We'll be happy to discuss with you!

mvandelle commented 4 days ago

Hi Thomas, I have some issues installing the editable version of the lightning-qubit github repositry on my machine (windows sadly, i do not have a Mac OS or linux). I checked that i have all requirement, but in the last step when runing "pip install -e ." i got an error, it seems that a file is not properly created during the building process " error: can't copy 'C:\Users\User\AppData\Local\Temp\tmp67sbr2fa.build-lib\pennylane_lightning\lightning_qubit_ops.cp313-win_amd64.pyd': doesn't exist or not a regular file". Im starting to run out of option to solve this, is it a issue that maybe already happened on windows installation ? Have a good day, Marc

tomlqc commented 4 days ago

Hi @mvandelle , You would have more fun with Linux (think about dual boot if this is an option). I would need a bit more context. How did you install python and do you use venv or conda? Would you mind continuing the discussion in a draft PR?

mvandelle commented 4 days ago

I created the draft PR