Copying measurement variable inside cudaq.kernel causes issues.
Closed this issue · 0 comments
vinitX commented
Required prerequisites
- Consult the security policy. If reporting a security vulnerability, do not report the bug using this form. Use the process described in the policy to report the issue.
- Make sure you've read the documentation. Your issue may be addressed there.
- Search the issue tracker to verify that this hasn't already been reported. +1 or comment there if it has.
- If possible, make a PR with a failing test to give us a starting point to work on!
Describe the bug
Copying the measurement variable to another local variable in the kernel causes issues. For instance, in the code snippet attached below, I'm executing a simple circuit where I copy the measurement results stored in 'res' to another variable, 'Flag', but that new variable doesn't work the same when I try to use some conditional statements on it. For comparison, I'm attaching two snippets: one working with the 'res' variable and the other working with the 'Flag' variable.
Steps to reproduce the bug
@cudaq.kernel
def test():
qubit = cudaq.qubit()
res = mz(qubit)
h(qubit)
res = mz(qubit)
Flag = res
if Flag == True:
true_res = mz(qubit)
else:
false_res = mz(qubit)
Output:
{
true_res : { 0:503 1:497 }
global : { 0:503 1:497 }
res : { 0:503 1:497 }
}
Expected behavior
{
false_res : { 0:511 }
global : { 0:511 1:489 }
true_res : { 1:489 }
res : { 00:511 01:489 }
}
Is this a regression? If it is, put the last known working version (or commit) here.
Not a regression
Environment
- CUDA Quantum version:
- Python version:
- C++ compiler:
- Operating system:
Suggestions
No response