A scalar-valued automatic differentiation (autograd) engine for deep learning written in Zig.
Before attempting to build this project, make sure you have Nix with Flake support installed on your machine.
To get a local copy of the project up and running on your machine, follow these simple steps:
-
Clone the project repository
git clone https://github.com/Kaweees/kiwigrad.git cd kiwigrad -
Install the project dependencies
nix-shell --max-jobs $(nproc) # Linux / Windows (WSL) nix-shell --max-jobs $(sysctl -n hw.ncpu) # macOS
-
Build the project
just build
-
Run the project
just run
To include kiwigrad in your Zig project, follow these steps:
-
Add to your
build.zig.zonfile viazig fetch:zig fetch --save git+https://github.com/Kaweees/kiwigrad.git
-
Add the following line to your
build.zigfile:const kiwigrad = @import("kiwigrad"); pub fn build(b: *std.Build) void { // exe setup... const KiwiGrad_dep = b.dependency("kiwigrad", .{ .target = target, .optimize = optimize, }); const KiwiGrad_module = KiwiGrad_dep.module("kiwigrad"); exe.root_module.addImport("kiwigrad", KiwiGrad_module); // additional build steps... }
kiwigrad is designed to be easy to use. You can include the library in your Zig project by adding the following line to your source files:
const kiwigrad = @import("kiwigrad");kiwigrad is capable of rendering 3D scenes with thousands of triangles at interactive frame rates. The following benchmarks were conducted on a 2019 MacBook Pro with a 2.3 GHz 8-Core Intel Core i9 processor and 16 GB of RAM.
| Benchmark | Description | Result |
|---|---|---|
cube |
Render a cube with 12 triangles | 60 FPS |
sphere |
Render a sphere with 960 triangles | 60 FPS |
bunny |
Render a Stanford Bunny with 69451 triangles | 60 FPS |
dragon |
Render a Stanford Dragon with 871306 triangles | 60 FPS |
kiwigrad/
├── .github/ # GitHub Actions CI/CD workflows
├── src/ # Library source files
│ ├── lib.zig # Public API entry point
│ └── ...
├── examples/ # Example projects
│ ├── benchmark.zig # Benchmarking the library
│ └── train.zig # Training a model on MNIST
├── build.zig # Zig build script
├── build.zig.zon # Zig build script dependencies
├── LICENSE # Project license
└── README.md # You are hereThe source code for Kaweees/kiwigrad is distributed under the terms of the MIT License, as I firmly believe that collaborating on free and open-source software fosters innovations that mutually and equitably beneficial to both collaborators and users alike. See LICENSE for details and more information.

