[Paper Review] MiniTensor: A Lightweight, High-Performance Tensor Operations Library
MiniTensor is an open-source, PyTorch-like tensor library with a Rust engine and PyO3 bindings, delivering a tiny CPU-focused framework with autodiff, NN modules, and optimizers. It emphasizes minimalism, correctness, and performance with a few-megabyte wheel.
We present MiniTensor, an open source tensor operations library that focuses on minimalism, correctness, and performance. MiniTensor exposes a familiar PyTorch-like Python API while it executes performance critical code in a Rust engine. The core supports dense $n$ dimensional tensors, broadcasting, reductions, matrix multiplication, reverse mode automatic differentiation, a compact set of neural network layers, and standard optimizers. In this paper, we describe the design of MiniTensor's architecture, including its efficient memory management, dynamic computation graph for gradients, and integration with Python via PyO3. We also compare the install footprint with PyTorch and TensorFlow to demonstrate that MiniTensor achieves a package size of only a few megabytes, several orders of magnitude smaller than mainstream frameworks, while preserving the essentials needed for research and development on CPUs. The repository can be found at https://github.com/neuralsorcerer/minitensor
Motivation & Objective
- Provide a compact, correct, and high-performance tensor library for CPU research and education.
- Offer a PyTorch-inspired API with a Rust execution engine and Python bindings.
- Demonstrate a minimal binary footprint while preserving essential DL functionality.
Proposed method
- Three-layer architecture: Python API, PyO3 bindings, and Rust engine.
- Reverse-mode automatic differentiation with computation graph and pullbacks.
- Implementation of core tensor ops (dense tensors, broadcasting, reductions, matrix multiplication) and standard NN layers, losses, and optimizers.
- Advanced performance techniques including ahead-of-time compilation, LLVM vectorization, and portable SIMD where available.
- Zero-copy interoperability with NumPy via PyO3 bindings.
- End-to-end examples and unit tests to validate correctness and gradients.
Experimental results
Research questions
- RQ1Can a minimal CPU-focused tensor library provide essential deep learning functionality with a significantly smaller footprint than mainstream frameworks?
- RQ2How close can a Rust-based engine with a PyTorch-like API approach the performance of larger frameworks on CPU tasks for common operations?
- RQ3What is the practical trade-off between binary size, ease of auditing, and research usability in a lightweight framework?
Key findings
- The MiniTensor wheel is a few megabytes (2.6 MB) versus hundreds of megabytes for PyTorch (887.9 MB) and TensorFlow (620.7 MB).
- It provides dense tensors, broadcasting, reductions, matrix multiplication, reverse-mode autodiff, neural network layers, and standard optimizers.
- Performance relies on a Rust engine with LLVM-based vectorization, ahead-of-time compilation, and optional portable SIMD; GPU support is on the roadmap.
- Python integration via PyO3 enables zero-copy conversion with compatible NumPy arrays, maintaining PyTorch-like usability.
- The library includes unit tests and finite-difference checks for autodiff correctness, plus end-to-end model training examples.
- The design emphasizes a minimal kernel surface, auditable code, and straightforward deployment on CPUs.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.