Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Vision

1. Motivation

Real scientific pipelines run on a mix of backends. The same NDVI computation might run on NumPy in a notebook, on JAX during model training, on CuPy in a GPU-attached inference service, and on dask for a cluster batch job. Writing four versions of the same operator (one per backend) is the wrong path. Writing one version against a specific backend (say NumPy) and then calling .cpu().numpy() everywhere else is slower, error-prone, and breaks gradient flow.

The Python Array API standard is the modern, formal answer. Every conforming array implements __array_namespace__(), which returns a module-like object with mean, sum, reshape, where, … exposed as functions. Five major libraries (NumPy 2.0+, JAX, CuPy, PyTorch 2.0+ and dask) conform, fully or substantially. pipekit-array is the package that wraps the ~12 array-shaped operators we keep rewriting (ApplyAlong, Subsample, AssertClose, AssertValueRange, ModelOp, …) against array_namespace(x), so the operator picks its backend from the input.

What is missing from pipekit-ops is a place for these operators to live. The QC operators of pipekit_ops.operators deliberately stay carrier-agnostic; their module docstring says that numeric checks (AssertValueRange, AssertNoNaN) “live in sister libraries (Report 3, pipekit-array)”. pipekit_ops.observe.Histogram ships a generic controller with a user-supplied to_array adapter, and pipekit-array would ship the carrier-aware version, where to_array defaults to the Array API’s flatten path. The boundary is already drawn, and this package is the thing on the other side.

As built (0.3.1). The data-flow operators (ApplyAlong, StackAlong, ConcatenateAlong, MeanScalar, BatchAlong) ship, and Subsample was retired in favour of isel with a stepped slice (ADR A15). The QC family, the array Histogram and ModelOp are not built yet. The package grew a second surface the original plan did not have: the named carrier DimArray and the dim-level functions of Dim-level functions: the missing ones, which work by dim name on any registered carrier.

2. What pipekit-array is

A thin, dependency-light library: pipekit-array depends on pipekit-ops and nothing else by default. Backends are extras (pipekit-array[numpy], [jax], [torch], [cupy], [dask]), and so are the integrations ([xarray], [sklearn], [einx], [compat]). Backend availability is determined at call time from the input: array_namespace(x) raises TypeError if x does not implement __array_namespace__ (no Array-API-conforming backend is installed for the input’s type). Operators themselves construct without needing any backend, which is the whole point of dispatching on the input.

Three conceptual layers, all on top of pipekit_ops.Operator:

Every operator follows the same shape: _apply(x, …) calls array_namespace(x) to pick the backend, calls the Array API functions, and returns an array of the same backend. There is no conversion, no .cpu() and no .numpy().

3. Design principles

These echo pipekit-train’s principles and extend them to the array-carrier setting:

4. Where pipekit-array sits in the stack

┌────────────────────────────────────────────────────┐
│                Domain libraries                    │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────┐  │
│  │  geotoolz    │  │   xr_toolz   │  │  others  │  │
│  │ (GeoTensor)  │  │   (xarray)   │  │   ...    │  │
│  └──────┬───────┘  └──────┬───────┘  └────┬─────┘  │
│         └────────┬────────┴───────────────┘        │
│                  ▼                                 │
│         ┌─────────────────┐                        │
│         │  pipekit-array  │  ← duck-typed arrays   │
│         │  (Array API)    │     (numpy/JAX/torch…) │
│         └────────┬────────┘                        │
│                  ▼                                 │
│         ┌─────────────────┐                        │
│         │   pipekit-ops   │  ← carrier-agnostic    │
│         │     (core)      │     framework          │
│         └─────────────────┘                        │
└────────────────────────────────────────────────────┘

5. The Array API bet: what works, what doesn’t

The Array API standard is well defined for the operations pipekit-array needs (basic maths, reductions, reshapes, indexing, concatenation). It is not well defined for:

These constraints are known, documented and small enough that they do not motivate per-backend libraries. One library covers all five backends with disciplined operator design.

6. Out of scope

These were explicitly considered and rejected for the v0.1 scope.

Boundary cases are catalogued in Boundaries.