Skip to content

Legate rejects cuPyNumeric array real component #976

@elliottslaughter

Description

@elliottslaughter

The following program fails:

from legate.core.task import task, InputArray
import cupynumeric as cpn

@task
def f(x: InputArray):
    pass

y = cpn.zeros(3, dtype=cpn.complex128)
z = y.real
f(z)

Error:

$ python test_complex.py 
Traceback (most recent call last):
  File "test_complex.py", line 10, in <module>
    f(z)
  File "py_task.pyx", line 228, in legate.core._ext.task.py_task.PyTask.__call__
  File "py_task.pyx", line 198, in legate.core._ext.task.py_task.PyTask.prepare_call
  File "invoker.pyx", line 580, in legate.core._ext.task.invoker.VariantInvoker.prepare_call
  File "invoker.pyx", line 483, in legate.core._ext.task.invoker.VariantInvoker._prepare_params
  File "invoker.pyx", line 420, in legate.core._ext.task.invoker.VariantInvoker._handle_param
TypeError: Argument: 'x' expected one of (<class 'legate.core._lib.data.logical_store.LogicalStore'>, <class 'legate.core._lib.data.logical_array.LogicalArray'>), got <class 'cupynumeric._array.array.ndarray'>

Oddly enough you can work around it by passing z to cpn.array:

from legate.core.task import task, InputArray
import cupynumeric as cpn

@task
def f(x: InputArray):
    pass

y = cpn.zeros(3, dtype=cpn.complex128)
z = y.real
w = cpn.array(z)
f(w)
$ python test_complex2.py

I can't see a reason why Legate should be rejecting the .real component of a complex array when it is already a valid cuPyNumeric array.

$ legate-issue
Python      :  3.12.8 | packaged by conda-forge | (main, Dec  5 2024, 14:24:40) [GCC 13.3.0]
Platform    :  Linux-4.18.0-553.40.1.el8_10.x86_64-x86_64-with-glibc2.28
Legion      :  25.3.0 (commit: 2bef0fe6d5f7fc9f08898b57769930f5de964a6c)
Legate      :  25.3.0.dev37+g79203c03
cuPynumeric :  25.03.00.dev+8.g5fff8e5f
Numpy       :  1.26.4
Scipy       :  1.15.1
Numba       :  (failed to detect)
CTK package :  cuda-version-12.8-h5d125a7_3 (conda-forge)
GPU driver  :  570.86.15
GPU devices :  
  GPU 0: NVIDIA A100-SXM4-40GB
  GPU 1: NVIDIA A100-SXM4-40GB
  GPU 2: NVIDIA A100-SXM4-40GB
  GPU 3: NVIDIA A100-SXM4-40GB

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions