Skip to content

Fix kernel builder c_if qubit extraction bug - #857

Merged
anthony-santana merged 3 commits into
NVIDIA:mainfrom
anthony-santana:c_if_bug
Nov 3, 2023
Merged

anthony-santana merged 3 commits into
NVIDIA:mainfrom
anthony-santana:c_if_bug

Conversation

@anthony-santana

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

Copy link
Copy Markdown
Collaborator

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-pr-bot

copy-pr-bot Bot commented Nov 3, 2023

Copy link
Copy Markdown

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

anthony-santana commented Nov 3, 2023 •

Copy link
Copy Markdown
Collaborator Author

/ok to test

Command Bot: Processing...

@github-actions

github-actions Bot commented Nov 3, 2023

Copy link
Copy Markdown

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

@amccaskey amccaskey left a comment

Copy link
Copy Markdown
Collaborator

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.

Comment thread runtime/cudaq/builder/QuakeValue.cpp Resolved
Signed-off-by: A.M. Santana <anthonys@nvidia.com>
@anthony-santana

anthony-santana commented Nov 3, 2023 •

Copy link
Copy Markdown
Collaborator Author

/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
@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

@schweitzpgi schweitzpgi left a comment

Copy link
Copy Markdown
Collaborator

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