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

Support cudaq.qvector for the multi-qubit custom op #2484

Open
1 task done
Squirtle007 opened this issue Dec 19, 2024 · 1 comment
Open
1 task done

Support cudaq.qvector for the multi-qubit custom op #2484

Squirtle007 opened this issue Dec 19, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@Squirtle007
Copy link

Required prerequisites

  • Search the issue tracker to check if your feature has already been mentioned or rejected in other issues.

Describe the feature

Extended from ticket #1475

Problem
Accepting cudaq.qvector to provide flexibility and convenience for multi-qubit custom op within a kernel.

Description
Now in v0.9.1, error: invalid number of arguments occurs when the code below is executed with cudaq.draw, cudaq.sample, etc:

num_qubits = 2
cudaq.register_operation("custom_op", np.identity(2**num_qubits))

@cudaq.kernel
def kernel(num_qubits: int):
    qubits = cudaq.qvector(num_qubits)
    custom_op(qubits)  # Doesn't work

Then we need to manually pass the qubits (or cudaq.qubit) one by one:

@cudaq.kernel
def kernel(num_qubits: int):
    qubits = cudaq.qvector(num_qubits)
    custom_op(qubits[0], qubits[1])

Same for the ctrl method if cudaq.qvector is involved:

num_qubits = 2
cudaq.register_operation("custom_op", np.identity(2**num_qubits))

@cudaq.kernel
def kernel(num_qubits: int):
    qubits = cudaq.qvector(num_qubits+1)
    custom_op.ctrl(qubits[0], qubits[1:3])  # Doesn't work
@Squirtle007 Squirtle007 added the enhancement New feature or request label Dec 19, 2024
@Squirtle007
Copy link
Author

An error is not thrown when attempting to broadcast a custom unitary to a vector #2452.
But it would be great to support passing cudaq.qvector to a custom op.

@Squirtle007 Squirtle007 reopened this Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant