Hi,
The Array API standard aims to standardize a common subset of functionality of the majority of array libraries, such as NumPy, PyTorch, CuPy and JAX, with a view to remedy the fragmentation of the array computing ecosystem caused by the accumulated divergences among these—almost, but not completely dissimilar—array/tensor libraries.
Adopting the Array API standard in scikit-image gives users flexibility in choosing their software stack for array computing, and [enables performance improvements] (https://labs.quansight.org/blog/array-api-meta-blogposts) from using low-level implementations of hardware accelerated algorithms.
Much of scikit-image relies on computational kernels written in Cython. An immediate concern is whether adopting the Array API brings meaningful benefits—these handwritten kernels are and will remain being NumPy-only, while the majority of gains reported from Array API adoption are from using hardware accelerators.
First of all, to an extent of scikit-image using scipy.ndimage, the latter does benefit from GPU execution for CuPy arrays, today. This way, scikit-image functions which call scipy.ndimage functions and have their internals Array API compatible, use CUDA automatically for CuPy array inputs.
More generally, Array API compatibility gives a generic framework for, and implements the foundational infrastructure of, dispatching to specialized accelerator-enabled implementations (such as CUCIM and similar GPU libraries). Specific details of the dispatching can take multiple forms, there are several implementations in different libraries, and there are multiple further ideas floating around. What the Array API compatibility provides however, is a general and ecosystem-aligned framework for working through these (both fascinating and difficult) details.
Here is
-
a draft SKIP for adopting the Array API in scikit-image, as a PR, and in a rendered form.
-
a POC/WIP/demo level implementation which brings Array API compatibility to one function,
skimage2.metrics.structured_similarity
Thoughts? Comments?
I know it’s a large topic with quite a bit of history, and it comes in the midst of the skimage2 transition. Either way, I’d be happy to go into details, either large-scale or smaller items, to see if this is something y’all would be interested in.
Cheers,
Evgeni