Skip to main content

Actor-shaped face for compute-acceleration backends (NVIDIA CUDA shipping; ROCm / Metal / oneAPI / Vulkan future), on the atomr actor runtime.

Project description

atomr-accel (Python)

Python bindings for atomr-accel — drive an actor-supervised NVIDIA CUDA pipeline directly from Python without juggling streams, contexts, or hand-rolled retry loops.

import numpy as np
import atomr_accel

with atomr_accel.System.open("my-app") as sys:
    dev = sys.spawn_device(device_id=0)         # real CUDA device

    # Allocate two N×N f32 buffers on-device.
    n = 256
    a = dev.allocate_f32(n * n)
    b = dev.allocate_f32(n * n)
    c = dev.allocate_f32(n * n)

    # Upload from numpy.
    dev.copy_from_numpy(a, np.ones(n * n, dtype=np.float32))
    dev.copy_from_numpy(b, np.full(n * n, 2.0, dtype=np.float32))

    # Run cuBLAS SGEMM — the call blocks until the kernel finishes.
    # Either through the legacy alias on Device:
    dev.sgemm(a, b, c, m=n, n=n, k=n, alpha=1.0, beta=0.0)
    # …or the typed Blas handle (also supports gemm_f64, axpy_f32):
    blas = dev.blas()
    blas.gemm_f32(a, b, c, m=n, n=n, k=n)

    # Pull the result back into a fresh numpy array.
    result = dev.copy_to_numpy(c)
    print(result.reshape(n, n))

For hosts without a GPU, pass mock=True to spawn_device and the device replies Unrecoverable("...mock mode") for any kernel call — useful for testing the surrounding plumbing in CI.

Install

The wheel builds with maturin:

# from this directory
pip install maturin pytest numpy
maturin develop --release       # builds + installs into the active venv
pytest tests/                    # runs the no-GPU smoke suite

For a release wheel:

maturin build --release --no-default-features --features extension-module
# wheel lands in target/wheels/

The pure-Python facade (python/atomr_accel/__init__.py) re-exports the native classes and exception types. Downstream libraries import from atomr_accel and treat atomr_accel._native as private.

Feature flags

The Rust crate matches atomr-accel's feature gating so the wheel can be built minimal or full:

Feature Adds
(default) System, Device, GpuBuffer{F32,F64,I32,U32,U8}, Blas, exceptions
cudnn Cudnn handle (Device.cudnn(), conv2d_fwd_f32)
cufft Fft handle (Device.fft(), structural anchor)
curand RngGenerator handle (Device.rng(), set_seed, uniform_f32, normal_f32)
cusolver Solver handle (structural anchor; spawn path tracked)
nccl Collective handle (structural anchor; comm-group bootstrap tracked)
nvrtc NvrtcKernel (structural anchor; compile/launch tracked)
cublaslt (placeholder; future Python surface)
core-libs / training-libs / full-cuda aggregates
maturin develop --features atomr-accel-py/curand,atomr-accel-py/nvrtc

Public API

Class / function What it wraps
atomr_accel.System.open(name) A atomr_core::actor::ActorSystem lifetime
system.spawn_device(id, mock=) A DeviceActor (real or mock)
device.allocate_{f32,f64,i32,u32,u8}(len) Typed DeviceMsg::alloc::<T>GpuBuffer{T}
device.copy_from_numpy[_T](buf, np) H2D DeviceMsg::copy_from_host::<T>
device.copy_to_numpy[_T](buf) D2H DeviceMsg::copy_to_host::<T> → numpy
device.sgemm(a,b,c,m,n,k,...) cuBLAS SGEMM (legacy alias for blas.gemm_f32)
device.stats() DeviceMsg::StatsDeviceLoad
device.libraries_ready() KernelChildren snapshot probe
device.blas()Blas ActorRef<BlasMsg> handle
blas.gemm_f32 / gemm_f64 / axpy_f32 Typed BlasMsg::Gemm / BlasMsg::L1 dispatch
device.cudnn()Cudnn (feat: cudnn) ActorRef<CudnnMsg> handle
cudnn.conv2d_fwd_f32(x, w, y, ...) CudnnMsg::Op(ConvFwdRequest::<f32>)
device.fft()Fft (feat: cufft) ActorRef<FftMsg> handle (Phase 1 anchor)
device.rng()RngGenerator (feat: curand) ActorRef<RngMsg> handle
rng.set_seed / uniform_f32 / normal_f32 RngMsg::SetSeed / Fill(FillRequest::<f32>)
Solver, Collective (feat-gated) Handle classes; full method coverage in Phase 1.5
NvrtcKernel (feat: nvrtc) KernelHandle probe (Phase 1 stub)
GpuBuffer{T}.is_stale() / .dtype / .len Generation token check + dtype tag
GpuRuntimeError (and subclasses) Typed GpuError mapping

Every method blocks the calling thread until the underlying actor replies (the GIL is released for the duration via py.allow_threads). Async wrappers can be layered later via pyo3_async_runtimes::tokio::future_into_py.

How it works

