EuroSciPy 2024

Using the Array API to write code that runs with Numpy, Cupy and PyTorch
08-26, 16:00–17:30 (Europe/Berlin), Room 5

Python code that works with Numpy, Cupy and PyTorch arrays? Use a GPU when possible, but fallback to using a CPU if there is none? We will show you how you can write Python code that can do all of the above. The not so secret ingredient to do this is the Array API. In this workshop you will learn what the Array API is and how to use it to write programs that can take any compatible array as input.


There are many Python libraries to choose from for numerical computing, data science, machine learning and deep learning. A
downside of this diversity is that the API of each of these array libraries is subtly different. This makes it hard to
write code that works with more than one array type. As a result taking advantage of modern hardware, like a GPU, is hard
because you need to handle the differences between Numpy and an array library that supports GPUs.

The Array API standard aims to solve this problem by providing a common API that all compatible libraries support. This means
that you can write code that works no matter what array library is used. And, because there are array libraries with GPU
support, it means you can write Python code that works on CPUs and GPUs!

This workshop will be hands on! This means you need to bring a laptop that has at least Numpy and PyTorch installed on it.
This will let you experience that your code works with either of these libraries. To see the effect of using a GPU you will also
need to either have a laptop that has one or use a service like Google colab.

After a brief introduction and demo we will tackle one or two applications that can be implemented in Numpy and then modified
to use the Array API.

By the end of this workshop you will know how to take Numpy code and modify it so that it is compatible with the Array API.
You will be well equipped to modify existing libraries in the PyData ecosystem or write your own applications.

Material: https://github.com/betatim/sound-array-api-tutorial


Abstract as a tweet

Python code that works with Numpy, Cupy and PyTorch arrays? Use a GPU when possible, but fallback to using a CPU if there is none? We will show you how in this workshop!

Category [High Performance Computing]

Other

Expected audience expertise: Domain

none

Expected audience expertise: Python

some

Public link to supporting material

https://github.com/betatim/sound-array-api-tutorial

See also: Material

I am a scikit-learn core maintainer and work at NVIDIA.

Before working on scikit-learn I helped build mybinder.org and worked on JupyterHub.

Many years ago I was a particle physicist at CERN in Geneva.

This speaker also appears in:

Sebastian has been a NumPy developer for about 10 years now. After a PhD in phsyics he worked at as a postdoc at the Berkeley Institute for Datascience on NumPy as grants byt the Alfred P. Sloan Foundation and the Gordon and Betty Moore Foundation. Since 2022 he has been a software engineer at NVIDIA where he continues to contribute to NumPy.

This speaker also appears in: