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

List of list in kernel argument gives error #2627

Open
3 of 4 tasks
marwafar opened this issue Feb 17, 2025 · 1 comment
Open
3 of 4 tasks

List of list in kernel argument gives error #2627

marwafar opened this issue Feb 17, 2025 · 1 comment
Labels
bug Something isn't working python-lang Anything related to the Python CUDA Quantum language implementation

Comments

@marwafar
Copy link
Collaborator

Required prerequisites

  • Consult the security policy. If reporting a security vulnerability, do not report the bug using this form. Use the process described in the policy to report the issue.
  • Make sure you've read the documentation. Your issue may be addressed there.
  • Search the issue tracker to verify that this hasn't already been reported. +1 or comment there if it has.
  • If possible, make a PR with a failing test to give us a starting point to work on!

Describe the bug

import cudaq

my_list=[[0,1],[2,3,4]]

@cudaq.kernel
def kernel(my_list:list[list[int]]):
    q=cudaq.qvector(5)
    
    for list in my_list:
        for idx in list:
            x(q[idx])

counts=cudaq.sample(kernel,my_list)
print(counts)

running the above code gives this error:
RuntimeError: error: Cannot infer CUDA-Q type from provided
Python type (!cc.stdvec<!cc.stdvec>)

Steps to reproduce the bug

import cudaq

my_list=[[0,1],[2,3,4]]

@cudaq.kernel
def kernel(my_list:list[list[int]]):
    q=cudaq.qvector(5)
    
    for list in my_list:
        for idx in list:
            x(q[idx])

counts=cudaq.sample(kernel,my_list)
print(counts)

The issue seems to be with actually calling the kernel. Doing a print(kernel) works, and seems to return valid MLIR

Expected behavior

The kernel should be correctly compiled and apply x gate on all qubits and have 11111 state when print counts.

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

Not a regression

Environment

  • CUDA-Q version: 0.9.1
  • Python version: 3.10
  • C++ compiler:
  • Operating system: Linux

Suggestions

No response

@bebora
Copy link
Contributor

bebora commented Feb 17, 2025

Duplicate of #1809.

@schweitzpgi schweitzpgi added bug Something isn't working python-lang Anything related to the Python CUDA Quantum language implementation labels Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working python-lang Anything related to the Python CUDA Quantum language implementation
Projects
None yet
Development

No branches or pull requests

3 participants