Qaqarot / qaqarot

Quantum Computer Library for Everyone
Apache License 2.0
371 stars 53 forks source link

Numba backend returns wrong statevector #76

Closed gyu-don closed 4 years ago

gyu-don commented 4 years ago
from blueqat import Circuit

c = Circuit()
c.h[0]
c.cx[0, 1];
c.z[2];

import numpy as np

v1 = c.run_with_numpy()
v2 = c.run_with_numba()
v3 = c.run_with_qgate()

print('numpy')
print(v1)
print('numba')
print(v2)
print('qgate')
print(v3)

Expected: All backends return same result Actual:

numpy
[0.70710678+0.j 0.        +0.j 0.        +0.j 0.70710678+0.j
 0.        +0.j 0.        +0.j 0.        +0.j 0.        +0.j]
numba
[ 0.70710678+0.j  0.70710678+0.j  0.        +0.j  0.        +0.j
 -0.        +0.j -0.        +0.j -0.        +0.j -0.        +0.j]
qgate
[0.70710678+0.j 0.        +0.j 0.        +0.j 0.70710678+0.j
 0.        +0.j 0.        +0.j 0.        +0.j 0.        +0.j]
gyu-don commented 4 years ago

Easier case: c = Circuit().x[0].cx[0, 1].z[2]

gyu-don commented 4 years ago

c = Circuit().i[2].x[0].cx[0, 1] is easiest case. Maybe, when n_qubit is 3, cx is not worked properly.