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

Fix kernel builder c_if qubit extraction bug #857

Merged
merged 3 commits into from
Nov 3, 2023

Conversation

anthony-santana
Copy link
Collaborator

@anthony-santana anthony-santana commented Nov 3, 2023

Description

  • Fixes an issue where qubits that are extracted in a then function were not getting a unique extract_ref if used outside of the conditional
  • Adds new python and C++ tests to test for this bug
    kernel = cudaq.make_kernel()
    qubits = kernel.qalloc(2)

    kernel.x(qubits[0])
    measure = kernel.mz(qubits[0], "measure0")

    def then():
        kernel.x(qubits[1])

    kernel.c_if(measure, then)

    # With bug, any use of `qubits[1]` again would throw a
    # runtime error.
    kernel.x(qubits[1])
    kernel.x(qubits[1])

    result = cudaq.sample(kernel)

Signed-off-by: A.M. Santana <anthonys@nvidia.com>
Copy link

copy-pr-bot bot commented Nov 3, 2023

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Signed-off-by: A.M. Santana <anthonys@nvidia.com>
@anthony-santana anthony-santana changed the title Kernel builder c_if bug Fix kernel builder c_if qubit extraction bug Nov 3, 2023
@anthony-santana anthony-santana marked this pull request as ready for review November 3, 2023 04:35
@anthony-santana
Copy link
Collaborator Author

anthony-santana commented Nov 3, 2023

/ok to test

Command Bot: Processing...

Copy link

github-actions bot commented Nov 3, 2023

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Nov 3, 2023
Copy link
Collaborator

@amccaskey amccaskey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this, I'm pretty sure the code you've removed was put there before we had the canonicalizers that combined like extracts. Good to see the old stuff get cleaned up.

Signed-off-by: A.M. Santana <anthonys@nvidia.com>
@anthony-santana
Copy link
Collaborator Author

anthony-santana commented Nov 3, 2023

/ok to test

Command Bot: Processing...

@anthony-santana anthony-santana enabled auto-merge (squash) November 3, 2023 13:33
@anthony-santana anthony-santana merged commit 2e3536b into NVIDIA:main Nov 3, 2023
105 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Nov 3, 2023
@anthony-santana anthony-santana deleted the c_if_bug branch November 3, 2023 14:08
Copy link
Collaborator

@schweitzpgi schweitzpgi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@bettinaheim bettinaheim added this to the release 0.5.0 milestone Nov 15, 2023
@bettinaheim bettinaheim added the bug fix To be listed under Bug Fixes in the release notes label Nov 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug fix To be listed under Bug Fixes in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants