grove
grove copied to clipboard
Bug fix in vqe expectation
We found a bug while using vqe with samples=None. The current version uses the expectation method of WavefunctionSimulator from pyquil.api to calculate the expectation values of every term (including coefficients) in the PauliSum and then weights these with the coefficients of the terms. Thus, the coefficients are, effectively, squared, which results in an incorrect expectation value of the PauliSum. The proposed solution is to let the expectation method of WavefunctionSimulator handle everything since it supports PauliSums.
Moreover, we found that vqe expectation made some unnecessary computations on the QC, probably due to an accidental indentation (see last commit).
@kajoel Thanks for this!
@amyfbrown Can someone take a look into it and merge it, please? I think it's pretty critical one - if anyone is using VQE (or QAOA), they probably run a simulation with no sampling at first.