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

Unexpected results in global register for kernels that both mx and mz #2684

Open
3 of 4 tasks
bmhowe23 opened this issue Mar 3, 2025 · 0 comments
Open
3 of 4 tasks

Comments

@bmhowe23
Copy link
Collaborator

bmhowe23 commented Mar 3, 2025

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

Putting both mx and mz in kernels can result in incomplete results in the __global__ register.

Steps to reproduce the bug

Consider the following kernel:

import cudaq

@cudaq.kernel
def kernel():
    qubits_a = cudaq.qvector(2)
    qubit_b = cudaq.qubit()
    mz(qubits_a)
    mx(qubit_b)

counts = cudaq.sample(kernel)
print(counts)

That will produce something like this:

{ 0:490 1:510 }

Expected behavior

The specification/docs say that

if a qubit is measured in the middle of a kernel and subsequent operations change the state of the qubit, the qubit will be implicitly re-measured at the end of the kernel, and that re-measured value is the value that will appear in the global register.

It is unclear if "re-measured" means measured in the same basis as the original measurement or not, but regardless, the example above shows that the measurements for qubits_a can be lost. They should be in the resulting global register.

Is this a regression? If it is, put the last known working version (or commit) here.

Not a regression

Environment

  • CUDA-Q version: latest (fe1396b at the time of the creation of this issue)
  • Python version: 3.10
  • C++ compiler:
  • Operating system:

Suggestions

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant