qiskit-community / qiskit-nature

Qiskit Nature is an open-source, quantum computing, framework for solving quantum mechanical natural science problems.
https://qiskit-community.github.io/qiskit-nature/
Apache License 2.0
296 stars 201 forks source link

QEOM energies differ for Statevector and Qasm simulator #52

Closed MariaSapova closed 1 year ago

MariaSapova commented 3 years ago

Information

What is the current behavior?

For H2 molecule QEOM excited state energies differ running with Statevector and Qasm simulators.

Steps to reproduce the problem

Please, run the gist

What is the expected behavior?

Close excited state energies

Suggested solutions

Seems like the problem is somewhere in eval() method, but I'm not sure about that.

ikkoham commented 3 years ago

How about using Aer for statevector simulator instead of BasicAer?

MariaSapova commented 3 years ago

@ikkoham Hello! Aer for statevector simulator provides the same results as BasicAer and they are equal to exact diagonalization results. But still there is some problem with qasm.

yaelbh commented 3 years ago

Qasm by default performs measurements, so you obtain statistical errors. This is its default behavior, because users often use it to mimic a real device. If you want exact diagonalization, try setting the parameter initial_custom to True.

MariaSapova commented 3 years ago

Hello @yaelbh! I use include_custom = True with qasm simulator. Still excited state energies deviate greatly. image And also there is some obvious error in matrix element calculations. image

MariaSapova commented 3 years ago

Hello @paulineollitrault ! Could you please provide any insights on how to deal with this inconsistence in qasm results?

paulineollitrault commented 3 years ago

Hi @MariaSapova! A fix is pending (see above), waiting to be merged

MariaSapova commented 3 years ago

@paulineollitrault as far as I can see this commit fixes the normalization of the matrix elements, but what about differences in q_0_0, q_1_1, q_2_2 values? I guess the energies differ because of these matrix elements.

image

woodsp-ibm commented 3 years ago

@paulineollitrault Do you have any response to the last comment above that despite the normalization fix being merged there are still differences? If this is still an issue I will transfer this to the new repo to be fixed there/

MariaSapova commented 3 years ago

@woodsp-ibm @paulineollitrault Hello! I actually already opened another issue which is more general Qiskit/qiskit-aqua#1510. I found out that evaluate_operators() in GroundStateEigensolvers produces incorrect expectation values when using qasm. With rewriting expectation value evaluation I could overcome this issue and got correct matricees in QEOM.

mrossinek commented 3 years ago

I investigated this bug together with @Cryoris again today but we have not been able to track down the exact cause of it yet.. We opened a PR to fix a sub-issue of this but I am afraid a fix for this issue will not make it into the upcoming release. I will revisit this again in more detail later.

Anthony-Gandon commented 1 year ago

This issue seems to have been solved as a side effect of the new Qiskit release. The problematic methods for this issue (eval_op() and evaluate_operators()) have been deprecated and replaced.

The new behaviour of the QEOM calculation does not show this difference between the noisy and state vector "backend" (this has also been replaced): see this gist

mrossinek commented 1 year ago

Thank you, Anthony! :+1: