Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
5.28k stars 2.37k forks source link

Possible Issue with eval_hamiltonian? #611

Closed qcomputer11 closed 6 years ago

qcomputer11 commented 6 years ago

Informations

What is the current behavior?

I am trying to do a test calculation using the variational method and the tools in the optimization.py module. First, I calculate the exact value for the lowest eigenvalue of my matrix using numpy. Then, I use the SPSA optimization to find it using the simulator. However, I have found that the simulator can return a value that is actually lower than the exact eigenvalue, which should not be possible by the variational principle.

Thus, my problem is that, when evaluating the Hamiltonian, it is possible to get a value below the lowest eigenvalue, which should not be possible.

Steps to reproduce the problem

I will attach my Hamiltonian (anharmonic_osc.txt) and code (convert variational_issue.txt to a .py file). The initial value of theta should work to recreate the issue. Simply running my attached script should give values of the objective function below the actual minimum.

anharmonic_osc.txt variational_issue.txt

Note also that this error can be observed with other circuits as well.

What is the expected behavior?

eval_hamiltonian should not produce a value below the actual ground state.

Suggested solutions

It is possible I am not understanding something about how the optimization.py module works (I am relatively new to qiskit and quantum computing), but I am very concerned that values of the objective function that violate the variational principle are returned. I have also observed this error infrequently with the circuits in optimization.py. My guess is that eval_hamiltonian is not actually finding an expectation value (<x|H|x>), but I am unsure of how to fix this.

jaygambetta commented 6 years ago

we are actually removing this in the near future and putting it into qiskit-acqua. @pistoia and @antoniomezzacapo could you please take this up in acqua.

Thanks