Catalog PyPI
PACKAGE EXPLORERView in registry

acai-control

PyPI

Backend-independent array control-flow primitives

Versions collected1
Direct dependencies2From release 0.1.0
Last observed20 Oct, 17:51 UTC

README

Version 0.1.0 documentation

acai

Array Control-flow And Iteration: small, backend-independent control-flow primitives for code written with the Python Array API ecosystem.

Installation

Install acai with:

pip install acai-control

Array backends such as NumPy, CuPy, JAX, and PyTorch are not installed by acai-control. array-api-compat provides namespace inference and backend detection, while Optree provides pytree traversal.

Usage

The acai namespace provides four main functions:

  • cond: Apply one of two functions according to a scalar predicate.
  • fori_loop: Apply a function over an integer range.
  • scan: Scan a function over arrays while carrying state.
  • while_loop: Apply a function repeatedly while a condition is true.

The basic usage is:

import numpy as np
from array_api_compat import array_namespace

from acai import cond, fori_loop, scan, while_loop

x = np.asarray(1)
xp = array_namespace(x)

# 1 * 2 * 3 * 4 * 5
factorial = fori_loop(1, 6, lambda i, value: value * i, x, xp=xp)

# The namespace may also be inferred from an array carry.
power_of_two = while_loop(lambda value: value < 16, lambda value: value * 2, x)

# Select one branch without losing staged control flow on JAX.
magnitude = cond(x >= 0, lambda value: value, lambda value: -value, x, xp=xp)

# Accumulate values and collect every intermediate total.
total, cumulative = scan(
    lambda carry, value: (carry + value, carry + value),
    np.asarray(0),
    np.asarray([1, 2, 3]),
)

Implementation details

The loop functions use ordinary Python loops for NumPy, CuPy, and PyTorch. For JAX, they dispatch to jax.lax.while_loop and jax.lax.fori_loop, so loops remain staged under jax.jit. Likewise, cond uses ordinary Python branching except on JAX, where it dispatches to jax.lax.cond. scan uses eager iteration and stacking except on JAX, where it dispatches directly to jax.lax.scan.

PyTorch

PyTorch arrays are supported through eager Python control flow. PyTorch's native structured control-flow primitives are currently prototype features, so acai does not dispatch to them. Consequently, its control flow is not guaranteed to remain structured under torch.compile.

Dask and ndonnx

Dask arrays and ndonnx symbolic arrays are not currently supported. All primitives raise NotImplementedError when given either namespace.

Python Array API standard

acai is not part of the Python Array API standard and is not affiliated with array-api-compat or array-api-extra.

Downloads & popularity

