-
-
Notifications
You must be signed in to change notification settings - Fork 780
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
[Tracker] Implement all scipy.*
APIs in CuPy
#6324
Comments
This looks great, thanks @kmaehashi!
Note that we're quite likely deprecating this module in SciPy 1.9.0 (see scipy/scipy#15608), so I suggest not working on that. |
Thanks for the info, @rgommers! Updated the list. |
@kmaehashi, RAFT contains hierarchical clustering code as well: #3434. RAFT also contains functions for computing contingency table and sampling from various distributions. Wondering if those might be useful here as well. |
Thanks @cjnolet! Added a link to the issue. |
This is brilliant and interesting! I am Pranav, developer @lfortran, we are trying to compile scipy using LFortran, we are very close, almost got |
Hi @Pranavchiku! Yes, we are rewriting SciPy code into CUDA C/C++. You'll get the idea by exploring our code base under |
Do we need explicit GPU environment, or integrated GPUs work? By integrated I mean Apple GPU that is available with mac m1, m2, etc. chips. |
Discrete GPUs are required, currently we support CUDA and HIP (for AMD). |
Hey, I need non-batched BLAS functions for what I'm working on, so I will be working on implementing those in the near future. Just wondering if there are any thoughts on a best-practices for implementing these. Roughly how I imagine using these functions (collapsible code section):@jit.rawkernel(device=True)
def square(a):
matrix2 = cupyx.jit.local_memory(float, (2, 2)) #I'll also try implementing multi-dimensional local/shared arrays
matrix2[0][0] = a
matrix2[1][1] = a
return cupyx.scipy.linalg.det(matrix2) #can be used in device functions
@jit.rawkernel()
def elementwise_2_x_squared(x, size): #computes 2*x^2, toy example which uses linalg functions
tid = jit.grid(1)
ntid = jit.gridsize(1)
matrix = cupyx.jit.local_memory(float, (2, 2))
for i in range(tid, size, ntid):
stored_val = x[i]
x[i] = square(stored_val)
matrix[0][0] = stored_val
matrix[1][1] = stored_val
x[i] += cupyx.scipy.linalg.det(matrix) #can be used inside raw kernel
c = cp.array([1., 2.])
elementwise_2_x_squared((256,), (256,), (c, 2))
print(c) #should return [2., 8.] The main use case I have is roughly: I have a large array of scalar values (could be hundreds of millions). For each value, I need to generate a (potentially not small) matrix, solve it, and then use the result to compute a scalar output value. For batched code, I would need to store these matrices altogether (potentially hundreds of GB memory - not feasible), while for non-batched, dynamically generated matrices, the memory requirements would just be the scalar values. |
Hello, |
It seems possible to mark |
Also, I wonder if the comparison table (super-useful BTW!) , https://docs.cupy.dev/en/stable/reference/comparison.html#scipy-cupy-apis is updated automatically on a release, or is it manual? Would be great to remove SciPy deprecated items (signal.cmplx_sort, windows from scipy.signal namespace, linalg.tri{l,u} etc) |
Hey all, I was always willing to contribute here and I have my first PR #8305 opened that ports |
Good catch! Updated the list
The page is generated with this tool. Deprecated items are currently listed in cupy/docs/source/_comparison_generator.py Lines 206 to 207 in 1aa70f0
|
Hi @Pranavchiku, thank you for your interest in contributing! We, however, would like to kindly ask all contributors to build and test the branch before submitting a pull request. I understand that there are situations where access to GPUs is difficult but in that case please consider using offerings such as Google Colab. |
Thanks @kmaehashi A couple of comments, now that I looked at this tracker a bit more:
|
Thanks for the suggestions @ev-br!
Absolutely, marked !
Can't really say they are unlikely at all, as we have non-public (undocumented)
Sounds great, marked ❌.
I began to wonder if I could delete it from the list, as the audience is very limited compared to NumPy's I/O routines (e.g.,
Nice, added a link to the Array API support docs! |
Implement GPU version of
scipy.*
functions incupyx.scipy.*
namespace.This is a tracker issue that summarizes the implementation status of each SciPy public module in CuPy. See the comparison table for details.
Legends
List of Modules
scipy.cluster
)scipy.cluster.vq
) (Equivalent of scipy.cluster.vq.kmeans #5947)scipy.cluster.hierarchy
) (Equivalent of scipy.cluster.hierarchy.linkage #3434)scipy.constants
)scipy.fft
)scipy.fftpack
) (note: deprecated, no further development planned)scipy.integrate
) (Numerical Differential Equation Integration #7019)scipy.interpolate
) (Tracker: cupyx.scipy.interpolate #7186)scipy.io
)scipy.io.arff
scipy.io.matlab
scipy.io.wavfile
scipy.linalg
)scipy.linalg.blas
)scipy.linalg.cython_blas
scipy.linalg.lapack
) c.f.cupyx.lapack
scipy.linalg.cython_lapack
scipy.linalg.interpolative
)scipy.ndimage
)scipy.odr
)scipy.optimize
) (Any plans for scipy.optimize? #6112)scipy.signal
) (Tracker: cupyx.scipy.signal #7403)scipy.signal.windows
(Tracker: cupyx.scipy.signal.windows #7404)scipy.sparse
)scipy.sparse.linalg
)scipy.sparse.csgraph
) (Compressed Sparse Graph Routines (scipy.sparse.csgraph
) #2431)scipy.spatial
) (cupyx.scipy.spatial
andcupyx.scipy.spatial.distance
packages #5946)scipy.spatial.distance
) (cupyx.scipy.spatial
andcupyx.scipy.spatial.distance
packages #5946)scipy.spatial.transform
)scipy.special
) (note: planned to be backed by SciPy in future Add complex support for the digamma function #8163)scipy.stats
)scipy.stats.contingency
) (note: RAFT could be used)scipy.stats.distributions
scipy.stats.mstats
) (note: masked arrays unsupported in CuPy)scipy.stats.qmc
)scipy.stats.sampling
) (note: RAFT could be used)Note: Several modules in SciPy such as
scipy.cluster.hierarchy
accepts CuPy ndarrays as inputs through the Array API standard.Starter Task
If you are new to CuPy and wondering where to start, here are some good first things to try. They are relatively simple and independent.
scipy.stats
)scipy.sparse.block_diag
(cupyx.scipy.sparse.block_diag
working with cupy sparse matrix on GPU #7058)scipy.sparse.load_npz
scipy.sparse.save_npz
scipy.constants.*
(hint: most things except for methods can just be borrowed from SciPy)Steps to Contribute
Fork and star ⭐ the CuPy repository 😉
Pick a function you want to work on from any of the modules listed above. You can find the function in the SciPy API Reference to understand what should be implemented. If you want to work on new modules (🥚), first discuss with us on this issue.
Implement a function in your branch. If you need help, join Gitter or just ask for help in this issue.
Don't forget to write a test code!
Build CuPy and run tests to confirm that the function runs fine:
pip install -e . && pytest tests/cupyx_tests/scipy_tests/PATH_TO_YOUR_TEST
See the Contribution Guide for details.
Submit a pull-request to the
main
branch.Note that you will need a GPU environment to develop CuPy.
See also: NumPy API Tracker Issue #6078
The text was updated successfully, but these errors were encountered: