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

Incorrect results from statevector simulation when fusion is enabled #2245

Open
hvenev-insait opened this issue Oct 14, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@hvenev-insait
Copy link

Informations

  • Qiskit Aer version: 0.15.1
  • Python version: 3.12.7
  • Operating system: Fedora 40

What is the current behavior?

On some circuits AerSimulator(method='statevector', fusion_enable=...) produces very different results based on the value of fusion_enable. I think the fusion_enable=False result is the correct one.

Steps to reproduce the problem

import qiskit
import qiskit_aer
import numpy

q = qiskit.circuit.QuantumRegister(15)
circuit = qiskit.QuantumCircuit(q)
circuit.h(q[0])
circuit.cx(q[1], q[0])
circuit.x(q[0])
circuit.s(q[0])
circuit.x(q[0])
circuit.save_statevector()

sim1 = qiskit_aer.AerSimulator(method='statevector', precision='double', device='CPU', fusion_enable=True)
sim2 = qiskit_aer.AerSimulator(method='statevector', precision='double', device='CPU', fusion_enable=False)

res1 = sim1.run(circuit, shots=1).result()
res2 = sim2.run(circuit, shots=1).result()

sv1 = numpy.asarray(res1.data()['statevector'])[:4]
# [0.7071067811865476, 0.7071067811865475j, 0, 0]

sv2 = numpy.asarray(res2.data()['statevector'])[:4]
# [0.7071067811865476j, 0.7071067811865475, 0, 0]

# remove global phase
sv1 /= sv1[0]
sv2 /= sv2[0]

print(list(sv1))
# [1, 0.9999999999999998j, 0, 0]

print(list(sv2))
# [1, -0.9999999999999998j, 0, 0]

What is the expected behavior?

The difference between simulation results with and without fusion should be minimal.

Suggested solutions

@hvenev-insait hvenev-insait added the bug Something isn't working label Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant