rust-ai-core
Unified AI engineering toolkit that orchestrates the complete rust-ai ecosystem into a cohesive API for fine-tuning, quantization, and GPU-accelerated AI operations.
What is rust-ai-core?
rust-ai-core is the central hub for 8 specialized AI/ML crates, providing:
- Unified API: Single entry point (
RustAI) for all AI engineering tasks - Foundation Layer: Device selection, error handling, memory tracking
- Ecosystem Re-exports: Direct access to all component crates
Integrated Ecosystem
| Crate | Purpose | Version |
|---|---|---|
| peft-rs | LoRA, DoRA, AdaLoRA adapters | 1.0.3 |
| qlora-rs | 4-bit quantized LoRA | 1.0.5 |
| unsloth-rs | Optimized transformer blocks | 1.0 |
| axolotl-rs | YAML-driven fine-tuning | 1.1 |
| bitnet-quantize | BitNet 1.58-bit quantization | 0.2 |
| trit-vsa | Ternary VSA operations | 0.2 |
| vsa-optim-rs | VSA-based optimization | 0.1 |
| tritter-accel | Ternary GPU acceleration | 0.1.3 |
Installation
Rust
[]
# Full ecosystem integration
= "0.3"
# With CUDA support
= { = "0.3", = ["cuda"] }
# With Python bindings
= { = "0.3", = ["python"] }
# Everything
= { = "0.3", = ["full"] }
Python
Quick Start Guide
Option 1: Unified API (Recommended)
The RustAI facade provides a simplified interface for common tasks:
use ;
Option 2: Direct Crate Access
Access individual crates through the ecosystem module:
use ;
use ;
use ;
use ;
Option 3: Foundation Layer Only
Use just the core utilities without ecosystem crates:
use ;
use ;
API Reference
Unified API (RustAI)
// Initialize
let ai = new?;
// Workflows
ai.finetune // -> FinetuneBuilder (LoRA, DoRA, AdaLoRA)
ai.quantize // -> QuantizeBuilder (NF4, FP4, BitNet, INT8)
ai.vsa // -> VsaBuilder (Vector Symbolic Architectures)
ai.train // -> TrainBuilder (Axolotl-style YAML config)
// Info
ai.device // Active device (CPU or CUDA)
ai.ecosystem // Ecosystem crate versions
ai.is_cuda // Whether CUDA is active
ai.info // Full environment info
Configuration Options
let config = new
.with_verbose // Enable verbose logging
.with_memory_limit // 8 GB limit
.with_cpu // Force CPU execution
.with_cuda_device; // Select CUDA device
Ecosystem Modules
| Module | Crate | Key Types |
|---|---|---|
ecosystem::peft |
peft-rs | LoraConfig, LoraLinear, DoraConfig |
ecosystem::qlora |
qlora-rs | QLoraConfig, QuantizedTensor, Nf4Quantizer |
ecosystem::unsloth |
unsloth-rs | FlashAttention, SwiGLU, RMSNorm |
ecosystem::axolotl |
axolotl-rs | AxolotlConfig, TrainingPipeline |
ecosystem::bitnet |
bitnet-quantize | BitNetConfig, TernaryLinear |
ecosystem::trit |
trit-vsa | TritVector, PackedTritVec, HdcEncoder |
ecosystem::vsa_optim |
vsa-optim-rs | VsaOptimizer, GradientPredictor |
ecosystem::tritter |
tritter-accel | TritterRuntime, TernaryMatmul |
Foundation Utilities
| Function | Purpose |
|---|---|
get_device() |
CUDA-first device selection with fallback |
warn_if_cpu() |
One-time warning when running on CPU |
estimate_tensor_bytes() |
Memory estimation for tensor shapes |
estimate_attention_memory() |
O(n^2) attention memory estimation |
MemoryTracker::new() |
Thread-safe memory tracking with limits |
init_logging() |
Initialize tracing with env filter |
Environment Variables
| Variable | Description | Default |
|---|---|---|
RUST_AI_FORCE_CPU |
Force CPU execution | false |
RUST_AI_CUDA_DEVICE |
CUDA device ordinal | 0 |
RUST_LOG |
Logging level | info |
Feature Flags
| Feature | Description | Dependencies |
|---|---|---|
cuda |
CUDA support via CubeCL | cubecl, cubecl-cuda |
python |
Python bindings via PyO3 | pyo3, numpy |
full |
All features enabled | cuda, python |
Design Philosophy
- CUDA-first: GPU preferred, CPU fallback with warnings
- Zero-cost abstractions: Traits compile to static dispatch
- Fail-fast validation: Configuration errors caught at construction
- Unified API: Single entry point for all AI engineering tasks
- Direct access: Full crate APIs available when needed
Examples
See the examples/ directory:
device_selection.rs- Device configuration patternsmemory_tracking.rs- Memory estimation and trackingerror_handling.rs- Error handling patterns
Python Bindings
# Memory estimation
=
# Attention memory (for model planning)
=
# Device detection
=
# Memory tracking
= # 8 GB limit
License
MIT License - see LICENSE-MIT
Contributing
Contributions welcome! Please ensure:
- All public items have documentation
- Tests pass:
cargo test - Lints pass:
cargo clippy --all-targets --all-features - Code is formatted:
cargo fmt
See Also
- ARCHITECTURE.md - Design decisions and extension points
- docs.rs/rust-ai-core - Full API documentation