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

Unclear error message on passing ndarray to kernels that accept cudaq.State #1814

Open
3 of 4 tasks
annagrin opened this issue Jun 13, 2024 · 0 comments · May be fixed by #1872
Open
3 of 4 tasks

Unclear error message on passing ndarray to kernels that accept cudaq.State #1814

annagrin opened this issue Jun 13, 2024 · 0 comments · May be fixed by #1872
Labels
user experience Issue or PR that significantly impacts user experience
Milestone

Comments

@annagrin
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

Python gives unclear message when I pass a ndarray to a kernel that takers cudaq.State as a parameter"

RuntimeError: error: Cannot infer CUDA-Q type from provided Python type (!cc.ptr<!cc.state>)

Offending code:
  File "/home/annagrin/source/cuda-quantum/program.py", line 24, in <module>
    counts = cudaq.sample(kernel, c)

Steps to reproduce the bug

import cudaq
import numpy as np

c = np.array([1, 2j, 3, 4j, 5, 6j, 7, 8j], dtype=np.complex64)

@cudaq.kernel
def kernel(vec: cudaq.State):
    q = cudaq.qvector(vec)

counts = cudaq.sample(kernel, c)

Expected behavior

A better error message would mention the actual type (ndarray) not matching the formal type (cudaq.State)

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

Not a regression

Environment

  • CUDA Quantum version:
  • Python version:
  • C++ compiler:
  • Operating system:

Suggestions

No response

@1tnguyen 1tnguyen linked a pull request Jul 1, 2024 that will close this issue
@bettinaheim bettinaheim added the user experience Issue or PR that significantly impacts user experience label Jul 1, 2024
@bettinaheim bettinaheim added this to the release 0.8.0 milestone Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
user experience Issue or PR that significantly impacts user experience
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants