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

Uploaded CPython 3.10+Windows x86-64

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

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

atomr_accel-0.4.2-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.4.2-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.4.2-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.4.2.tar.gz.

File metadata

  • Download URL: atomr_accel-0.4.2.tar.gz
  • Upload date:
  • Size: 999.2 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.4.2.tar.gz
Algorithm Hash digest
SHA256 1aa9b754f18053929967f21f9ce1096736892b2de1ea23100d4ad671f249deba
MD5 64c436f298d2f217e217bb70e89e018b
BLAKE2b-256 4949b6d6ea9eaf7a4bc69c9e85515b0554a77777fd22bd73ae72e5d0510622cf

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: atomr_accel-0.4.2-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.4.2-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 95c70ecfe846f021b0a3959b5978b44ce1637917228a7ba759389981de9c01ca
MD5 76fe38b555295427ab55deb0727f9e0b
BLAKE2b-256 0bd98efa1179a17981f19f8b3651e469302b86d2dc51c6f44cc4cc8a75006884

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for atomr_accel-0.4.2-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9ad1ed293dfe0f1efe79d5ed23d7aff4d9751bd7adc3f5520e56f21f418f27e4
MD5 5766b4346c49d5c426d833d7d7146675
BLAKE2b-256 c4f8d86f0c4eebcf0bc7dc5f8a594d069f0dc64e611233fcf50f7795f5a4aaa7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for atomr_accel-0.4.2-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 30c80370dc88a8bbd1603a043fa7b088d2ffabfeb847a541005bb0182bda1984
MD5 200f6a2cd07addfbe4977abcbd18d79f
BLAKE2b-256 648e9ccc3119f7afcf529459e8e6613bc02330435f52b5588470389cbeab1d02

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for atomr_accel-0.4.2-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0f055d2d3d694ab663d7433dd4d9c5d7506d3ab6fcaaa9356f354cd03cc9546a
MD5 a541d57709e5e914b4cb9498db8b432c
BLAKE2b-256 0429986c96f13571ff754afea7c7c46da5d45c13e20d170b7da79db795dc40f5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for atomr_accel-0.4.2-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 619701ebb5b3ff6e26da89f33fccaf419c7335cab006e7036a964e73f526d3aa
MD5 a42a44d23cfdeb0a035ef57ea2bd0d56
BLAKE2b-256 b70aeeb51abccb6e36b9f626203bf1359fb7ac11a4ae7a907ea4f3c482e0c348

See more details on using hashes here.

Provenance

The following attestation bundles were made for atomr_accel-0.4.2-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.4.2-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.4.2-cp310-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 e07c3a33d313c97f3c06813e5357e5168ad6c365301777cb940e4d4b938bd0f9
MD5 1cd065749bb63e227be92ac3a479a516
BLAKE2b-256 4345a3ccb5fbed8b0ca7bf1a85e42a088c4b5186c2448373c063d707503c7c38

See more details on using hashes here.

Provenance

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