Open jwtkeeble opened 2 months ago
Have you tried reconstructing the expectation values using parallelization from https://qiskit.github.io/qiskit-aer/stubs/qiskit_aer.AerSimulator.html
Also I'm curious, have you checked this with the EstimatorV2 Primitive?
Hi @jsaroni, thanks for the response! I'm relatively new to Qiskit, so I'm not that well versed in the Qiskit framework. Do I just have to change the backend of qiskit_aer
to parrallelize expectation values?
I did see that you can represent the wavefunction as a vector (and use something like np.einsum
) to compute multiple expectations, but that's intractable for any reasonable number of qubits.
If you're aware of any minimal reproducible example that can compute expectation values, please do let me know!
What should we add?
I'm trying to compute the expectation values of a large set of Pauli strings, and it's taking way too long on the CPU. I was wondering there's an in-built way to parrallelize taking the expectation values over a large list?
My current solution is to use the
joblib
library and split by array intonthreads
subsets and run each subset on a single thread on my CPU (out of a total ofnthreads
). However, I only see a benefit at aroundnqubits
= 10 and higher, which I assume this is due to some form of overhead when assigning the subsets to each CPU thread (and a trade-off between anthreads
CPU working independently and allnthreads
CPUs working on the same expectation value).Is there an in-built to parrallelize this operation? Or perhaps is there a way to parrallelize this for-loop over the GPU without using an external library? I understand in other libraries (e.g. JAX or PyTorch), there exist in-built vectorization functions, e.g.
jax.vmap
ortorch.vmap
that allow for a vectorized approach to iterables. Is there something equivalent in Qiskit?Any help would be greatly appreciated!
I've attached an example script below to demonstrate this behaviour, and I've attached an example output at the bottom of this issue.
The output of this script is here: