Skip to main content

LeanPass

A tiny, NumPy-only reverse-mode autodiff library.
Not competing with PyTorch on features, competing on being lightweight and readable!.

pip install leanpass
Computation graph showing forward and backward pass

A small computation graph: forward pass, backward pass.

LeanPass exists because most autodiff libraries bury the mechanics under C++ kernels and JIT compilers. If you're trying to understandhow gradients flow through a neural network not justthat they flow, you need source code that fits in your head.

This is that library. ~500 lines of pure NumPy. Everybackward() call traces through the graph step by step. No magic, no abstraction layers, just vector calculus you can read line by line.