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
{{ message }}
Repository navigation
Add Array shuffle / general take using tasks #11257
Implement a shuffle for arrays that can be used as a general take as well.
This is motivated by a groupby like pattern / general take that uses almost random indexes into a single dimension. This currently is done through slicing, which blows up the number of chunks and makes the result mostly unusable. Additionally, it completely overloads the scheduler if you operate a properly random indexer during the actual slicing operation.
Leveraging a shuffle like strategy gives us the option to keep the number of chunks consistent and re-order the array in a way that elements in a dimension are close together if needed.
Every inner list specifies a single group. We could take liberties and squash multiple groups into a single chunk without changing the order. Groupby like patterns could then do a shuffle - map_blocks for transformers or high-cardinality groupby ops.
As a first step, we will implement this using the task-based approach.
I don't think that take_along_axis solves the shuffle problem the way we would want to. We might want to put values from different chunks into the same chunk and potentially reorder between chunks, which won't work with a trivial blockwise based implementation of take_along_axis
Yeah I think take would call this new API under the hood in cases where it makes sense (a sorted take indexer is better suited to just use the current implementation for example). take is also a bit more general (you can select rows into more than one chunk for example), but the application is very very similar
Activity
[-]Array shuffle / general take using tasks[/-][+]Add Array shuffle / general take using tasks[/+]dcherian commentedon Jul 29, 2024
see #11076
phofl commentedon Jul 29, 2024
(precursor: I might be missing something).
I don't think that take_along_axis solves the shuffle problem the way we would want to. We might want to put values from different chunks into the same chunk and potentially reorder between chunks, which won't work with a trivial blockwise based implementation of
take_along_axisdcherian commentedon Jul 29, 2024
Yes I was wrong, we need to optimize
takeinstead oftake_along_axis. See pydata/xarray#9220 (comment)phofl commentedon Jul 29, 2024
Yeah I think take would call this new API under the hood in cases where it makes sense (a sorted take indexer is better suited to just use the current implementation for example). take is also a bit more general (you can select rows into more than one chunk for example), but the application is very very similar
phofl commentedon Aug 6, 2024
shuffle and take have both been merged. shuffle probably needs a follow up, but closing here