Skip to content

dask deterministic hashing #300

Description

@crusaderky

sparse.COO should implement dask deterministic hashing:
https://docs.dask.org/en/latest/custom-collections.html#deterministic-hashing

The current situation is that dask falls back on a random uuid4:

>>> import dask.array
>>> import numpy
>>> import sparse
>>> a = numpy.array([1,2])
>>> sa = sparse.COO(a)
>>> dask.array.from_array(a).__dask_keys__()
[('array-de932becc43e72c010bc91ffefe42af1', 0)]
>>> dask.array.from_array(a).__dask_keys__()                                                                                                                                                                                                              
[('array-de932becc43e72c010bc91ffefe42af1', 0)]
>>> dask.array.from_array(sa).__dask_keys__()                                                                                                                                                                                                              
[('array-77964bd4315f9a3eb43953586a91d273', 0)]
>>> dask.array.from_array(sa).__dask_keys__()                                                                                                                                                                                                             
[('array-cf0d4b78cf3a2b277c351ea3d534a790', 0)]

Suggested implementation:

class COO:
    def __dask_tokenize__(self):
        from dask.base import normalize_token
        return normalize_token((type(self), self.coords, self.data, self.shape, self.fill_value))

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions