sparse icon indicating copy to clipboard operation
sparse copied to clipboard

GPU support?

Open fujiisoup opened this issue 7 years ago • 7 comments

Cupy provides GPU enabled sparse matrix implementation that has similar APIs to scipy.sparse.

I believe that only a slight modification makes sparse compatible to cupyx.scipy.sparse. Is it in the scope of sparse's development?

The most significant problem I believe is how to prepare a testing framework. Travis does not provide gpu instance. It looks that Cupy's development team has their own server for testing.

fujiisoup avatar Oct 14 '18 20:10 fujiisoup

The problem I have with this approach is that I do not have a CUDA GPU I can use for testing currently. Therefore, maintaining and testing any cupy-specific parts will be close to impossible for me.

I can accept PRs if and only if they do not contain any cupy specific code. The reason isn't the unwillingness to have it; it's the inability to maintain it.

hameerabbasi avatar Oct 14 '18 20:10 hameerabbasi

Thanks, @hameerabbasi.

How about to enable the use of general scipy.sparse-like arrays (and also np.ndarray-like array) in sparse? I think it would have done connection to #86, when we may want sparse stay that had similar api to scipy's sparse.

For API, I am thinking if we could do with the context manager, like

with use_array_modules(cupy, cupyx.scipy.sparse):
    sparse.COO(coords, data)

which uses cupy.ndarray and cupyx.scipy.sparse instead of numpy and scipy.sparse, respectively.

fujiisoup avatar Oct 14 '18 21:10 fujiisoup

I'm currently using Numba for some of the calculations on the NumPy. If Numba doesn't properly support these NumPy-ish arrays, then we run into issues.

I guess we could add this context and only test against NumPy specifically. We would also need to check if the contexts are all the same during a calculation.

I guess my point is it would quickly turn complicated, with very little chance left for me to support it. That said, I'm willing to give it a try if we can have a solid CI setup at the very least.

hameerabbasi avatar Oct 15 '18 09:10 hameerabbasi

If Numba doesn't properly support these NumPy-ish arrays, then we run into issues.

Numba does not support Cupy... OK. It looks the GPU support is a little further away than I expected. Thanks for the information.

fujiisoup avatar Oct 15 '18 11:10 fujiisoup

IIUC Sparse makes use of NumPy arrays to hold the coordinates and data as well as uses it for computation, correct? If so, I wonder to what extent protocols like NEP 18 can get us where we want to go here.

jakirkham avatar May 30 '19 14:05 jakirkham

Numba does not support Cupy...

As a follow-up on this point, you might find this doc interesting. 🙂

jakirkham avatar May 30 '19 14:05 jakirkham

I am currently in a situation where I have a sparse 1D vector and I have been using sparse.COO. Now I have moved to a GPU server and have been implementing cupy. It seems on y'all's site that cupy integration is in the future, but not yet. I have looked into cupyx.scipy.sparse.coo_matrix but it doesn't support 1D vectors. Ideas? The other matrix and vector are cupy, so I'd like to find some answer that results in a cupy compatible array because then I can still use the gpu for this one operation.

crumleyc avatar Mar 03 '20 21:03 crumleyc