Overview
axonml is the umbrella crate for the AxonML machine learning framework - a complete ML/AI toolkit written in pure Rust. It provides PyTorch-equivalent functionality including tensors, automatic differentiation, neural networks, optimizers, data loading, and domain-specific utilities for vision, text, and audio processing.
This crate re-exports all AxonML sub-crates under a unified API, allowing you to build and train deep learning models with a single import.
Features
- Tensors - N-dimensional arrays with broadcasting, views, slicing, and BLAS-accelerated operations
- Automatic Differentiation - Computational graph construction with backward pass for gradient computation
- Neural Networks - Linear, Conv2d, BatchNorm, LayerNorm, Attention, RNN/LSTM/GRU, and more
- Optimizers - SGD, Adam, AdamW, RMSprop with learning rate schedulers (Step, Exponential, Cosine)
- Data Loading - Dataset trait, DataLoader with batching, samplers, and transforms
- Vision - Image transforms, MNIST/CIFAR datasets, CNN architectures (LeNet, SimpleCNN)
- Text - Tokenizers (BPE, WordPiece, Whitespace), vocabularies, text datasets
- Audio - Spectrograms, MFCC, audio transforms, synthetic audio datasets
- Distributed - DDP, all-reduce, broadcast, barrier, process groups
- Profiling - Memory and compute profilers, timeline analysis, bottleneck detection
- LLM Architectures - BERT and GPT-2 implementations with generation utilities
- JIT Compilation - Graph tracing and optimization for compiled inference
Modules (Re-exports)
| Module | Description | Feature Flag |
|---|---|---|
core |
Error types, Device, DType definitions | core |
tensor |
N-dimensional tensor operations | core |
autograd |
Automatic differentiation and Variables | core |
nn |
Neural network layers and modules | nn |
optim |
Optimizers and learning rate schedulers | nn |
data |
DataLoader, Dataset trait, samplers, transforms | data |
vision |
Image transforms and vision datasets | vision |
text |
Tokenizers, vocabularies, text datasets | text |
audio |
Audio transforms and audio datasets | audio |
distributed |
Distributed training utilities (DDP) | distributed |
profile |
Profiling and bottleneck analysis | profile |
llm |
BERT and GPT-2 architectures | llm |
jit |
JIT compilation and graph optimization | jit |
Usage
Add axonml to your Cargo.toml:
[]
= "0.1.0"
Using the Prelude
The prelude module re-exports commonly used types for quick access:
use *;
Training Loop Example
use *;
Feature Flags
Select only the features you need:
[]
# Full framework (default)
= "0.1.0"
# Core only (tensors + autograd)
= { = "0.1.0", = false, = ["core"] }
# Neural networks without domain-specific modules
= { = "0.1.0", = false, = ["nn", "data"] }
# Vision pipeline
= { = "0.1.0", = false, = ["vision"] }
# NLP pipeline
= { = "0.1.0", = false, = ["text", "llm"] }
Feature Flag Reference
| Feature | Includes | Description |
|---|---|---|
full |
All features | Complete framework (default) |
core |
tensor, autograd | Core tensor operations and autodiff |
nn |
core + nn, optim | Neural network layers and optimizers |
data |
core + data | DataLoader and dataset utilities |
vision |
nn, data + vision | Image processing and vision datasets |
text |
nn, data + text | Tokenizers and text processing |
audio |
nn, data + audio | Audio transforms and datasets |
distributed |
nn + distributed | Distributed training (DDP) |
profile |
core + profile | Profiling and analysis tools |
llm |
nn + llm | BERT and GPT-2 architectures |
jit |
core + jit | JIT compilation and tracing |
Version Information
use ;
Tests
Run the full test suite:
Run tests for specific features:
Run integration tests:
Examples
The crate includes example programs:
# Simple training example
# MNIST digit classification
# NLP and audio feature test
Sub-Crate Structure
axonml/
axonml-core - Error types, Device, DType
axonml-tensor - N-dimensional tensor operations
axonml-autograd - Automatic differentiation
axonml-nn - Neural network layers
axonml-optim - Optimizers and schedulers
axonml-data - DataLoader and Dataset trait
axonml-vision - Image transforms and datasets
axonml-text - Tokenizers and text utilities
axonml-audio - Audio transforms and datasets
axonml-distributed- Distributed training (DDP)
axonml-profile - Profiling and analysis
axonml-llm - BERT and GPT-2 models
axonml-jit - JIT compilation
axonml-serialize - Model serialization
axonml-tui - Terminal user interface
axonml (this) - Umbrella crate
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.