Skip to content
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

HHL results mismatch with the runtime and textbook #8332

Closed
zuxfoucault opened this issue Jul 12, 2022 · 3 comments · Fixed by #9832
Closed

HHL results mismatch with the runtime and textbook #8332

zuxfoucault opened this issue Jul 12, 2022 · 3 comments · Fixed by #9832
Labels
mod: algorithms Related to the Algorithms module

Comments

@zuxfoucault
Copy link

zuxfoucault commented Jul 12, 2022

image
This is a snapshot from the textbook.

image
This is from runtime.

The same code shows different circuit in the textbook and execution time. Not sure what’s wrong with this? https://learn.qiskit.org/course/ch-applications/solving-linear-systems-of-equations-using-hhl-and-its-qiskit-implementation

Also, the solution states are different.

@zuxfoucault
Copy link
Author

For the naive solution, is the circuit should be 4 qubits or 5? Thanks!

@zuxfoucault
Copy link
Author

zuxfoucault commented Jul 17, 2022

Update: If I change the extracting vector index:
"""
naive_full_vector = np.array([naive_sv[16], naive_sv[17] ])
tridi_full_vector = np.array([tridi_sv[16], tridi_sv[17] ])
"""
Now, I can get the exact solution same as classical:
full naive solution vector: [1.125 0.375]
full tridi solution vector: [1.125 0.375]
classical state: [1.125 0.375]

But if I try another example i.e., matrix = np.array([[1, -1/4], [-1/4, 1]])
and keeping other code the same, the solution won't match.
full naive solution vector: [1.00580738 0.32752595]
full tridi solution vector: [1.125 0.375]
classical state: [1.06666667 0.26666667]

@zuxfoucault
Copy link
Author

zuxfoucault commented Jul 18, 2022

Is this where the bug from:
https://github.com/Qiskit/qiskit-terra/blob/main/qiskit/algorithms/linear_solvers/hhl.py#L384

Why does allow negative eigenvalues considering adding 1 more qubit in the circuit? If I set neg_value to False, the rendered result showed exactly like the example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mod: algorithms Related to the Algorithms module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants