Skip to main content

Safe, fast Rust kernels exposed to Python via PyO3

Project description

rust_accel

rust_accel is a Rust-accelerated Python extension module built with PyO3 and maturin, designed to speed up computation-heavy numerical workloads while keeping a clean, Python-native API.

It is ideal for performance-critical paths in data processing, numerical optimization, and machine-learning pipelines where Python ergonomics and Rust speed are both required.


Features

  • High-performance Rust kernels exposed to Python
  • Seamless NumPy-compatible API
  • Parallelized computation using Rayon
  • Clean python/ source layout (no import shadowing)
  • Prebuilt wheels via maturin
  • Memory-safe Rust implementation

Installation

From PyPI (recommended)

pip install rust-accel

From source (development)

git clone https://github.com/0rlych1kk4/rust_accel.git
cd rust_accel
python -m venv .venv
source .venv/bin/activate
pip install -U pip maturin
maturin develop

Usage

optimize_reconstruction

Computes a batched dot-product–style loss between an input matrix and multiple gradient matrices.

import numpy as np
import rust_accel

x = np.ones((2, 3), dtype=np.float32)

grads = np.stack([
    np.full((2, 3), 2, np.float32),
    np.full((2, 3), 3, np.float32),
], axis=0)

loss = rust_accel.optimize_reconstruction(x, grads)
print(loss)  # 30.0

### clone_grad
Creates a Rust-side copy of a NumPy array and returns it as a flat Python list.

```python
import numpy as np
import rust_accel

x = np.ones((2, 3), dtype=np.float32)
flat = rust_accel.clone_grad(x)

print(len(flat))     # 6
print(flat[:3])      # [1.0, 1.0, 1.0]

Real-World Use Cases

  • Accelerating inner loops in ML / optimization pipelines
  • High-frequency numerical aggregation
  • Scientific computing with Python frontends
  • Hybrid Python–Rust systems where correctness and speed matter
  • Safe native extensions without manual memory management

Contributing

We welcome contributions to the rust_accel project! If you'd like to contribute, please follow these steps:

  1. Fork this repository to your GitHub account.
  2. Clone your forked repository to your local machine:
    git clone https://github.com/yourusername/rust_accel.git
    

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

rust_accel-0.1.1.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

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

rust_accel-0.1.1-cp311-cp311-macosx_11_0_arm64.whl (219.8 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

Details for the file rust_accel-0.1.1.tar.gz.

File metadata

  • Download URL: rust_accel-0.1.1.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.8.6

File hashes

Hashes for rust_accel-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7cc51552a870b81829bec93e0abbe7cab382bddcb3c6f773573187b39de97488
MD5 ed33bbb527ddb7462b38eead8cb7bea5
BLAKE2b-256 6d2e68a6343ef0082f31536f4e00f8756814f7154f5e38b7753421eb8ca806f1

See more details on using hashes here.

File details

Details for the file rust_accel-0.1.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rust_accel-0.1.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 97672965486d582a682b41f06994f28e743b3491c214910db84477475ec6ab20
MD5 7f1f670338a04a7a08a548ac39c22e8f
BLAKE2b-256 9e5450d4d32f854ae1255f7e7b2f9201fbfb6fa661baec3385f902eaae1221e6

See more details on using hashes here.

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