Skip to content

Dask.Array to support cupy.sparse arrays #5604

Closed

Description

@cjnolet

While attempting to demonstrate the use of cupy.sparse arrays underneath Dask.Array, I found that cupy.sparse doesn't yet have vstack or hstack functions for concatenating sparse arrays. I have filed issue [1] with the cupy project.

Once this has been implemented, the corresponding concatenate function will need to be registered within Dask. I adapted the following code block from the scipy.sparse concatenate_lookup function.

@concatenate_lookup.register_lazy("cupyx")
def register_cupyx():
    import cupyx 
    import cupy

    def _concat_cupy_sparse(L, axis=0):
        if axis == 0:
            return cupy.sparse.vstack(L)
        elif axis == 1:
            return cupy.sparse.hstack(L)
        else:
            msg = (
                "Can only concatenate cupy sparse matrices for axis in "
                "{0, 1}.  Got %s" % axis
            )
            raise ValueError(msg)

    concatenate_lookup.register(cupyx.scipy.sparse.spmatrix, _concat_cupy_sparse)

[1] cupy/cupy#2655

Activity

  1. mrocklin commented on Nov 22, 2019

    @mrocklin
    Member

    This also came up recently in scverse/scanpy#921

  2. mrocklin commented on Nov 22, 2019

    @mrocklin
    Member

    I noticed that you volunteered to help resolve this on the cupy side. Thanks @cjnolet . I'm looking forward to seeing this work. It's nice seeing all of the Numpy implementations converge a bit. (cc @stefanv )

  3. jakirkham commented on Mar 9, 2020

    @jakirkham
    Member

    This is being attempted in PR ( #5735 ).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions