Skip to content

Adopt the array API standard: foundation + CRPS pilot#133

Open
frazane wants to merge 26 commits into
mainfrom
array-api-adoption
Open

Adopt the array API standard: foundation + CRPS pilot#133
frazane wants to merge 26 commits into
mainfrom
array-api-adoption

Conversation

@frazane

@frazane frazane commented Jun 7, 2026

Copy link
Copy Markdown
Owner

First phase of the array API migration (Part of #132): replaces the hand-written ArrayBackend abstraction with the Python array API standard via array-api-compat, inferring the framework from the input arrays, and migrates the CRPS family end-to-end as the pilot.

Infrastructure

  • New array-api-compat dependency.
  • The array framework is inferred from the input arrays through a new namespace layer (get_namespace, augmented ArrayAPINamespace) — pass numpy/jax/torch arrays and the result comes back in the same framework, no configuration.
  • A native-first extension layer supplies the special functions the standard lacks (erf, gamma, betainc, …), dispatching to jax.scipy.special / torch.special / scipy.
  • numba's compiled gufuncs remain an explicit, opt-in fast path via backend="numba".

CRPS family

  • All crps_* public wrappers and the CRPS core numerics are migrated to the inferred-namespace dispatch.

Deprecations and behavior changes

  • backend="numpy"/"jax"/"torch" and register_backend / backends.set_active(...) for array-API frameworks are deprecated; inference replaces them. backend="numba" is unaffected.
  • Mixed-framework inputs (e.g. a numpy observation with a torch forecast) now raise a clear error.
  • The default no longer routes through numba: interval_score and crps_quantile previously defaulted to gufuncs and now require backend="numba" to opt in.
  • torch has no native betainc / hyp2f1 / expi; scores needing those raise NotImplementedError for torch inputs (pass numpy or jax instead).

Testing

Full suite green across numpy, numba, jax, and torch (705 passed, 16 skipped). CRPS tests exercise native arrays per framework and assert the inferred backend so a misrouted score can't silently fall back to numpy; added gradient tests for jax and torch.

frazane added 26 commits June 7, 2026 01:08
@github-actions github-actions Bot added documentation Improvements or additions to documentation core Core scoring API / numerics labels Jun 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core scoring API / numerics documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant