NVIDIA / cuda-quantum

C++ and Python support for the CUDA Quantum programming model for heterogeneous quantum-classical workflows
https://nvidia.github.io/cuda-quantum/
Other
486 stars 179 forks source link

Some gates not available in new Python syntax #2223

Open zohimchandani opened 1 week ago

zohimchandani commented 1 week ago

Required prerequisites

Describe the bug

This works:

import cudaq 

n_qubits = 2
params_vals = [1,2,3]

kernel, params = cudaq.make_kernel(list)
q = kernel.qalloc(n_qubits)

kernel.givens_rotation(params[1], q[0], q[1])
kernel.fermionic_swap(params[2], q[0], q[1])

result = cudaq.sample(kernel, params_vals)

print(result)

This does not:

import cudaq 
from typing import List

n_qubits = 2 
params_vals = [1,2,3]

@cudaq.kernel()
def kernel(params: List[int]):

    q = cudaq.qvector(n_qubits)

    givens_rotation(params[1], q[0], q[1])
    fermionic_swap(params[2], q[0], q[1])

result = cudaq.sample(kernel, params_vals)
print(result)
CompilerError: 582779219.py:12: error: unhandled function call - givens_rotation, known kernels are dict_keys(['kernel'])
     (offending source -> givens_rotation(params[1], q[0], q[1]))

Can we add support for these gates and document them please?

Steps to reproduce the bug

NA

Expected behavior

NA

Is this a regression? If it is, put the last known working version (or commit) here.

Not a regression

Environment

Suggestions

NA