1downloads
1-day window · source-reported counts18 Oct 2026
12964.50
2026-08-11: 103 · observed 2026-10-20T22:08:03.4359476Z · period 2026-08-11–2026-08-112026-08-12: 9 · observed 2026-10-20T22:08:03.4359476Z · period 2026-08-12–2026-08-122026-08-13: 2 · observed 2026-10-20T22:08:03.4359476Z · period 2026-08-13–2026-08-132026-08-14: 4 · observed 2026-10-20T22:08:03.4359476Z · period 2026-08-14–2026-08-142026-08-15: 3 · observed 2026-10-20T22:08:03.4359476Z · period 2026-08-15–2026-08-152026-08-17: 5 · observed 2026-10-20T22:08:03.4359476Z · period 2026-08-17–2026-08-172026-08-18: 23 · observed 2026-10-20T22:08:03.4359476Z · period 2026-08-18–2026-08-182026-08-20: 30 · observed 2026-10-20T22:08:03.4359476Z · period 2026-08-20–2026-08-202026-08-21: 67 · observed 2026-10-20T22:08:03.4359476Z · period 2026-08-21–2026-08-212026-08-23: 3 · observed 2026-10-20T22:08:03.4359476Z · period 2026-08-23–2026-08-232026-08-24: 66 · observed 2026-10-20T22:08:03.4359476Z · period 2026-08-24–2026-08-242026-08-25: 3 · observed 2026-10-20T22:08:03.4359476Z · period 2026-08-25–2026-08-252026-08-27: 18 · observed 2026-10-20T22:08:03.4359476Z · period 2026-08-27–2026-08-272026-08-28: 4 · observed 2026-10-20T22:08:03.4359476Z · period 2026-08-28–2026-08-282026-08-29: 4 · observed 2026-10-20T22:08:03.4359476Z · period 2026-08-29–2026-08-292026-08-31: 2 · observed 2026-10-20T22:08:03.4359476Z · period 2026-08-31–2026-08-312026-09-01: 18 · observed 2026-10-20T22:08:03.4359476Z · period 2026-09-01–2026-09-012026-09-02: 36 · observed 2026-10-20T22:08:03.4359476Z · period 2026-09-02–2026-09-022026-09-03: 23 · observed 2026-10-20T22:08:03.4359476Z · period 2026-09-03–2026-09-032026-09-04: 21 · observed 2026-10-20T22:08:03.4359476Z · period 2026-09-04–2026-09-042026-09-06: 3 · observed 2026-10-20T22:08:03.4359476Z · period 2026-09-06–2026-09-062026-09-07: 6 · observed 2026-10-20T22:08:03.4359476Z · period 2026-09-07–2026-09-072026-09-08: 129 · observed 2026-10-20T22:08:03.4359476Z · period 2026-09-08–2026-09-082026-09-09: 4 · observed 2026-10-20T22:08:03.4359476Z · period 2026-09-09–2026-09-092026-09-10: 45 · observed 2026-10-20T22:08:03.4359476Z · period 2026-09-10–2026-09-102026-09-11: 23 · observed 2026-10-20T22:08:03.4359476Z · period 2026-09-11–2026-09-112026-09-12: 8 · observed 2026-10-20T22:08:03.4359476Z · period 2026-09-12–2026-09-122026-09-13: 1 · observed 2026-10-20T22:08:03.4359476Z · period 2026-09-13–2026-09-132026-09-14: 38 · observed 2026-10-20T22:08:03.4359476Z · period 2026-09-14–2026-09-142026-09-15: 14 · observed 2026-10-20T22:08:03.4359476Z · period 2026-09-15–2026-09-152026-09-16: 9 · observed 2026-10-20T22:08:03.4359476Z · period 2026-09-16–2026-09-162026-09-17: 3 · observed 2026-10-20T22:08:03.4359476Z · period 2026-09-17–2026-09-172026-09-18: 30 · observed 2026-10-20T22:08:03.4359476Z · period 2026-09-18–2026-09-182026-09-20: 2 · observed 2026-10-20T22:08:03.4359476Z · period 2026-09-20–2026-09-202026-09-21: 3 · observed 2026-10-20T22:08:03.4359476Z · period 2026-09-21–2026-09-212026-09-22: 2 · observed 2026-10-20T22:08:03.4359476Z · period 2026-09-22–2026-09-222026-09-23: 1 · observed 2026-10-20T22:08:03.4359476Z · period 2026-09-23–2026-09-232026-09-25: 5 · observed 2026-10-20T22:08:03.4359476Z · period 2026-09-25–2026-09-252026-09-26: 4 · observed 2026-10-20T22:08:03.4359476Z · period 2026-09-26–2026-09-262026-09-27: 2 · observed 2026-10-20T22:08:03.4359476Z · period 2026-09-27–2026-09-272026-09-28: 2 · observed 2026-10-20T22:08:03.4359476Z · period 2026-09-28–2026-09-282026-09-29: 1 · observed 2026-10-20T22:08:03.4359476Z · period 2026-09-29–2026-09-292026-09-30: 4 · observed 2026-10-20T22:08:03.4359476Z · period 2026-09-30–2026-09-302026-10-01: 2 · observed 2026-10-20T22:08:03.4359476Z · period 2026-10-01–2026-10-012026-10-02: 5 · observed 2026-10-20T22:08:03.4359476Z · period 2026-10-02–2026-10-022026-10-05: 2 · observed 2026-10-20T22:08:03.4359476Z · period 2026-10-05–2026-10-052026-10-06: 1 · observed 2026-10-20T22:08:03.4359476Z · period 2026-10-06–2026-10-062026-10-07: 1 · observed 2026-10-20T22:08:03.4359476Z · period 2026-10-07–2026-10-072026-10-08: 3 · observed 2026-10-20T22:08:03.4359476Z · period 2026-10-08–2026-10-082026-10-09: 9 · observed 2026-10-20T22:08:03.4359476Z · period 2026-10-09–2026-10-092026-10-10: 4 · observed 2026-10-20T22:08:03.4359476Z · period 2026-10-10–2026-10-102026-10-12: 4 · observed 2026-10-20T22:08:03.4359476Z · period 2026-10-12–2026-10-122026-10-13: 9 · observed 2026-10-20T22:08:03.4359476Z · period 2026-10-13–2026-10-132026-10-14: 4 · observed 2026-10-20T22:08:03.4359476Z · period 2026-10-14–2026-10-142026-10-15: 5 · observed 2026-10-20T22:08:03.4359476Z · period 2026-10-15–2026-10-152026-10-17: 3 · observed 2026-10-20T22:08:03.4359476Z · period 2026-10-17–2026-10-172026-10-18: 1 · observed 2026-10-20T22:08:03.4359476Z · period 2026-10-18–2026-10-18
11 Aug18 Oct

pypistats · 57 observations shown. Missing days are unknown. Source category: overall: without mirrors.

