Hacker News new | ask | show | jobs
by KeplerBoy 636 days ago
One could also "import jax.numpy as jnp". All those libraries have more or less complete implementations of numpy and scipy (i believe CuPy has the most functions, especially when it comes to scipy) functionality.

Also: You can just mix match all those functions and tensors thanks to the __cuda_array_interface__.

3 comments

Jax variables are immutable.

Code written for CuPy looks similar to numpy but very different from Jax.

Ah, well, that's interesting! Does anyone know how cupy manages tensor mutability?
CuPy tensors (or `ndarray`) provide the same semantics as NumPy. In-place operations are permitted.
Ah yes, stumbled over that recently, but the error message is very helpful and it's a quick change.
For those interested in the NumPy/SciPy API coverage in CuPy, here is the comparison table:

https://docs.cupy.dev/en/latest/reference/comparison.html

Indeed, has anyone so far successfully drop-in replaced numpy in a project with this cupy and achieved massive improvements? Because, you know, when dealing with GPU it is very important to actually understand how data flows back and forth to it, not only the algorithmic nature of the code written.

As a sidenote, it is funny how this gets released in 2024, and not in say 2014...

Oh yes, I've personally used CuPy for great speed ups compared to Numpy in radar signal processing. Taking a code that took 30 seconds with NumPy down to 1 second with CuPy. The code basically performed a bunch of math on like 100 MB of data, so the PCIe bottleneck was not a big issue.

Also CuPy was first released in 2015, this post is just a reminder for people that such things exist.

Thank you. Your post is informative, and well grounds the very inappropriate hype in mine.
Yeah, the data managed by cupy generally stays on the GPU and you can control when you get it out pretty straightforwardly. It’s great if most of your work happens in a small number of standard operations. Like matrix operations or Fourier transforms, the sort of thing that cupy will provide for you. You can get custom kernels running through cupy but at some point it’s easier to just write c/c++.
It's because it was not possible to write tons of brain-dead, repetitive code in 2014.

In 2024, with AI you can do these kind of projects very fast.