Skip to content

0.5.0: one class per array library (ArrayLibrary family); devices as values; conversion records - #12

Merged
trissim merged 3 commits into
mainfrom
refactor/array-library-family
Oct 12, 2026
Merged

trissim merged 3 commits into
mainfrom
refactor/array-library-family

Conversation

@trissim

@trissim trissim commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

What

Each supported array library is one class of one family, arraybridge.libraries.ArrayLibrary. The class states the library's identity and owns its devices, data movement, streams, DLPack, out-of-memory recognition, child-process environment and native array operations. FrameworkRuntime, the ~60 _<library>_<capability> functions, the positional-tuple MemoryType members and the parallel ArrayOperations family are gone; what several libraries share is a parent class (HostDevices, AcceleratorDevices, CudaLibrary, DLPackImport, DLPackProtocolExport, NvidiaWheelLibraries, MutableArrays).

  • MemoryType is a view: an Enum generated from the registered library classes, no behaviour, MemoryType.X.library for the library object. A library defined later appears as a member.
  • Devices are values (HOST, AcceleratorDevice(i), NamedDevice(name)); is_gpu and the CPU/GPU type sets are removed. torch, JAX and TensorFlow have a host device.
  • arraybridge.conversion: ConversionRoute (ordered registered family; one predicate answers the planned mechanism and selects the route), ConversionRecord, ConversionObserver (off by default), ConversionCounters.
  • No typing.Any in the package (278 before). Array is a nominal ABC with native classes registered when first met.
  • framework_config, framework_ops, converters_registry, dtype_scaling, gpu_cleanup, oom_recovery, array_operations are deleted with no aliases. CHANGELOG.md lists every removed name and its replacement.

Checked

  • Characterisation script (207 recorded results: every library x capability reachable with NumPy, torch 2.6.0+cu124 and CuPy 13.6 on a GTX 1080, including CuPy <-> torch zero-copy pointer equality, streams, real out-of-memory recognition, decorators) is identical between v0.4.1 and this branch.
  • Suite: 279 passed / 18 skipped (NumPy only, Python 3.10, 3.12, 3.13); 289 passed / 8 skipped with real torch + CuPy on the GPU. v0.4.1 baseline: 253 passed / 11 skipped.
  • ruff, black, mypy clean. warn_return_any is turned off: optional libraries are not importable by the checker, so what their modules return has no static type.

Not checked

TensorFlow, JAX and pyclesperanto paths ran only against fake modules (and JAX on CPU): their accelerator code is a port of the 0.4.1 functions and was not run on a device. The host-device paths for JAX and TensorFlow are new and ran only on fakes.

🤖 Generated with Claude Code

trissim and others added 3 commits October 12, 2026 14:54
…d operations

MemoryType becomes a view generated from the registered library classes.
Devices are Device values (HOST, AcceleratorDevice, NamedDevice); is_gpu and
the CPU/GPU type sets are gone. Conversion routes are a registered ordered
family whose one predicate answers the planned mechanism and selects the
route. Work in progress: tests and docs not yet updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… 0.5.0

A library without main-memory arrays (CuPy) cannot wrap a host buffer, so that
pair is planned and run as a host copy instead of a DLPack attempt that fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…new libraries

Tests are regrouped by what they test (libraries, devices, conversion,
memory type, toy library) with shared fake modules; tests of deleted modules
are removed. Adds the toy-library test (one class gives lookup, MemoryType
member, decorator and conversion), the light-import and plan-without-devices
subprocess tests, and conversion record and counter tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 12, 2026 19:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@trissim
trissim merged commit 0aecbe4 into main Oct 12, 2026
12 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants