-
Notifications
You must be signed in to change notification settings - Fork 184
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
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 |
ikkoham
changed the title
Unexpected behavior with enumerate
Unexpected behavior with list[bool] for argument of kernel
Oct 30, 2024
This is likely the same problem as the one reported in #2262. |
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: