-
Notifications
You must be signed in to change notification settings - Fork 213
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
Unexpected behavior with list[bool] for argument of kernel #2330
Labels
python-lang
Anything related to the Python CUDA Quantum language implementation
Comments
hmm, this may not be the problem of import cudaq
import itertools
@cudaq.kernel
def test(num_qubits: int, mask: list[bool]):
q = cudaq.qvector(num_qubits)
for i in range(num_qubits):
if mask[i]:
x(q[i])
mz(q)
num_qubits = 3
for mask in itertools.product((True, False), repeat=num_qubits):
print(list(mask))
print(cudaq.sample(test, num_qubits, list(mask))) outputs the same |
This is the bug of import cudaq
import itertools
@cudaq.kernel
def test(num_qubits: int, mask: list[int]):
q = cudaq.qvector(num_qubits)
for i in range(num_qubits):
if mask[i]:
x(q[i])
mz(q)
num_qubits = 4
for mask in itertools.product((1, 0), repeat=num_qubits):
print(list(mask))
print(cudaq.sample(test, num_qubits, list(mask))) works as expected. |
import cudaq
import itertools
@cudaq.kernel
def test(num_qubits: int, mask: list[int]):
q = cudaq.qvector(num_qubits)
for i, m in enumerate(mask):
if m:
x(q[i])
mz(q)
num_qubits = 4
for mask in itertools.product((1, 0), repeat=num_qubits):
print(list(mask))
print(cudaq.sample(test, num_qubits, list(mask))) is ok |
This is likely the same problem as the one reported in #2262. |
#2338 fixes a number of bugs with arguments, etc. Output if #2338 is applied: [True, True, True]
{ 111:1000 }
[True, True, False]
{ 110:1000 }
[True, False, True]
{ 101:1000 }
[True, False, False]
{ 100:1000 }
[False, True, True]
{ 011:1000 }
[False, True, False]
{ 010:1000 }
[False, False, True]
{ 001:1000 }
[False, False, False]
{ 000:1000 } |
Fixed. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Required prerequisites
Describe the bug
Unexpected behavior when using enumerate to create kernel.
Detail is below.
Steps to reproduce the bug
outputs
Only the case (True, False, False) is correct.
Expected behavior
Should return the correct bit string
Is this a regression? If it is, put the last known working version (or commit) here.
Not a regression
Environment
Suggestions
No response
The text was updated successfully, but these errors were encountered: