You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Search the issue tracker to check if your feature has already been mentioned or rejected in other issues.
Describe the feature
Some of usage of numpy arrays is not supported yet inside kernel functions. Should we support all of those uses?
numpy arrays of float
Works:
f= [0., 1., 1., 0.]
arr=np.array(f)
# Pass an array as a parameter@cudaq.kerneldeftest_float_array_param(vec : np.ndarray):
f1=veccounts=cudaq.sample(test_float_array_param, arr)
assertlen(counts) ==0
Does not work:
# Capture an array@cudaq.kerneldeftest_float_array_capture():
arr1=arr# cudaq.kernel.ast_bridge.CompilerError: test_kernel_np_array.py:45: error: Invalid type for variable (arr) captured from parent scope (only int, bool, float, complex, and list[int|bool|float|complex] accepted, type was ndarray).# counts = cudaq.sample(test_float_array_capture)# assert len(counts) == 0
Works:
# Define an array of float inside a kernel@cudaq.kerneldeftest_float_array_definition():
f1=np.array([1.0, 0., 0., 1.])
counts=cudaq.sample(test_float_array_definition)
assertlen(counts) ==0
Numpy arrays of complex
Does not work:
# Pass an array of complex as a parameterc= [.70710678+0j, 0., 0., 0.70710678]
arr=np.array(c)
@cudaq.kerneldeftest_complex_array_param(vec : np.ndarray):
arr1=vec# RuntimeError: error: Invalid runtime argument type. Argument of type list[complex] was provided, but list[float] was expected.# counts = cudaq.sample(test_complex_array_param, arr)# assert len(counts) == 0
Does not work:
# Capture an array of complex@cudaq.kerneldeftest_complex_array_capture():
arr1=arr# cudaq.kernel.ast_bridge.CompilerError: test_kernel_np_array.py:80: error: Invalid type for variable (arr) captured from parent scope (only int, bool, float, complex, and list[int|bool|float|complex] accepted, type was ndarray).# counts = cudaq.sample(test_complex_array_capture)# assert len(counts) == 0
Works:
# Define an array of complex inside a kernel@cudaq.kerneldeftest_complex_array_definition():
arr=np.array([1.0+0j, 0., 0., 1.])
counts=cudaq.sample(test_complex_array_definition)
assertlen(counts) ==0
Note
Support c = np.array([...], dtype=np.complex64) and demonstrate with the nvidia target. Also it would be good to test that we raise an exception for the use of complex with nvidia and np.complex64 with FP64 backends (all the other ones).
The text was updated successfully, but these errors were encountered:
Required prerequisites
Describe the feature
Some of usage of numpy arrays is not supported yet inside kernel functions. Should we support all of those uses?
numpy arrays of float
Works:
Does not work:
Works:
Numpy arrays of complex
Does not work:
Does not work:
Works:
Note
Support
c = np.array([...], dtype=np.complex64)
and demonstrate with thenvidia
target. Also it would be good to test that we raise an exception for the use of complex withnvidia
andnp.complex64
with FP64 backends (all the other ones).The text was updated successfully, but these errors were encountered: