KEMBAR78
Enable capture of opaque kernel functions by amccaskey · Pull Request #1934 · NVIDIA/cuda-quantum · GitHub
Skip to content

Conversation

@amccaskey
Copy link
Collaborator

@amccaskey amccaskey commented Jul 15, 2024

Enable the following pattern

def localFunction():
    @cudaq.kernel
    def bell(i : int):
        q = cudaq.qvector(i)
        h(q[0])
        x.ctrl(q[0], q[1])    
    return bell 

opaqueBell = localFunction()
    
@cudaq.kernel
def kernel():
     opaqueBell(2)

counts = cudaq.sample(opaqueBell)

@copy-pr-bot
Copy link

copy-pr-bot bot commented Jul 15, 2024

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.

@amccaskey
Copy link
Collaborator Author

amccaskey commented Jul 15, 2024

/ok to test

Command Bot: Processing...

@github-actions
Copy link

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

github-actions bot pushed a commit that referenced this pull request Jul 15, 2024
@khalatepradnya
Copy link
Collaborator

Enable the following pattern

def localFunction():
    @cudaq.kernel
    def bell(i : int):
        q = cudaq.qvector(i)
        h(q[0])
        x.ctrl(q[0], q[1])    
    return bell 

opaqueBell = localFunction()
    
@cudaq.kernel
def kernel():
     opaqueBell(2)

counts = cudaq.sample(opaqueBell)  # Is this typo?

Can you help clarify this example?
I think counts = cudaq.sample(opaqueBell, 2) is supported before this PR, and this PR will enable counts = cudaq.sample(kernel)?

@amccaskey
Copy link
Collaborator Author

Enable the following pattern

def localFunction():
    @cudaq.kernel
    def bell(i : int):
        q = cudaq.qvector(i)
        h(q[0])
        x.ctrl(q[0], q[1])    
    return bell 

opaqueBell = localFunction()
    
@cudaq.kernel
def kernel():
     opaqueBell(2)

counts = cudaq.sample(opaqueBell)  # Is this typo?

Can you help clarify this example? I think counts = cudaq.sample(opaqueBell, 2) is supported before this PR, and this PR will enable counts = cudaq.sample(kernel)?

This new functionality is for capturing kernels declared elsewhere (like in a function), and aliased with a new variable name.

Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
@khalatepradnya
Copy link
Collaborator

khalatepradnya commented Jul 16, 2024

/ok to test

Command Bot: Processing...

@amccaskey amccaskey enabled auto-merge (squash) July 16, 2024 19:28
@amccaskey amccaskey merged commit ef013e8 into NVIDIA:main Jul 16, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2024
@bettinaheim bettinaheim added the release notes Changes need to be captured in the release notes label Jul 29, 2024
@bettinaheim bettinaheim added this to the release 0.8.0 milestone Jul 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release notes Changes need to be captured in the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants