-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
QEOM energies differ for Statevector and Qasm simulator #52
Comments
How about using Aer for statevector simulator instead of BasicAer? |
@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. |
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 |
Hello @yaelbh! |
As reported on multiple occasions (#1460 and qiskit-community#1467), the eigenvalues of the auxiliary operators are not correctly normalized when the QASM backend is used. This commit fixes this short-coming by applying the same normalization to the VQE's eigenstate when obtained from a QASM backend (in which case this is a dictionary) as done by the `CircuitSampler` in its `sample_circuits` function. The case of the statevector backend is unaffected by this change, as it will return the eigenstate as a list.
As reported on multiple occasions (#1460 and qiskit-community#1467), the eigenvalues of the auxiliary operators are not correctly normalized when the QASM backend is used. This commit fixes this short-coming by applying the same normalization to the VQE's eigenstate when obtained from a QASM backend (in which case this is a dictionary) as done by the `CircuitSampler` in its `sample_circuits` function. The case of the statevector backend is unaffected by this change, as it will return the eigenstate as a list. Co-authored-by: Julien Gacon <gaconju@gmail.com>
As reported on multiple occasions in Qiskit Aqua ([1], [2]), the eigenvalues of the auxiliary operators are not correctly normalized when the QASM backend is used. This commit fixes this short-coming by applying the same normalization to the VQE's eigenstate when obtained from a QASM backend (in which case this is a dictionary) as done by the `CircuitSampler` in its `sample_circuits` function. The case of the statevector backend is unaffected by this change, as it will return the eigenstate as a list. A unittest is added which asserts this behavior. [1]: https://github.com/Qiskit/qiskit-aqua/issues/1460 [2]: qiskit-community/qiskit-aqua#1467 Co-authored-by: Julien Gacon <gaconju@gmail.com>
Hello @paulineollitrault ! Could you please provide any insights on how to deal with this inconsistence in qasm results? |
Hi @MariaSapova! A fix is pending (see above), waiting to be merged |
@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. |
As reported on multiple occasions in Qiskit Aqua ([1], [2]), the eigenvalues of the auxiliary operators are not correctly normalized when the QASM backend is used. This commit fixes this short-coming by applying the same normalization to the VQE's eigenstate when obtained from a QASM backend (in which case this is a dictionary) as done by the `CircuitSampler` in its `sample_circuits` function. The case of the statevector backend is unaffected by this change, as it will return the eigenstate as a list. A unittest is added which asserts this behavior. [1]: https://github.com/Qiskit/qiskit-aqua/issues/1460 [2]: qiskit-community/qiskit-aqua#1467 Co-authored-by: Julien Gacon <gaconju@gmail.com> Co-authored-by: Julien Gacon <gaconju@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
As reported on multiple occasions in Qiskit Aqua ([1], [2]), the eigenvalues of the auxiliary operators are not correctly normalized when the QASM backend is used. This commit fixes this short-coming by applying the same normalization to the VQE's eigenstate when obtained from a QASM backend (in which case this is a dictionary) as done by the `CircuitSampler` in its `sample_circuits` function. The case of the statevector backend is unaffected by this change, as it will return the eigenstate as a list. A unittest is added which asserts this behavior. [1]: https://github.com/Qiskit/qiskit-aqua/issues/1460 [2]: qiskit-community/qiskit-aqua#1467 Co-authored-by: Julien Gacon <gaconju@gmail.com> Co-authored-by: Julien Gacon <gaconju@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* 1. params are required in convert method in GradientBased and HessianBased subclasses 2. fix on handling params of type ParameterExpression * Update qiskit/opflow/gradients/gradient.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * passmanager(..., callback=...) parameter removed (#5522) * passmanager callback removal * unused-import * reno * better initial_layout validation (#5526) Co-authored-by: Kevin Krsulich <kevin.krsulich@ibm.com> * 1) unit tests modified to test ParameterVector input for Gradient, NaturalGradient, QFI and Hessian 2) index method added to ParameterVector 3) handling of ParameterVector changed for Hessian to be consistent with list params * Hessian with respect to vector-like params returns matrix, unit test modified accordingly * Add PiecewiseChebyshev arithmetic circuit (#5364) * general polynomial approximation * release notes * fix qubit re-allocation * fix re-calling build * Update qiskit/circuit/library/arithmetic/piecewise_chebyshev.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * Update qiskit/circuit/library/arithmetic/piecewise_chebyshev.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * Update qiskit/circuit/library/arithmetic/piecewise_chebyshev.py Co-authored-by: Julien Gacon <gaconju@gmail.com> * fix indentation lint error * move tests to library module * Add suggestions from code review Co-authored-by: Julien Gacon <gaconju@gmail.com> * Ensure aux_operator eigenvalues are normalized (#5496) As reported on multiple occasions in Qiskit Aqua ([1], [2]), the eigenvalues of the auxiliary operators are not correctly normalized when the QASM backend is used. This commit fixes this short-coming by applying the same normalization to the VQE's eigenstate when obtained from a QASM backend (in which case this is a dictionary) as done by the `CircuitSampler` in its `sample_circuits` function. The case of the statevector backend is unaffected by this change, as it will return the eigenstate as a list. A unittest is added which asserts this behavior. [1]: https://github.com/Qiskit/qiskit-aqua/issues/1460 [2]: qiskit-community/qiskit-aqua#1467 Co-authored-by: Julien Gacon <gaconju@gmail.com> Co-authored-by: Julien Gacon <gaconju@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Hessian with respect to vector-like param returns matrix, unit test modified accordingly Co-authored-by: Julien Gacon <gaconju@gmail.com> Co-authored-by: Luciano Bello <luciano.bello@ibm.com> Co-authored-by: Kevin Krsulich <kevin.krsulich@ibm.com> Co-authored-by: Almudena Carrera Vazquez <almudenacarreravazquez@hotmail.com> Co-authored-by: Max Rossmannek <oss@zurich.ibm.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
@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 @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. |
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. |
Fixes qiskit-community#52 Fixes qiskit-community#415 Previously, QEOM evaluated the many operators needed to create the matrices Q,M on the groundstate resulting from a call to VQE. This worked for StateVector simulators because this object was exactly the statefunction (type VectorStateFn). However, when using QASM or aer_simulator this eigenstate is a dictionary of samples which was converted into a VectorStateFn without consideration of the sign ambiguity. This commit changes the evaluate_operators() method used in QEOM to the eval_observables() that was added in a recent commit of qiskit-terra. This method is called on the ansatz function evaluated at the optimal parameters given by the solver instead of on the groundstate. This delays the call to the eval() method which was the root of the issue. Added the required support for non-hermitian operators in the aer_pauli_expectation class
This issue seems to have been solved as a side effect of the new Qiskit release. 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 |
Thank you, Anthony! 👍 |
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.
The text was updated successfully, but these errors were encountered: