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

Cannot attach to the transpose of a np.ndarray #1165

Open
manopapad opened this issue Jan 23, 2025 · 0 comments
Open

Cannot attach to the transpose of a np.ndarray #1165

manopapad opened this issue Jan 23, 2025 · 0 comments

Comments

@manopapad
Copy link
Contributor

Reported by @elliottslaughter

When executing this file:

import numpy as np
import cupynumeric as cn

x = np.ones((4,5))
y = x.transpose()
cn.asarray(y)

we get the following error:

Traceback (most recent call last):
  File "/home/mpapadakis/b/cupynumeric/a.py", line 6, in <module>
    cn.asarray(y)
  File "runtime.pyx", line 1188, in legate.core._lib.runtime.runtime.track_provenance.decorator.wrapper
  File "runtime.pyx", line 1189, in legate.core._lib.runtime.runtime.track_provenance.decorator.wrapper
  File "/home/mpapadakis/b/cupynumeric/cupynumeric/_utils/coverage.py", line 105, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/mpapadakis/b/cupynumeric/cupynumeric/_module/creation_data.py", line 141, in asarray
    thunk = runtime.get_numpy_thunk(a, share=True, dtype=dtype)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mpapadakis/b/cupynumeric/cupynumeric/runtime.py", line 314, in get_numpy_thunk
    return self.find_or_create_array_thunk(obj, transfer)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mpapadakis/b/cupynumeric/cupynumeric/runtime.py", line 416, in find_or_create_array_thunk
    raise NotImplementedError(
NotImplementedError: cuPyNumeric does not currently know how to attach to array views that are not affine transforms of their parent array.

Essentially cuPyNumeric is saying "I can't reverse-engineer how y is derived from x using an affine transformation", but a transpose is an affine transformation, so this is likely a bug in compute_parent_child_mapping.

At a high level, perhaps this check isn't necessary anymore. What cuPyNumeric is trying to avoid is this pattern:

x = np.ones(...)
a = cn.asarray(x[0:10])
b = cn.asarray(x[5:15])

where two different Stores are created by attaching to different pieces of the same ndarray. Instead of attaching to the sub-arrays, cuPyNumeric first attaches to the full x, then creates subregions for a and b.

@lightsighter do you remember why you needed to guard against this? @magnatelee do you expect any issue with current Legate, if you have two Stores created in this fashion?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant