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 solver example: running errors #8334

Closed
dariomaio opened this issue Jul 13, 2022 · 0 comments · Fixed by #9832
Closed

HHL solver example: running errors #8334

dariomaio opened this issue Jul 13, 2022 · 0 comments · Fixed by #9832
Labels
bug Something isn't working mod: algorithms Related to the Algorithms module

Comments

@dariomaio
Copy link

Environment

  • Qiskit Terra version: 0.20.1
  • Python version: 3.7
  • Operating system: Windows 10

What is happening?

  1. full naive solution vector: [1.14135909 0.32179095]
    full tridi solution vector: [-1.17282534 -0.17530181]
    classical state: [1.125 0.375]

So the statement "It should not come as a surprise that naive_hhl_solution is exact because all the default methods used are exact" is false

  1. infinite loop running this code:

from qiskit import transpile

num_qubits = list(range(1,5))
a = 1
b = -1/3

i=1

calculate the circuit depths for different number of qubits to compare the use of resources

naive_depths = []
tridi_depths = []
for nb in num_qubits:
matrix = diags([b, a, b], [-1, 0, 1], shape=(2nb, 2nb)).toarray()
vector = np.array([1] + [0]*(2**nb -1))

naive_hhl_solution = HHL().solve(matrix, vector)
tridi_matrix = TridiagonalToeplitz(nb, a, b)
tridi_solution = HHL().solve(tridi_matrix, vector)

naive_qc = transpile(naive_hhl_solution.state,basis_gates=['id', 'rz', 'sx', 'x', 'cx'])
tridi_qc = transpile(tridi_solution.state,basis_gates=['id', 'rz', 'sx', 'x', 'cx'])

naive_depths.append(naive_qc.depth())
tridi_depths.append(tridi_qc.depth())
i +=1

How can we reproduce the issue?

You can run the example shownat https://learn.qiskit.org/course/ch-applications/solving-linear-systems-of-equations-using-hhl-and-its-qiskit-implementation

What should happen?

???

Any suggestions?

No response

@dariomaio dariomaio added the bug Something isn't working label Jul 13, 2022
@woodsp-ibm woodsp-ibm added the mod: algorithms Related to the Algorithms module label Mar 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mod: algorithms Related to the Algorithms module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants