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
568 stars 192 forks source link

Kernels do not take as input a list[list[int]] type object #1809

Open matteobarbieri00 opened 5 months ago

matteobarbieri00 commented 5 months ago

Required prerequisites

Describe the bug

When I pass a list[list[int]] to a cudaq kernel, I get the following error: RuntimeError: error: Cannot infer CUDA-Q type from provided Python type (!cc.stdvec<!cc.stdvec>) I didn't expect this, since in the documentation there are examples where this type is passed to a kernel.

Steps to reproduce the bug

import cudaq
@cudaq.kernel
def test_list_list(a: list[list[int]]):
    qc = cudaq.qvector(3)
    j = 0
    for i in a:
        if i[0] == 1:
            x(qc[j])
        j += 1
    mz(qc)

print(cudaq.sample(test_list_list,[[0,1],[1,0],[1,0]]))

Expected behavior

I expect to get the output {'011' : 1000}.

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

Not a regression

Environment

Suggestions

No response

amccaskey commented 4 months ago

@schweitzpgi @annagrin We need to figure out how to pack the data for recursive stdvec types in OpaqueArguments.h