Skip to main content

Python bindings for the Aphelion AI Framework - unified frontend for AI model development

Project description

aphelion-core

Core library for the Aphelion Framework - a unified frontend for AI model development in Rust.

Overview

aphelion-core provides the foundational APIs for building AI pipelines:

  • BuildGraph - Directed acyclic graph for model architecture with deterministic SHA-256 hashing
  • BuildPipeline - Composable pipeline stages for training, inference, and deployment
  • ModelConfig - Type-safe configuration with parameter validation and versioning
  • Backend - Hardware abstraction trait for CPU, GPU, and accelerators
  • Diagnostics - Structured tracing and event logging

Installation

[dependencies]
aphelion-core = "1.2"
serde_json = "1.0"  # Required for parameter values

Optional Features

[dependencies]
aphelion-core = { version = "1.2", features = ["rust-ai-core", "tritter-accel", "tokio"] }
Feature Description
rust-ai-core Memory tracking, device detection, dtype utilities via rust-ai-core
tritter-accel BitNet b1.58 ternary ops, VSA gradient compression via tritter-accel
cuda CUDA GPU support (requires rust-ai-core)
burn Burn deep learning framework backend
cubecl CubeCL GPU compute backend
tokio Async pipeline execution
python Python bindings via PyO3 (builds aphelion-framework wheel)

Quick Start

use aphelion_core::prelude::*;
use aphelion_core::config::ModelConfig;
use aphelion_core::backend::NullBackend;
use aphelion_core::diagnostics::InMemoryTraceSink;
use aphelion_core::graph::BuildGraph;
use aphelion_core::pipeline::{BuildContext, BuildPipeline};

// Create model configuration
let config = ModelConfig::new("transformer", "1.0.0")
    .with_param("d_model", serde_json::json!(512))
    .with_param("n_heads", serde_json::json!(8));

// Build graph
let mut graph = BuildGraph::default();
let node = graph.add_node("encoder", config);

// Execute pipeline
let backend = NullBackend::cpu();
let trace = InMemoryTraceSink::new();
let ctx = BuildContext::new(&backend, &trace);

let pipeline = BuildPipeline::standard();
let result = pipeline.execute(&ctx, graph).unwrap();

println!("Hash: {}", result.stable_hash());

Core Modules

config - Model Configuration

use aphelion_core::config::ModelConfig;

let config = ModelConfig::new("llama", "2.0.0")
    .with_param("hidden_size", serde_json::json!(4096))
    .with_param("num_layers", serde_json::json!(32));

// Type-safe retrieval
let hidden: u32 = config.param("hidden_size")?;
let layers: u32 = config.param_or("num_layers", 12)?;

graph - Build Graph

use aphelion_core::graph::BuildGraph;

let mut graph = BuildGraph::default();
let input = graph.add_node("input", config.clone());
let hidden = graph.add_node("hidden", config.clone());
graph.add_edge(input, hidden);

// Deterministic hash
let hash = graph.stable_hash();

pipeline - Pipeline Execution

use aphelion_core::pipeline::{BuildPipeline, ValidationStage, HashingStage};

let pipeline = BuildPipeline::new()
    .with_stage(Box::new(ValidationStage))
    .with_stage(Box::new(HashingStage))
    .with_pre_hook(|ctx| {
        println!("Starting on {}", ctx.backend.name());
        Ok(())
    });

let result = pipeline.execute(&ctx, graph)?;

backend - Hardware Abstraction

use aphelion_core::backend::{Backend, NullBackend, DeviceCapabilities};

// Use null backend for testing
let backend = NullBackend::cpu();

// Implement custom backend
impl Backend for MyGpuBackend {
    fn name(&self) -> &str { "my_gpu" }
    fn device(&self) -> &str { "cuda:0" }
    fn capabilities(&self) -> DeviceCapabilities { /* ... */ }
    fn is_available(&self) -> bool { true }
    fn initialize(&mut self) -> AphelionResult<()> { Ok(()) }
    fn shutdown(&mut self) -> AphelionResult<()> { Ok(()) }
}

diagnostics - Tracing

use aphelion_core::diagnostics::{InMemoryTraceSink, TraceSinkExt};

let trace = InMemoryTraceSink::new();
trace.info("model.init", "Initializing model");
trace.warn("config", "Deprecated parameter");

let json = trace.to_json();

Ecosystem Integration

aphelion-core is part of the rust-ai ecosystem:

See the framework README for full ecosystem documentation.

License

MIT License - see LICENSE

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

aphelion_framework-1.2.9.tar.gz (133.6 kB view details)

Uploaded Source

Built Distributions

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

aphelion_framework-1.2.9-cp310-abi3-win_amd64.whl (392.0 kB view details)

Uploaded CPython 3.10+Windows x86-64

aphelion_framework-1.2.9-cp310-abi3-manylinux_2_34_x86_64.whl (491.4 kB view details)

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

aphelion_framework-1.2.9-cp310-abi3-macosx_11_0_arm64.whl (447.7 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

Details for the file aphelion_framework-1.2.9.tar.gz.

File metadata

  • Download URL: aphelion_framework-1.2.9.tar.gz
  • Upload date:
  • Size: 133.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aphelion_framework-1.2.9.tar.gz
Algorithm Hash digest
SHA256 602782810423ebdda80af3c18eac91a1e11090d60ed7f90c41a6841b1308a1ce
MD5 ceda597952862307c8ad8a8c460954ae
BLAKE2b-256 41b8b2b184a8af7b38619c0c9058e0cd80eec98dc4c3fe11fd9687d1bcfab182

See more details on using hashes here.

Provenance

The following attestation bundles were made for aphelion_framework-1.2.9.tar.gz:

Publisher: release.yml on tzervas/aphelion-framework-rs

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

File details

Details for the file aphelion_framework-1.2.9-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for aphelion_framework-1.2.9-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 55cc89cfb402af953a84bc189fcfc043893b27f9a8b802d2dae4621e77402c42
MD5 1fce525d20d9931dc8a69c94e11e211c
BLAKE2b-256 b1cc48def611e81e7b205529d87fa0ceb85534ed3f9c9db70d22e59048cadc33

See more details on using hashes here.

Provenance

The following attestation bundles were made for aphelion_framework-1.2.9-cp310-abi3-win_amd64.whl:

Publisher: release.yml on tzervas/aphelion-framework-rs

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

File details

Details for the file aphelion_framework-1.2.9-cp310-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for aphelion_framework-1.2.9-cp310-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 8c97f6bd1c0915c80e2661054ea1fd81cf2a5982b1eb4fbdfe0b378f04f9fd2a
MD5 bcb85872e845d45493a53d9bef519cd1
BLAKE2b-256 f7700dd28824dd7fbabade1870bf96eada68844606878db5f6b267d7796e1367

See more details on using hashes here.

Provenance

The following attestation bundles were made for aphelion_framework-1.2.9-cp310-abi3-manylinux_2_34_x86_64.whl:

Publisher: release.yml on tzervas/aphelion-framework-rs

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

File details

Details for the file aphelion_framework-1.2.9-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for aphelion_framework-1.2.9-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a3bce20870f4f37359d2b5d12836f33156f037cae066a76b40803f81abb9ba3c
MD5 43f6c58bd9ff9c8b10a890d31566b3b1
BLAKE2b-256 51f874c99973ebd5b1635bdbbd7d429d14d8a5bf0d8b613a55d5af53477d39ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for aphelion_framework-1.2.9-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on tzervas/aphelion-framework-rs

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