Three pieces:

  1. A shared tokio runtime. The first call to System.open(...) initializes a multi-threaded scheduler; every subsequent call reuses it. Implemented in src/runtime.rs via pyo3-async-runtimes::tokio::init.
  2. The _native extension module. src/lib.rs registers System, Device, GpuBuffer, exceptions, and (feature-gated) RngGenerator / NvrtcKernel. Each Python class wraps a typed ActorRef<...> from atomr-accel and converts replies via errors::map_gpu.
  3. The pure-Python facade at python/atomr_accel/__init__.py. Hides _native; documents the API; gives downstream libraries a stable import path.

See docs/python-bridge.md for the full architecture write-up.

License

Apache-2.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

atomr_accel-0.10.0.tar.gz (1.0 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

atomr_accel-0.10.0-cp310-abi3-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.10+Windows x86-64

atomr_accel-0.10.0-cp310-abi3-musllinux_1_2_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ x86-64

atomr_accel-0.10.0-cp310-abi3-musllinux_1_2_aarch64.whl (2.6 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

atomr_accel-0.10.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

atomr_accel-0.10.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.4 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

atomr_accel-0.10.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (4.7 MB view details)

Uploaded CPython 3.10+macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

File details

Details for the file atomr_accel-0.10.0.tar.gz.

File metadata

  • Download URL: atomr_accel-0.10.0.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for atomr_accel-0.10.0.tar.gz
Algorithm Hash digest
SHA256 0c34e2a7ba7e3de9a7026e2aa184bb12a27c715568703a915ec04b1109688eaa
MD5 dd5c86a8261a501f4fdfd8b63970cc8b
BLAKE2b-256 2e7fd048ab58acdb020912d02a3f073c9ddfa09de5b2199cb1ea8b5968e43213

See more details on using hashes here.

Provenance

The following attestation bundles were made for atomr_accel-0.10.0.tar.gz:

Publisher: release.yml on rustakka/atomr-accel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file atomr_accel-0.10.0-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: atomr_accel-0.10.0-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 3.2 MB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for atomr_accel-0.10.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 0eb68be63c2f29b1c786d1455e503f6375ea77384f1ea52b3b174bc0f641dd7b
MD5 71979a99e38c6be3eb4f48c22938eeba
BLAKE2b-256 0da0d9f744615a57c2a72f3b29d8465f19b1eb89eccdaad4fb6aebb44af12ba8

See more details on using hashes here.

Provenance

The following attestation bundles were made for atomr_accel-0.10.0-cp310-abi3-win_amd64.whl:

Publisher: release.yml on rustakka/atomr-accel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file atomr_accel-0.10.0-cp310-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for atomr_accel-0.10.0-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 2e3badafcc1e120f6890d437a1939d09abdf589ce8c57ddcdacfb1d53658fb1c
MD5 60724a0d2549a82d4af07a471aef3e28
BLAKE2b-256 4154455063f16f32522e4d8a5a266ab7a2a831b8c9983b826db3f2996e6e5d18

See more details on using hashes here.

Provenance

The following attestation bundles were made for atomr_accel-0.10.0-cp310-abi3-musllinux_1_2_x86_64.whl:

Publisher: release.yml on rustakka/atomr-accel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file atomr_accel-0.10.0-cp310-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for atomr_accel-0.10.0-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 5076af6c99bb5b73bc5f9f8df432bdaad48e35192297eb4acecd3d71bf00ff03
MD5 42dc0f349506b685841fc345d420d68e
BLAKE2b-256 e387f257fd14b0334894d94230e9f1d6146209ae8585d6d70abb24d23cc3d828

See more details on using hashes here.

Provenance

The following attestation bundles were made for atomr_accel-0.10.0-cp310-abi3-musllinux_1_2_aarch64.whl:

Publisher: release.yml on rustakka/atomr-accel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file atomr_accel-0.10.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for atomr_accel-0.10.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d8fbd369ca1e7453d2030808fc7287283a82f07f971a0e07db3d4cc87e43336b
MD5 957cc114559dc3b6bf278c518f1b637b
BLAKE2b-256 9f97c21385800d340aa6ee46594fb227f0be1e97f2958ee97b2a07d8222005f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for atomr_accel-0.10.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on rustakka/atomr-accel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file atomr_accel-0.10.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for atomr_accel-0.10.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4fa845b0ba385b1aa8a81b8fc0ca6751cd61a2b952724eefae5172400801b261
MD5 07b959d50e507fd415bbf5c708ea5865
BLAKE2b-256 4b2b62759e2cef01e12a7ca7583133728cc774072fcb1604b7394bcc6dcb304c

See more details on using hashes here.

Provenance

The following attestation bundles were made for atomr_accel-0.10.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on rustakka/atomr-accel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file atomr_accel-0.10.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for atomr_accel-0.10.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 c8d3656289d07ff513c754d6601f0728d66ccb3a82d146a4dc5b4eca8bdb2238
MD5 dbdbf4ff08fba79c0fc6be0b6c07ba07
BLAKE2b-256 7ef66797d22b7bd94806f5b8387e5364a3733f3901181af7ce5b730435e5a3a2

See more details on using hashes here.

Provenance

The following attestation bundles were made for atomr_accel-0.10.0-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl:

Publisher: release.yml on rustakka/atomr-accel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page