Skip to content

Use numba automatically for numpy inputs and deprecate the backend argument - #178

Merged
frazane merged 9 commits into
mainfrom
array-api/p4-auto-numba
Nov 8, 2026
Merged

frazane merged 9 commits into
mainfrom
array-api/p4-auto-numba

Conversation

@frazane

@frazane frazane commented Nov 8, 2026

Copy link
Copy Markdown
Owner

The array framework is inferred from the inputs since the array API migration, which left the backend argument with one real job: opting into numba. With the gufuncs now faster than the array path, loaded lazily and guarded against inputs they do not support, numba becomes an automatic accelerator for numpy inputs and the backend argument is deprecated.

What changed

  • New set_config, get_config and config_context with numba="auto" (default), True or False. "auto" uses a gufunc when numba is installed, the inputs are plain numpy and the score is not excluded; True always uses one; False never does. config_context is scoped with a ContextVar, and the SCORINGRULES_NUMBA environment variable sets the initial value.
  • A small exclusion table keeps weighted_interval_score (until weighted_interval_score adds w_median * median instead of w_median * |obs - median| on all non-numba backends #140 is fixed) and the akr estimators of gksuv_ensemble for float32 on the array path in auto mode.
  • Every backend value warns with a DeprecationWarning pointing at the caller. backend="numba" still forces numba for that call, the other values are ignored. backends.set_active("numba") and set_active("numpy") warn and map to numba=True and numba=False.
  • Bool data now takes the array path in every mode, so a call behaves the same with or without numba installed.
  • Auto mode is silent without numba and only imports numba on a call that runs a gufunc. A numba that is installed but fails to import gives one RuntimeWarning, then the array path.
  • The test suite selects paths with config_context, and the parity helper checks numba=True, auto and False, including that auto takes the gufunc unless the exclusion table says otherwise.

Notes

Score docstrings and the user guide are updated in the next PR. The dispatch decision costs about 1.6 us per call; crps_ensemble at N=10 drops from 38 us to 14 us in auto mode. config_context does not reach work sent to thread pools or dask's threaded scheduler; the docstring says to use set_config there.


This change was developed in tandem with AI coding agents.

@github-actions github-actions Bot added documentation Improvements or additions to documentation core Core scoring API / numerics ci CI, tooling, repo automation labels Nov 8, 2026
@frazane
frazane merged commit aca5cc3 into main Nov 8, 2026
27 checks passed
@frazane
frazane deleted the array-api/p4-auto-numba branch November 8, 2026 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci CI, tooling, repo automation 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