| Crates.io | axonml |
| lib.rs | axonml |
| version | 0.2.4 |
| created_at | 2026-01-19 22:19:13.92493+00 |
| updated_at | 2026-01-25 22:43:15.604476+00 |
| description | A complete ML/AI framework in pure Rust - PyTorch-equivalent functionality |
| homepage | |
| repository | |
| max_upload_size | |
| id | 2055432 |
| size | 181,781 |
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.
| 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 |
Add axonml to your Cargo.toml:
[dependencies]
axonml = "0.1.0"
The prelude module re-exports commonly used types for quick access:
use axonml::prelude::*;
fn main() -> axonml::core::Result<()> {
// Create a tensor
let x = Tensor::from_vec(vec![1.0, 2.0, 3.0, 4.0], &[2, 2])?;
// Wrap in a Variable for autograd
let var = Variable::new(x, true);
// Build a simple model
let model = Sequential::new()
.add(Linear::new(784, 128))
.add(ReLU)
.add(Linear::new(128, 10));
// Create an optimizer
let mut optimizer = Adam::new(model.parameters(), 0.001);
Ok(())
}
use axonml::prelude::*;
fn train() -> axonml::core::Result<()> {
// Create model
let model = Sequential::new()
.add(Linear::new(784, 256))
.add(ReLU)
.add(Dropout::new(0.2))
.add(Linear::new(256, 10));
// Optimizer
let mut optimizer = Adam::new(model.parameters(), 0.001);
// Dataset and loader
let dataset = SyntheticMNIST::new(1000);
let loader = DataLoader::new(dataset, 32);
// Training loop
for epoch in 0..10 {
for batch in loader.iter() {
// Forward pass
let output = model.forward(&batch.data);
let loss = CrossEntropyLoss::new().forward(&output, &batch.labels);
// Backward pass
loss.backward();
// Update weights
optimizer.step();
optimizer.zero_grad();
}
println!("Epoch {} complete", epoch + 1);
}
Ok(())
}
Select only the features you need:
[dependencies]
# Full framework (default)
axonml = "0.1.0"
# Core only (tensors + autograd)
axonml = { version = "0.1.0", default-features = false, features = ["core"] }
# Neural networks without domain-specific modules
axonml = { version = "0.1.0", default-features = false, features = ["nn", "data"] }
# Vision pipeline
axonml = { version = "0.1.0", default-features = false, features = ["vision"] }
# NLP pipeline
axonml = { version = "0.1.0", default-features = false, features = ["text", "llm"] }
| 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 |
use axonml::{version, features};
fn main() {
println!("AxonML version: {}", version());
println!("Enabled features: {}", features());
}
Run the full test suite:
cargo test -p axonml
Run tests for specific features:
cargo test -p axonml --features "core nn data"
Run integration tests:
cargo test -p axonml --test integration_test
The crate includes example programs:
# Simple training example
cargo run -p axonml --example simple_training
# MNIST digit classification
cargo run -p axonml --example mnist_training
# NLP and audio feature test
cargo run -p axonml --example nlp_audio_test
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
Licensed under either of:
at your option.