View observed values
Date / source periodValueObserved at
2026-10-18 – 2026-10-1812026-10-20T22:08:03.4359476Z
2026-10-17 – 2026-10-1732026-10-20T22:08:03.4359476Z
2026-10-15 – 2026-10-1552026-10-20T22:08:03.4359476Z
2026-10-14 – 2026-10-1442026-10-20T22:08:03.4359476Z
2026-10-13 – 2026-10-1392026-10-20T22:08:03.4359476Z
2026-10-12 – 2026-10-1242026-10-20T22:08:03.4359476Z
2026-10-10 – 2026-10-1042026-10-20T22:08:03.4359476Z
2026-10-09 – 2026-10-0992026-10-20T22:08:03.4359476Z
2026-10-08 – 2026-10-0832026-10-20T22:08:03.4359476Z
2026-10-07 – 2026-10-0712026-10-20T22:08:03.4359476Z
2026-10-06 – 2026-10-0612026-10-20T22:08:03.4359476Z
2026-10-05 – 2026-10-0522026-10-20T22:08:03.4359476Z
2026-10-02 – 2026-10-0252026-10-20T22:08:03.4359476Z
2026-10-01 – 2026-10-0122026-10-20T22:08:03.4359476Z
2026-09-30 – 2026-09-3042026-10-20T22:08:03.4359476Z
2026-09-29 – 2026-09-2912026-10-20T22:08:03.4359476Z
2026-09-28 – 2026-09-2822026-10-20T22:08:03.4359476Z
2026-09-27 – 2026-09-2722026-10-20T22:08:03.4359476Z
2026-09-26 – 2026-09-2642026-10-20T22:08:03.4359476Z
2026-09-25 – 2026-09-2552026-10-20T22:08:03.4359476Z
2026-09-23 – 2026-09-2312026-10-20T22:08:03.4359476Z
2026-09-22 – 2026-09-2222026-10-20T22:08:03.4359476Z
2026-09-21 – 2026-09-2132026-10-20T22:08:03.4359476Z
2026-09-20 – 2026-09-2022026-10-20T22:08:03.4359476Z
2026-09-18 – 2026-09-18302026-10-20T22:08:03.4359476Z
2026-09-17 – 2026-09-1732026-10-20T22:08:03.4359476Z
2026-09-16 – 2026-09-1692026-10-20T22:08:03.4359476Z
2026-09-15 – 2026-09-15142026-10-20T22:08:03.4359476Z
2026-09-14 – 2026-09-14382026-10-20T22:08:03.4359476Z
2026-09-13 – 2026-09-1312026-10-20T22:08:03.4359476Z
2026-09-12 – 2026-09-1282026-10-20T22:08:03.4359476Z
2026-09-11 – 2026-09-11232026-10-20T22:08:03.4359476Z
2026-09-10 – 2026-09-10452026-10-20T22:08:03.4359476Z
2026-09-09 – 2026-09-0942026-10-20T22:08:03.4359476Z
2026-09-08 – 2026-09-081292026-10-20T22:08:03.4359476Z
2026-09-07 – 2026-09-0762026-10-20T22:08:03.4359476Z
2026-09-06 – 2026-09-0632026-10-20T22:08:03.4359476Z
2026-09-04 – 2026-09-04212026-10-20T22:08:03.4359476Z
2026-09-03 – 2026-09-03232026-10-20T22:08:03.4359476Z
2026-09-02 – 2026-09-02362026-10-20T22:08:03.4359476Z
2026-09-01 – 2026-09-01182026-10-20T22:08:03.4359476Z
2026-08-31 – 2026-08-3122026-10-20T22:08:03.4359476Z
2026-08-29 – 2026-08-2942026-10-20T22:08:03.4359476Z
2026-08-28 – 2026-08-2842026-10-20T22:08:03.4359476Z
2026-08-27 – 2026-08-27182026-10-20T22:08:03.4359476Z
2026-08-25 – 2026-08-2532026-10-20T22:08:03.4359476Z
2026-08-24 – 2026-08-24662026-10-20T22:08:03.4359476Z
2026-08-23 – 2026-08-2332026-10-20T22:08:03.4359476Z
2026-08-21 – 2026-08-21672026-10-20T22:08:03.4359476Z
2026-08-20 – 2026-08-20302026-10-20T22:08:03.4359476Z
2026-08-18 – 2026-08-18232026-10-20T22:08:03.4359476Z
2026-08-17 – 2026-08-1752026-10-20T22:08:03.4359476Z
2026-08-15 – 2026-08-1532026-10-20T22:08:03.4359476Z
2026-08-14 – 2026-08-1442026-10-20T22:08:03.4359476Z
2026-08-13 – 2026-08-1322026-10-20T22:08:03.4359476Z
2026-08-12 – 2026-08-1292026-10-20T22:08:03.4359476Z
2026-08-11 – 2026-08-111032026-10-20T22:08:03.4359476Z

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
0.1.08 Sept 20262

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 17:51 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:254b32659bab22d881c5ac90e6eeeb3eac01bde0e8e224d5a48bfeebb4e65d1f