KEMBAR78
Enable user-custom data structs in python kernels by amccaskey · Pull Request #1939 · NVIDIA/cuda-quantum · GitHub
Skip to content

Conversation

@amccaskey
Copy link
Collaborator

@amccaskey amccaskey commented Jul 16, 2024

Enable the use of custom data class types in Python CUDA-Q kernel code

import cudaq
from dataclasses import dataclass 

@dataclass
class CustomIntAndFloatType:
    integer : int 
    floatingPoint : float 

@cudaq.kernel
def test(input : CustomIntAndFloatType):
    qubits = cudaq.qvector(input.integer)
    ry(input.floatingPoint, qubits[0])
    rx(input.floatingPoint * 2, qubits[0])
    x.ctrl(qubits[0], qubits[1])
    
instance = CustomIntAndFloatType(2, np.pi/2.)
counts = cudaq.sample(test, instance)

@copy-pr-bot
Copy link

copy-pr-bot bot commented Jul 16, 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 amccaskey requested review from annagrin, khalatepradnya and schweitzpgi and removed request for annagrin and khalatepradnya July 17, 2024 12:53
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.

LGTM.

@khalatepradnya
Copy link
Collaborator

I see this PR covers Python frontend, do we want to have same support on C++ side? (in the future)

@schweitzpgi
Copy link
Collaborator

I see this PR covers Python frontend, do we want to have same support on C++ side? (in the future)

We already support (some) data structures in C++. I don't think we want or need to register them as in this PR.

@amccaskey
Copy link
Collaborator Author

I see this PR covers Python frontend, do we want to have same support on C++ side? (in the future)

We already support (some) data structures in C++. I don't think we want or need to register them as in this PR.

After your comment the other day Eric - this PR no longer requires user-registration of the custom structs.

@amccaskey amccaskey force-pushed the pyTypePlugin branch 2 times, most recently from eb2a47e to f040769 Compare July 22, 2024 16:46
@amccaskey
Copy link
Collaborator Author

amccaskey commented Jul 22, 2024

/ok to test

Command Bot: Processing...

@amccaskey amccaskey enabled auto-merge (squash) July 22, 2024 16:49
@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 22, 2024
@amccaskey
Copy link
Collaborator Author

amccaskey commented Jul 22, 2024

/ok to test

Command Bot: Processing...

@github-actions
Copy link

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

@amccaskey amccaskey force-pushed the pyTypePlugin branch 3 times, most recently from 130aff9 to 2f3f5d2 Compare July 26, 2024 19:09
amccaskey added 14 commits July 30, 2024 13:12
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
@amccaskey
Copy link
Collaborator Author

amccaskey commented Jul 31, 2024

/ok to test

Command Bot: Processing...

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

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

@amccaskey
Copy link
Collaborator Author

amccaskey commented Aug 5, 2024

/ok to test

Command Bot: Processing...

@amccaskey amccaskey enabled auto-merge (squash) August 5, 2024 13:31
@amccaskey amccaskey merged commit 1300912 into NVIDIA:main Aug 5, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Aug 5, 2024
@bettinaheim bettinaheim added the enhancement New feature or request label Nov 19, 2024
@bettinaheim bettinaheim added this to the release 0.9.0 milestone Nov 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants