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

array.layout.form touches shape #3018

Closed
lgray opened this issue Feb 12, 2024 · 3 comments
Closed

array.layout.form touches shape #3018

lgray opened this issue Feb 12, 2024 · 3 comments
Labels
bug (unverified) The problem described would be a bug, but needs to be triaged

Comments

@lgray
Copy link
Contributor

lgray commented Feb 12, 2024

Version of Awkward Array

2.6.1

Description and code to reproduce

import awkward as ak

a = ak.Array([1, 2, 3, 4, 5])

layout, report = ak.typetracer.typetracer_with_report(a.layout.form_with_key())

b = ak.Array(layout)

print(report.data_touched, report.shape_touched)

b.layout.form

print(report.data_touched, report.shape_touched)

results in:

[] []
[] ['node0']

Asking for the form shouldn't touch shape.

@lgray lgray added the bug (unverified) The problem described would be a bug, but needs to be triaged label Feb 12, 2024
@lgray
Copy link
Contributor Author

lgray commented Feb 12, 2024

This is what is needed in addition to #3017 to avoid problems with dask's deterministic keys project dask/dask#10905.

Also related: dask/dask#10918 (partial fix that doesn't quite hold)

@agoose77
Copy link
Collaborator

Technically this does require shape because it's a NumpyArray, and NumpyArray's have shapes as part of their type signature. In this case, it's asking for shape[1:], because the outermost length can be unknown. We don't have a way of saying touch_inner_shape, so we have to touch the whole thing.

@agoose77
Copy link
Collaborator

Well, saying that, we could introduce a "fast path" that checks self.data.ndim. This is defined as non-touching because it's "valueless metadata". I think it's the only example of such an operation that doesn't even touch shape; I remember us discussing it recently (and we could git blame that line in _nplikes/typetracer.py to find more discussion if needs be).

e.g.

if self._data.ndim == 1:
    ...
else:
    do_something_with(
        self._data.shape[1:]
    )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug (unverified) The problem described would be a bug, but needs to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants