L2
App Listed Dormant
l2 is a fast, Pytorch-style Tensor+Autograd library written in Rust
- Downloads
- 0
- Dependents
- Not applicable
- Stars
- 197
- Forks
- 19
- Contributors
- 1
- Commits
- 165
- Latest release
About
A Pytorch-style Tensor+Autograd library written in Rust
Installation • Contributing • Authors • License • Acknowledgements

Made by Bilal Khan • https://bilal.software
- What is l2?
- Quick start
- Design choices
- Contributing
- Authors
- License
- Acknowledgements
What is l2?
l2 is named after the l2 or Euclidean distance, a popular distance function in deep learning
l2 is a Pytorch-style Tensor+Autograd library written in Rust. It contains a multidimensional array class, Tensor, with support for strided arrays, numpy-style array slicing, broadcasting, and most major math operations (including fast, BLAS-accelerated matrix multiplication!). On top of this, l2 has a built-in efficient graph-based autograd engine that keeps track of all operations performed on a tensor and topologically sorts and traverses the graph to compute the gradients.
I also made a more simplified C++ version of l2 last year, which you can take a look at here
Quick start
Add l2 = "1.0.3" to your Cargo.toml file and add the following to main.rs
Read the full README
Note: L2 will by default use Apple's
acclerateBLAS library on macOS You can also change the BLAS library that you want to use yourself. Take a look at theblas-srccrate for more information
use l2::tensor::*;
let x: Tensor = Tensor::normal(&[2, 4], 0.0, 1.0)?;
let y: Tensor = Tensor::normal(&[4, 1], 0.0, 1.0)?;
let z: Tensor = l2::matmul(&x, &y)?;
z.backward();
println!("{}", z);
Design choices
I made l2 to get better at using Rust and to learn more about how libraries like Pytorch and Tensorflow work behind the scenes, so don't expect this library to be production-ready :)
l2 is surprisingly fast especially since I didn't try very hard to optimize all the operators, it's usually only less than one order of magnitude slower than Pytorch in most of the benchmarks that I ran. l2 only supports a cpu backend at the moment since I'm not familiar enough with rust to start working with CUDA and cudnn. So far, l2 doesn't have any Pytorch-style abstractions like the Parameter, Layer, or Module classes. There might still be some bugs in the transpose operators and calling .backward() on tensors with more dimensions. I was interested in using Rust's Const Generics to run compile-time shape checks but I decided to leave it until some other time.
Contributing
This repository is still a work in progress, so if you find a bug, think there is something missing, or have any suggestions for new features, feel free to open an issue or a pull request. Feel free to use the library or code from it in your own projects, and if you feel that some code used in this project hasn't been properly accredited, please open an issue.
Authors
- Bilal Khan
License
This project is licensed under the MIT License - see the license file for details
Acknowledgements
The fast.ai deep learning from the foundations course (https://course.fast.ai/part2) teaches a lot about how to make your own deep learning library
Some of the resources that I found useful when working on this library include:
- http://blog.ezyang.com/2019/05/pytorch-internals/
- https://pytorch.org/tutorials/beginner/nn_tutorial.html
- https://eisenjulian.github.io/deep-learning-in-100-lines/
- https://medium.com/@florian.caesar/how-to-create-a-machine-learning-framework-from-scratch-in-491-steps-93428369a4eb
- https://medium.com/@johan.mabille/how-we-wrote-xtensor-1-n-n-dimensional-containers-f79f9f4966a7
- https://erikpartridge.com/2019-03/rust-ml-simd-blas-lapack
- https://medium.com/@GolDDranks/things-rust-doesnt-let-you-do-draft-f596a3c740a5
- https://datascience.stackexchange.com/questions/20139/gradients-for-bias-terms-in-backpropagation
- https://cs231n.github.io/optimization-2/
- https://cs231n.github.io/neural-networks-case-study/#grad
- https://stackoverflow.com/questions/38082835/backpropagation-in-gradient-descent-for-neural-networks-vs-linear-regression
- https://medium.com/@karpathy/yes-you-should-understand-backprop-e2f06eab496b
- https://stackoverflow.com/questions/38082835/backpropagation-in-gradient-descent-for-neural-networks-vs-linear-regression
- https://github.com/karpathy/micrograd
- https://rufflewind.com/2016-12-30/reverse-mode-automatic-differentiation
- https://github.com/ibab/rust-ad
- https://github.com/Rufflewind/revad/blob/eb3978b3ccdfa8189f3ff59d1ecee71f51c33fd7/revad.py
- https://github.com/srirambandi/ai
- https://discuss.pytorch.org/t/is-pytorch-autograd-tape-based/13992/3
- https://www.reddit.com/r/MachineLearning/comments/8ep130/d_how_does_autograd_work/
- https://github.com/mattjj/autodidact
- https://github.com/karpathy/recurrentjs
- https://github.com/karpathy/randomfun
- https://medium.com/@ralphmao95/simple-autograd-implementation-understand-automatic-differentiation-hand-by-hand-9e86f6d703ab
- https://evcu.github.io/ml/autograd/
- https://blog.paperspace.com/pytorch-101-understanding-graphs-and-automatic-differentiation/
- https://github.com/maciejkula/wyrm
- https://medium.com/@maciejkula/building-an-autodifferentiation-library-9ccf32c7a658
- https://github.com/evcu/numpy_autograd/blob/master/my_autograd.py#L147
- https://github.com/evcu/numpy_autograd/blob/master/Autograd.ipynb
- https://cs231n.github.io/optimization-2/
- https://github.com/explosion/thinc
- https://github.com/joelgrus/joelnet
- https://github.com/QuantStack/xtensor
- https://github.com/ThinkingTransistor/Sigma
- https://github.com/mratsim/Arraymancer
- https://github.com/siekmanj/sieknet
- https://github.com/siekmanj/sieknet_2.0
- https://github.com/Daniel-Liu-c0deb0t/Java-Machine-Learning
- https://github.com/karpathy/micrograd
This README is based on:
- https://github.com/bilal2vec/pytorch_zoo
- https://github.com/bilal2vec/grover
- https://github.com/rish-16/gpt2client
- https://github.com/mxbi/mlcrate
- https://github.com/athityakumar/colorls
- https://github.com/amitmerchant1990/electron-markdownify
I used carbon.now.sh with the "Shades of Purple" theme for the screenshot at the beginning of this README
This project contains ~4300 lines of code
Compatibility
- License
- MIT
- Crate facts
- Not measured
- Runs on, Native code and Python bindings read crates on crates.io. This entry lists no crate.
Compare with similar projects
Order: strongest tier first, then most downloads, then name, with unmeasured values last. A library counts downloads over 30 days. An app counts binary downloads per release. An app with none counts its crate downloads over 30 days. ML Rust runs this catalogue, so its closest project always gets a row.
| Project | Downloads | Dependents | Stars | Latest release | Runs on (GPU) | Native code | License |
|---|---|---|---|---|---|---|---|
|
l2 is a fast, Pytorch-style Tensor+Autograd library written in Rust |
0 binary downloads per release | Not applicable | 197 | Not measured | Not measured | MIT | |
|
burn Featured
Flexible and Comprehensive Deep Learning Framework in Rust |
521,465 downloads over 30 days | 391 | 16,257 | 0.22.1 | CUDA, WebGPU, Metal, ROCm, Vulkan | Binds native code: netlink-sys (feature iroh), nvml-wrapper-sys (feature sys-metrics), torch-sys (feature tch) | Apache-2.0 OR MIT |
|
Ergonomic auto differentiation in Rust, with pytorch like apis. |
2,369 downloads over 30 days | 4 | 1,944 | 0.13.0 | CUDA | No native code found | Apache-2.0 OR MIT |
|
boostr Listed
ML framework on numr for training and inference on CPU, CUDA and WebGPU: attention, quantization, inference scheduling and distributed execution. Models include LLaMA, Mamba2, Qwen3.5, Whisper, Kokoro, VITS, VoxCPM2, Silero VAD, CLAP and super-resolution. Loads SafeTensors and GGUF. |
1,265 downloads over 30 days | 7 | 20 | 0.11.2 | CUDA, WebGPU | Binds native code: ring (feature distributed) | Apache-2.0 |
|
rust-autograd Listed
Tensors and differentiable operations in Rust |
121 downloads over 30 days | 0 | 504 | 1.1.1 | GPU support unknown | Binds native code: intel-mkl-src (feature mkl) | MIT |
|
A machine learning library for Rust. |
25 downloads over 30 days | 0 | 333 | 0.2.1 | GPU support unknown | Binds native code: curl-sys (feature mnist), libz-sys (feature mnist) | Apache-2.0 OR MIT |
|
A learning-focused, high-performance tensor computation library built from scratch in Rust, featuring automatic differentiation and CPU/CUDA backends. |
Not measured | Not applicable | 79 | Not measured | Not measured | Not measured | MIT |
Why ListedNo archive, New or Featured rule places it, so it is Listed.
What it lacks for Featured
- The project is dormant and not finished. Dormancy rule
What else the check found
- The last activity is on 19 Feb 2022, 1724 days ago. That reaches the 365 days the rules expect, so the project is dormant. Dormancy rule
Not measured: Unpatched vulnerabilities past the grace window, First release.
Check notes
- Repology has no project l2
Exact rules: Listed, Featured app. The check on applied thresholds version 9.
Every rule outcome, as the check records it
expected-interval: app: E = 365 daysdormancy: last activity 2022-02-19, 1724 days ago, E = 365: dormantfeatured: not featured: dormant and not stablelisted: listed: no archive, new or featured rule applies
Measurements and sources
Each signal row shows the raw value, its source and the fetch date. The Sources list gathers every distinct source on this page. Movement needs more history.
Sources4 sources
- Description: the GitHub repository description
- GitHub releases, fetched
- GitHub repository, fetched
- GitHub contributors, fetched
Adoption0 binary downloads per release4 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Active dependents | Not measured | Yes | ||
| New dependents (365 days) | Not measured | Yes | ||
| Peak active dependents | Not measured | Yes | ||
| Active dependents as a share of the peak | Not measured | Yes | ||
| Binary downloads per release | 0 | GitHub releases | Yes |
MaintenanceLatest human commit: 4 years ago7 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Latest human commit | 2022-02-19 | GitHub repository | Yes | |
| Latest release | 2019-09-04 | GitHub releases | Yes | |
| First release | Not measured | Yes | ||
| Latest version | Not measured | Yes | ||
| Days the oldest outside issue waits for a reply | 0 | GitHub repository | Yes | |
| Maintainer replies over 365 days | 0 | GitHub repository | Yes | |
| Repository archived | false | GitHub repository | Yes | |
| Repository gone | false | GitHub repository | Yes | |
| Release commit or manifest in the repo | Not measured | Yes | ||
| Published docs | Not measured | Yes | ||
| Latest release fails cargo check | Not measured | Yes | ||
| Build check date | Not measured | Yes | ||
| Build check toolchain | Not measured | Yes |
SecurityNot measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Unpatched vulnerabilities past the grace window | Not measured | Yes | ||
| RustSec unmaintained advisory | Not measured | Yes | ||
| Deprecation notice | Not measured | Yes | ||
| Deprecated requirement | Not measured | Yes |
Distribution0 binary downloads over the last 3 releases10 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| Releases | Not measured | Yes | ||
| Downloads over 30 days | Not measured | Yes | ||
| Binary downloads over the last 3 releases | 0 | GitHub releases | Yes | |
| Homebrew installs on request over 365 days | Not measured | Yes | ||
| Repology repository families | Not measured | Yes | ||
| Docker pull growth over 90 days | Not measured | Yes | ||
| Docker pulls at the growth baseline | Not measured | Yes | ||
| Every version a prerelease | Not measured | Yes | ||
| Every version 0.0.x | Not measured | Yes | ||
| Every version yanked | Not measured | Yes | ||
| Crate deleted from crates.io | Not measured | Yes |
Repository197 stars, 19 forks, 1 contributors, 165 commits. Stars alone never qualify a project.1 not measured
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| GitHub stars | 197 | GitHub repository | Yes — one part of the repository route | |
| GitHub forks | 19 | GitHub repository | Yes — one part of the repository route | |
| Contributors with a GitHub account | 1 | GitHub contributors | Yes — one part of the repository route | |
| Commits on the default branch | 165 | GitHub repository | No | |
| Repository's main crate left out of the entry | Not measured | Yes |
Facts that never count
| Signal | Value | Source | Fetched | Counts |
|---|---|---|---|---|
| License | MIT | GitHub repository | No | |
| Runs on, from listed crates and their direct dependencies | Not measured | No | ||
| What shows each backend | Not measured | No | ||
| Native code, from listed crates and their dependencies | Not measured | No | ||
| Python bindings, from direct dependencies of listed crates | Not measured | No | ||
| Crates that depend on a listed crate directly | Not measured | No |
Corrections and review history
No correction applies to this entry.
Judgments
A judgment enters only through an approved issue and a merged pull request.
No judgment applies to this entry.