The README makes claims. This file backs them up with specific code locations, honest caveats, and enough trace information for an external reviewer to navigate the codebase cold.
Unified accelerator abstraction layer for Julia — GPU, TPU, NPU, FPGA, QPU, DSP, and more.
How it works: src/AcceleratorGate.jl defines a flat type hierarchy rooted at the
abstract type AbstractBackend. Every concrete accelerator family is its own struct:
CUDABackend(device::Int), ROCmBackend(device::Int), MetalBackend(device::Int),
TPUBackend, NPUBackend, DSPBackend, PPUBackend, MathBackend, FPGABackend,
VPUBackend, QPUBackend, and CryptoBackend. Two union types further group them:
GPUBackend = Union{CUDABackend, ROCmBackend, MetalBackend} and CoprocessorBackend
covering the remaining nine specialised units. There are also JuliaBackend,
RustBackend(lib_path), and ZigBackend(lib_path) for non-hardware execution paths.
Backend selection is process-global via a Ref{AbstractBackend} thread-unsafe singleton
(_current_backend). The @with_backend macro provides scoped override with restore-on-exit.
Honest caveat: Availability detection is entirely environment-variable-driven
(AXIOM_CUDA_AVAILABLE, AXIOM_ROCM_AVAILABLE, etc.). There is no runtime
probing of actual hardware. On a machine with a GPU that does not set these
vars, detect_gpu() returns nothing. The module is a dispatch scaffold, not a
hardware driver.
Platform-aware auto-detection (mobile, embedded, server, desktop)
How it works: detect_platform() in src/AcceleratorGate.jl (line ~236) probes
Sys.islinux(), Sys.isapple(), Sys.iswindows(), Sys.isbsd() and falls back to
uname -s for MINIX and OpenBSD. Android is distinguished from Linux via the
ANDROID_ROOT environment variable and /system/app path presence. iOS is
distinguished from macOS by the heuristic aarch64 + no /usr/local. Embedded
environments are flagged at CPU_THREADS ⇐ 2 AND total_memory < 512 MiB; server
environments at CPU_THREADS >= 16 OR total_memory > 32 GiB. Architecture
compatibility is enforced in _arch_compatible/2 — for example, MetalBackend
is only considered compatible with :aarch64.
select_backend uses this platform information together with DeviceCapabilities
structs and cost estimates to choose the cheapest suitable backend for an operation.
Honest caveat: The iOS heuristic (aarch64 + no /usr/local) is fragile — Apple
Silicon Macs running in unusual configurations may be misidentified. The server
heuristic fires on any machine with 16+ threads, including developer workstations.
Tests live in test/runtests.jl. Coverage includes:
-
All 15 backend struct constructors satisfy
isa AbstractBackend -
Union membership (
CUDABackend isa GPUBackend,TPUBackend isa CoprocessorBackend) -
@with_backendscoping restores original backend after block exit -
Detection returns
false/0/nothingwithout env vars set -
Detection returns correct types when env vars are set (
withenv(…)) -
capability_report()produces a dict withgenerated_at,strategy_order,backends,platform, andselected_backendkeys -
runtime_diagnostics()accumulates and resets fallback counters correctly -
_coprocessor_label,_coprocessor_key,_coprocessor_required_envhelpers
| Path | What’s There |
|---|---|
|
Entire module — backend type hierarchy, env-var detection, |
|
Full test suite. Uses |
|
Package identity ( |
|
MPL-2.0 full text; MPL-2.0 fallback text for Julia registry. |
| Repo | How AcceleratorGate (or this domain) appears |
|---|---|
|
Listed as one of the six "Metal Layer" packages pulled in by the umbrella metapackage
( |
|
Includes |
|
Sibling Metal Layer package; coordinates with |
|
Julia ecosystem monorepo where all standalone |
|
Uses Julia batch scripts for statistical processing; the accelerator abstraction pattern established here informs backend selection in compute-heavy Julia scripts. |