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.9.1.tar.gz (999.5 kB 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.9.1-cp310-abi3-win_amd64.whl (3.2 MB view details)

Uploaded CPython 3.10+Windows x86-64

atomr_accel-0.9.1-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.9.1-cp310-abi3-musllinux_1_2_aarch64.whl (2.6 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

atomr_accel-0.9.1-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.9.1-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.9.1-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (4.8 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.9.1.tar.gz.

File metadata

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

File hashes

Hashes for atomr_accel-0.9.1.tar.gz
Algorithm Hash digest
SHA256 7df9522974c083ac739afd77935c8143112ff369b0d11eb84c6b1280bdf4d800
MD5 4b45a13aaec9519e746b9222a71d016a
BLAKE2b-256 76ecc85c3ade5bfb2bf8ba3232015caf9b42cfd834f8bd864e3c40f1f0fceabd

See more details on using hashes here.

Provenance

The following attestation bundles were made for atomr_accel-0.9.1.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.9.1-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: atomr_accel-0.9.1-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.9.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 36c2a17d5ffb00d227972f70ea7259063d0e3f3b55a8a6039770e79a73db842a
MD5 a9b1c836173360dd43c71765299c0117
BLAKE2b-256 34109bbeaa4a34f607a2fc1cd2f825945913d55a5b1c22ce3ee14984a14fe6c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for atomr_accel-0.9.1-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.9.1-cp310-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for atomr_accel-0.9.1-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 40d08356b2f414903198805fbd0b0c6e2f90f24ddef3051bbeee9626c791b060
MD5 1ff593453eed4c002c8793addd20eac6
BLAKE2b-256 8386dfeaacd67b971ac25cf9f4b7524b30cf603b9f533ae9b4412fdd6a3c7538

See more details on using hashes here.

Provenance

The following attestation bundles were made for atomr_accel-0.9.1-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.9.1-cp310-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for atomr_accel-0.9.1-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 6c09064a4bef208e4b036b3c3aec985c10be1ecd123997f4812dd6e532becbec
MD5 ad0cb200ddbb5485d3ab7679a857e9d7
BLAKE2b-256 a11e67a5c75fc5ab5204ef66b05ce605a948872c7f9f0bef2686a8260a91793f

See more details on using hashes here.

Provenance

The following attestation bundles were made for atomr_accel-0.9.1-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.9.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for atomr_accel-0.9.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 776be185d2b937c4fffe66486afc72d9e57000034823698ffb9067b37dcc7d4d
MD5 3b4760a73d9deef505fca5f031a2ed9d
BLAKE2b-256 8d6299c00e8a86b2d8b2f1fb5638a451eaf244dcdebf92c37369172ac35ca305

See more details on using hashes here.

Provenance

The following attestation bundles were made for atomr_accel-0.9.1-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.9.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for atomr_accel-0.9.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8e3353bdbea660995b802c8b21a34dfb569c69518fc19fe250f02138c8fa1535
MD5 c0ee1891bbde8683f30087387a01390d
BLAKE2b-256 5218c8e42fd1f74065d0390fa99235963f67d7f95f1deed31b9c956ea621671c

See more details on using hashes here.

Provenance

The following attestation bundles were made for atomr_accel-0.9.1-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.9.1-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.9.1-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 c9f57aa2dcccd946f07501d7e765859c84417c0d025104d2ba9857fb9651f462
MD5 fd0e339ed2fad0feaaa88534179abb7c
BLAKE2b-256 e9404bcabccc21b81d064c43cb9a349e157322f5c20e16f3d116ae82c644adde

See more details on using hashes here.

Provenance

The following attestation bundles were made for atomr_accel-0.9.1-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