nv-legate / cunumeric

An Aspiring Drop-In Replacement for NumPy at Scale
https://docs.nvidia.com/cunumeric/24.06/
Apache License 2.0
621 stars 70 forks source link

`contract` doesn't work with integer types #564

Open ipdemes opened 2 years ago

ipdemes commented 2 years ago

Following test doesn't work with cuNumeric: a = [[1, 0], [0, 1]] b = [[4, 1], [2, 2]] c=np.dot(a, b)

It produces error:

Traceback (most recent call last):
  File "/home/idemeshko/install/legate/lib/python3.10/site-packages/legion_top.py", line 440, in legion_python_main
    run_path(args[start], run_name='__main__')
  File "/home/idemeshko/install/legate/lib/python3.10/site-packages/legion_top.py", line 255, in run_path
    exec(code, module.__dict__, module.__dict__)
  File "tests/integration/test_reproduce.py", line 11, in <module>
    c=np.dot(a, b)
  File "/home/idemeshko/development/cunumeric_ai_kernel_fix/cunumeric/coverage.py", line 110, in wrapper
    return func(*args, **kwargs)
  File "/home/idemeshko/development/cunumeric_ai_kernel_fix/cunumeric/array.py", line 143, in wrapper
    return func(*args, **kwargs)
  File "/home/idemeshko/development/cunumeric_ai_kernel_fix/cunumeric/module.py", line 3561, in dot
    return a.dot(b, out=out)
  File "/home/idemeshko/development/cunumeric_ai_kernel_fix/cunumeric/coverage.py", line 110, in wrapper
    return func(*args, **kwargs)
  File "/home/idemeshko/development/cunumeric_ai_kernel_fix/cunumeric/array.py", line 143, in wrapper
    return func(*args, **kwargs)
  File "/home/idemeshko/development/cunumeric_ai_kernel_fix/cunumeric/array.py", line 2540, in dot
    return _contract(
  File "/home/idemeshko/development/cunumeric_ai_kernel_fix/cunumeric/module.py", line 4009, in _contract
    c._thunk.contract(
  File "/home/idemeshko/development/cunumeric_ai_kernel_fix/cunumeric/deferred.py", line 116, in wrapper
    return func(*args, **kwargs)
  File "/home/idemeshko/development/cunumeric_ai_kernel_fix/cunumeric/deferred.py", line 1484, in contract
    raise TypeError(f"Unsupported type: {lhs_thunk.dtype}")
TypeError: Unsupported type: int64

It seems like supported_dtypes do not include integer types.

manopapad commented 2 years ago

Yes, unfortunately the tensor/BLAS libraries we use (tblis, cutensor, openblas, cublas) don't support integer datatypes. We would have to write custom implementations for integers.

ipdemes commented 2 years ago

I see, so this is a known issue. Should we then change the error message to "int 64 type is not currently supported by CuNumeric contract method used in dot/multiply" ?

manopapad commented 2 years ago

Sure, please make a PR with your suggestion. Note that a number of functions go through module.py:_contract (e.g. einsum, tensordot), so you wouldn't want the error message there to refer to specifically dot/multiply.