Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Volta ⚡
Volta is a minimal deep learning and automatic differentiation library built from scratch in pure Rust, heavily inspired by PyTorch. It provides a dynamic computation graph, NumPy-style broadcasting, and common neural network primitives.
This project is an educational endeavor to demystify the inner workings of modern autograd engines. It prioritizes correctness, clarity, and a clean API over raw performance, while still providing hooks for hardware acceleration.
Key Features
- Dynamic Computation Graph: Build and backpropagate through graphs on the fly, just like PyTorch.
- Reverse-Mode Autodiff: A powerful backward()method for efficient end-to-end gradient calculation.
- Rich Tensor Operations: A comprehensive set of unary, binary, reduction, and matrix operations via an ergonomic TensorOpstrait.
- NumPy-style Broadcasting: Sophisticated support for operations on tensors with different shapes.
- Neural Network Primitives: High-level nn::Moduletrait withLinear,ReLU, andSequentiallayers for building models.
- Classic Optimizers: Includes SGD(with momentum) andAdamfor model training.
- Model Persistence: Save and load Linearlayer weights to a compact binary format usingbincode.
- BLAS Acceleration (macOS): Optional performance boost for matrix multiplication via Apple's Accelerate framework.
- Validation-Focused: Includes a robust numerical gradient checker to ensure the correctness of all implemented operations.
Project Status
This library is training-ready for small to medium-sized feedforward neural networks (MLPs). It has a correct and well-tested autograd engine.
- ✅ What's Working: Full autograd engine, MLPs, optimizers, DataLoader, loss functions, and saving/loading of individualLinearlayers. The test suite includes over 65 tests validating gradient correctness.
- ⚠️ What's in Progress: Performance is not yet a primary focus. While BLAS acceleration is available for macOS matrix multiplication, most operations use naive loops.
- ❌ What's Missing:
- GPU Support: Currently CPU-only.
- Convolutional Layers: Conv2dis not yet implemented, blocking CNN-based tasks.
- Full Model Serialization: Only individual Linearlayers can be saved/loaded, not entireSequentialmodels.
 
Installation
Add Volta to your Cargo.toml:
[]
 = "0.1.0" # Replace with the latest version
Enabling BLAS on macOS
For a significant performance boost in matrix multiplication on macOS, enable the accelerate feature:
[]
 = {  = "0.1.0",  = ["accelerate"] }
Quick Start: Training an MLP
Here's how to define a simple Multi-Layer Perceptron (MLP), train it on synthetic data, and save a layer's weights.
use ;
API Overview
The library is designed around a few core concepts:
- Tensor: The central data structure, an- Rc<RefCell<RawTensor>>, which holds data, shape, and gradient information. It allows for a mutable, shared structure to build the computation graph.
- TensorOps: A trait implemented for- Tensorthat provides the ergonomic, user-facing API for all operations (e.g.,- tensor.add(&other),- tensor.matmul(&weights)).
- nn::Module: A trait for building neural network layers (- Linear,- ReLU) and composing them into larger models (- Sequential). It standardizes the- forward()pass and parameter collection.
- Optimizers (Adam,SGD): Structures that take a list of model parameters and update their weights based on computed gradients duringstep().
Running the Test Suite
Volta has an extensive test suite that validates the correctness of every operation and its gradient. To run the tests:
To run tests with BLAS acceleration enabled (on macOS):
Note: One test, misc_tests::test_adam_vs_sgd, is known to be flaky as it depends on the random seed and convergence speed. It may occasionally fail.
Roadmap
The next major steps for Volta are focused on expanding its capabilities to handle more complex models and improving performance.
- Full Model Serialization: Implement save/loadforSequentialcontainers to persist entire models, not just individual layers.
- Vision Support: Implement Conv2dandMaxPool2dlayers to unlock the ability to build and train Convolutional Neural Networks (CNNs).
- GPU Acceleration: Integrate a backend for GPU computation (e.g., wgpufor cross-platform support or directmetalbindings for macOS) to drastically speed up training.
- Performance Optimization: Implement SIMD for element-wise operations and further integrate optimized BLAS routines.
Contributing
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
License
This project is licensed under the MIT License - see the LICENSE file for details.