qiskit-nature icon indicating copy to clipboard operation
qiskit-nature copied to clipboard

QEOM energies differ for Statevector and Qasm simulator

Open MariaSapova opened this issue 4 years ago • 10 comments

Information

  • Qiskit Aqua version: 0.8.1
  • Python version: 3.6.8
  • Operating system: Ubuntu

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.

MariaSapova avatar Nov 30 '20 22:11 MariaSapova

How about using Aer for statevector simulator instead of BasicAer?

ikkoham avatar Dec 01 '20 06:12 ikkoham

@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.

MariaSapova avatar Dec 01 '20 11:12 MariaSapova

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.

yaelbh avatar Dec 01 '20 11:12 yaelbh

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 avatar Dec 01 '20 12:12 MariaSapova

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

MariaSapova avatar Dec 21 '20 10:12 MariaSapova

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

paulineollitrault avatar Dec 21 '20 10:12 paulineollitrault

@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

MariaSapova avatar Dec 21 '20 10:12 MariaSapova

@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/

woodsp-ibm avatar Jan 29 '21 21:01 woodsp-ibm

@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.

MariaSapova avatar Jan 30 '21 12:01 MariaSapova

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.

mrossinek avatar Mar 31 '21 21:03 mrossinek

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

Anthony-Gandon avatar Nov 17 '22 09:11 Anthony-Gandon

Thank you, Anthony! :+1:

mrossinek avatar Nov 17 '22 12:11 mrossinek