autoray
Abstract your array operations.
What it is and what it does
Autoray is a lightweight library that lets you write array code once and run it on any NumPy-compatible tensor backend. Instead of writing separate code paths for NumPy, PyTorch, JAX, CuPy, and other array libraries, you call `ar.do()` with a function name and let autoray route the call to the right backend based on the input array type. It also provides a drop-in NumPy-like interface and utilities for registering custom backends and functions.
The library solves the problem of backend lock-in: if you build a numerical algorithm in NumPy but later want to run it on GPU with CuPy or use JAX for automatic differentiation, you can do so without rewriting your core logic. It's particularly useful for library authors who want to support multiple backends without maintaining separate implementations.
Use it for:
- Write numerical algorithms that work on CPU (NumPy) or GPU (CuPy/PyTorch) without code duplication.
- Build libraries that support multiple tensor backends without explicit backend-specific branches.
- Migrate existing NumPy code to JAX or PyTorch by swapping the backend without rewriting function calls.
- Lazy evaluation and computation tracing across different backends using autoray's abstraction layer.
- Register custom tensor types or backend-specific optimizations while keeping the main algorithm backend-agnostic.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Autoray provides automatic dispatch of array operations across multiple tensor backends (NumPy, PyTorch, JAX, CuPy, MLX, Dask, TensorFlow, and others) without requiring backend-specific code.
Yes. Autoray is actively maintained, has no dependencies, installs cleanly, and solves a real problem for anyone writing numerical code that might need to run on multiple tensor backends. The permissive Apache license and support for current Python versions make it a low-risk addition. Install it if you're building libraries or algorithms that should work across NumPy, PyTorch, JAX, or other array-like libraries.
Install
autoray on PyPI
pip
pip install autorayuv
uv add autoraypoetry
poetry add autorayInstalling autoray
Before you install
Low friction installation with no runtime dependencies. Active maintenance with a release 7 days ago and recent commits; the project has been stable since its 2019 inception.
License in practice
Apache-2.0 permissive license allows use in commercial and proprietary projects with minimal restrictions.
Quickstart
import autoray as ar
# Automatic dispatch based on array type
U, s, VH = ar.do("linalg.svd", x)
# Or use the numpy-like interface
from autoray import numpy as np
z = np.ones((3, 4))
Requires Python 3.11 or later.
Verify before relying
- Whether performance overhead of dispatch is negligible for tight loops or compute-heavy workloads.
- Completeness of coverage for less common NumPy functions across all supported backends.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.11) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 7 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 658,067/month — #5,472 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: autoray-0.10.1-py3-none-any.whl
Keywords: agnostic, array, autograd, cupy, dask, dispatch, jax, mlx, numeric, numpy, tensor, tensorflow
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
tensorlyTensorLy performs tensor decomposition, tensor…
permissive · top 15,000 on PyPI
array-api-compatProvides a unified wrapper around NumPy, CuPy,…
permissive · top 5,000 on PyPI
einxeinx provides a universal notation for…
permissive · top 5,000 on PyPI
pyversPyvers provides dynamic dispatch for Python…
permissive · top 5,000 on PyPI
array-api-strictProvides a strict, minimal implementation of…
permissive · top 15,000 on PyPI
torchPyTorch provides GPU-accelerated tensor…
permissive · top 1,000 on PyPI
jaxtypingProvides type annotations and runtime…
permissive · top 5,000 on PyPI
einopsEinops provides readable tensor operations…
permissive · top 1,000 on PyPI
etilsA modular collection of utility submodules for…
permissive · top 5,000 on PyPI
mlxMLX is an array framework for machine learning…
permissive · top 5,000 on PyPI