Aphelion Framework
A Rust framework for building AI model pipelines with deterministic, traceable execution.
What It Does
Aphelion provides infrastructure for constructing and executing AI model build pipelines. It handles:
- Graph Construction: DAG-based model architecture representation with deterministic hashing
- Configuration Management: Type-safe parameters with validation and semantic versioning
- Pipeline Orchestration: Composable stages with hooks, progress tracking, and conditional execution
- Backend Abstraction: Hardware-agnostic interface for CPU, GPU, and accelerator backends
- Diagnostics: Structured tracing with exportable event logs
What It Does Not Do
Aphelion is not a tensor library or neural network implementation. It does not:
- Perform matrix operations or automatic differentiation
- Provide pre-built neural network layers
- Train models or run inference directly
For those capabilities, integrate with backends like Burn via the burn feature flag.
Installation
[]
= "1.0"
= "1.0" # Required for parameter values
Optional features:
[]
= { = "1.0", = ["burn", "tokio"] }
| Feature | Description |
|---|---|
burn |
Burn deep learning framework backend |
cubecl |
CubeCL GPU compute backend |
tokio |
Async pipeline execution support |
Core Concepts
Build Graph
A directed acyclic graph representing model architecture. Each node contains configuration and metadata.
use *;
let mut graph = default;
// Add nodes with configuration
let input = graph.add_node;
let hidden = graph.add_node;
let output = graph.add_node;
// Define data flow
graph.add_edge;
graph.add_edge;
// Deterministic hash for reproducibility
let hash = graph.stable_hash;
The graph hash is computed using SHA-256 over canonicalized node data. Identical graphs produce identical hashes regardless of construction order.
Configuration
Type-safe configuration with parameter validation:
use ModelConfig;
let config = new
.with_param
.with_param
.with_param
.with_param;
// Type-safe retrieval
let d_model: u32 = config.param?;
let dropout: f64 = config.param_or?;
let batch_size: u32 = config.param_or_default?; // Uses Default::default()
Pipeline Execution
Pipelines execute stages in sequence with optional hooks:
use *;
use ;
// Create execution context
let backend = cpu;
let trace = new;
let ctx = new;
// Build pipeline
let pipeline = new
.with_stage
.with_stage
.with_pre_hook
.with_post_hook
.with_progress;
// Execute
let result = pipeline.execute?;
Preset pipelines for common workflows:
let pipeline = standard; // Validation + hashing
let pipeline = for_training; // + training hooks
let pipeline = for_inference; // Minimal, hashing only
Custom Pipeline Stages
Implement the PipelineStage trait:
use ;
use BuildGraph;
use AphelionResult;
;
Custom Backends
Implement the Backend trait for hardware integration:
use ;
use AphelionResult;
Diagnostics and Tracing
Structured event logging with helper methods:
use ;
let trace = new;
// Helper methods reduce boilerplate
trace.info;
trace.warn;
trace.error;
// Export to JSON
let json = trace.to_json;
Validation
Composable validators for configuration checking:
use ;
let validator = new
.with_validator
.with_validator;
match validator.validate
Async Execution
With the tokio feature enabled:
async
Error Handling
All operations return AphelionResult<T>. Errors include context for debugging:
use AphelionError;
// Create errors with context
let error = validation
.in_stage
.for_field;
// Errors chain via std::error::Error::source()
if let Some = error.source
Project Structure
aphelion-framework-rs/
├── crates/
│ ├── aphelion-core/ # Core library (~6000 lines)
│ ├── aphelion-macros/ # Proc macros (#[aphelion_model])
│ ├── aphelion-tests/ # Integration tests
│ └── aphelion-examples/ # Usage examples
├── docs/
│ ├── ARCHITECTURE.md # System design
│ └── API-GUIDE.md # Usage patterns
└── SPEC.md # Success criteria
Testing
# Run all tests
# With async support
# With all features
Test coverage: 252 tests across unit, integration, and documentation tests.
Design Principles
Determinism: Graph hashes are reproducible. BTreeMap ensures ordered iteration. No implicit randomness.
Explicit over implicit: No hidden state. Configuration is explicit. Errors are typed and contextual.
Composition over inheritance: Pipelines compose stages. Validators compose validators. Backends implement traits.
Zero-cost abstractions: Feature flags gate optional dependencies. Unused code is not compiled.
Documentation
| Document | Description |
|---|---|
| ARCHITECTURE.md | System design, module responsibilities, data flow |
| API-GUIDE.md | Common patterns with working examples |
| SPEC.md | Success criteria and compliance checklist |
Examples
Run examples from the workspace:
Version History
| Version | Status | Features |
|---|---|---|
| 1.0.0 | Released | Core pipeline, graph, config, validation, tracing |
| 1.1.0 | Released | DX improvements: typed params, presets, async, auto-detect |
Contributing
- Fork the repository
- Create a feature branch from
develop - Write tests for new functionality
- Ensure
cargo test --workspace --all-featurespasses - Ensure
cargo clippy --workspace --all-features -- -D warningspasses - Submit a pull request to
develop
License
This project is licensed under the MIT License - see the LICENSE file for details.