Marco-Christiani/zigrad
A deep learning framework built on an autograd engine with high level abstractions and low level control.
https://github.com/user-attachments/assets/3842aa72-9b16-4c25-8789-eac7159e3768
Fast
2.5x+ speedup over a compiled PyTorch model on Apple Silicon, 1.5x on x86. Expect similar performance gains across more architectures and platforms as MKL/CUDA support improves and Zigrad's ML graph compiler is operational.*
*Tensorflow excluded for scaling purposes (too slow). A hermetic, reproducible benchmarking pipeline built on Bazel will allow testing across more platforms (in progress, testers needed).
Built for specialized optimization
Zigrad's design enables deep control and customization
But wait, there's more..
ReleaseFast
mode and under 200kb in ReleaseSmall
.*Not yet merged
An example of tracing the computation graph generated by a fully connected neural network for MNIST.
28x28 -> 784
784 -> 128
128 -> 64
64 -> 10
We did not have to use Zigrad's modules to write this network at all, as Zigrad is backed by a capable autograd engine. Even when using the autograd backend to dynamically construct the same neural network Zigrad can still trace the graph and render it.
Note: Since the graph is generated from the autograd information, we set the labels for the nodes by naming the tensors for the sake of the diagram.
Only dependency is a BLAS library.
On linux (or intel mac) you have some options,
conda
for example, just make sure you adjust the library paths as necessary.libopenblas-dev
or openblas-devel
The examples/
directory has some standalone templates you can take and modify, the zon files are pinned to commit hashes.
Hello world example shows how to run a backward pass using the GraphManager.
Note that in this very simple example, we do not need the GraphManager
and the script could be simplified but this is designed to get you familiar with the workflow.
git clone https://github.com/Marco-Christiani/zigrad/
cd zigrad/examples/hello-world
zig build run
Run the mnist demo
cd zigrad/examples/mnist
make help
make
A lot is planned and hoping for support from the Zig community so we can accomplish some of the more ambitious goals.