Skip to main content

Simple Deep Learning library for educational purposes

Project description

EaZyGrad Logo

EaZyGrad

EaZyGrad is a small educational python-only deep learning library built to make automatic differentiation easy to read, inspect, and extend. It only uses numpy as the building block, with a sprinkle of numba compilation for speed. This is similar in spirit to karphathy's micrograd but it operates on Tensor instead of scalar values. George Hotz's tinygrad is also an inspiration but EaZyGrad will focus on readibility and simplicity. The goal is not to compete with the army of extremely talented engineers who built PyTorch but to help understand the pieces behind libraries like PyTorch:

  • tensor objects,
  • dynamic computation graphs,
  • backward propagation,
  • neural network modules,
  • optimizers.

The project first started as me trying to figure out how Hessian-vector product are computed in practice. We aren't there yet but it still implement Jacobian-vector product to compute backpropagation (reverse-mode autodiff). The current API is as robust and reliable as an overfitted model on production so expect bugs and weird behaviors. Make sure to checkout the examples to see the versatility of the autograd engine. See the project page for the API and other, hopefully, interesting stuff.

Installation

Install from PyPI:

pip install eazygrad

For development:

git clone https://github.com/sabeaussan/EaZyGrad.git
cd EaZyGrad
pip install -e ".[dev]"

System Requirements

  • Python >=3.10, <3.14
  • NumPy >=2.3.0
  • Numba >=0.63.1
  • Graphviz
  • Pillow
  • Matplotlib
  • tqdm

Development and validation tools:

  • PyTorch
  • pytest
  • hypothesis
  • Sphinx
  • Furo

What EaZyGrad Looks Like

1. Basic autograd

import eazygrad as ez

x = ez.tensor([1.0, 2.0, 3.0], requires_grad=True)
y = (x * x).mean()
y.backward()

print("y =", y.numpy())
print("grad =", x.grad)

This example shows the core workflow:

  1. create tensors,
  2. build a computation graph through normal tensor operations,
  3. call backward(),
  4. inspect grad.

2. Small neural network

import eazygrad as ez
import eazygrad.nn as nn

class MLP(nn.Module):
    def __init__(self):
        super().__init__()
        self.fc1 = nn.Linear(2, 16)
        self.fc2 = nn.Linear(16, 1)

    def forward(self, x):
        return self.fc2(ez.relu(self.fc1(x)))

model = MLP()
optimizer = ez.Adam(model.parameters(), lr=1e-3)

This is intentionally close to the way you would write the same code in PyTorch.

How The Library Is Organized

The easiest way to navigate the project is to follow the same path as a forward and backward pass:

Core tensor and graph

User-facing API

Data and utilities

How To Read The Code

If you are new to autograd internals, this order works well:

  1. Read eazygrad/tensor_factories.py to see how tensors enter the system.
  2. Read eazygrad/_tensor.py to understand the public tensor API.
  3. Read eazygrad/grad/computation_graph.py to see how graph nodes are stored and traversed.
  4. Read eazygrad/grad/operations.py to see how each operation implements its backward rule.
  5. Read eazygrad/nn/linear.py and eazygrad/optimizer.py to connect autograd to learning.
  6. Run one of the examples and compare the training loop to a PyTorch equivalent.

Examples Included In The Repository

Supervised learning

Unsupervised learning

Reinforcement learning

Current Scope And Limitations

EaZyGrad is intentionally small and educational. That also means there are limitations:

  • the API surface is still compact,
  • some production-grade features are not implemented yet (gpu support),
  • performance is not the primary objective,
  • a few internals are still evolving.

Known limitation:

  • detached graph memory management is not fully solved yet, so detach() is intentionally not exposed as a working feature.

Roadmap

Planned next steps:

  • Implement Conv2d
  • Implement batch normalization
  • Implement attention layers
  • Add GPU support (Triton perhaps)
  • Add higher-order grad computation
  • Improve graph lifetime management and memory behavior
  • Expand module coverage and tests
  • Add more tutorial-style examples

Contributing

Issues, design discussions, documentation improvements, and small teaching-oriented features are all welcome.

If you contribute, prioritize:

  • readability,
  • correctness,
  • small focused abstractions,
  • examples and tests that help explain the behavior.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

eazygrad-0.0.2.tar.gz (45.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

eazygrad-0.0.2-py3-none-any.whl (32.7 kB view details)

Uploaded Python 3

File details

Details for the file eazygrad-0.0.2.tar.gz.

File metadata

  • Download URL: eazygrad-0.0.2.tar.gz
  • Upload date:
  • Size: 45.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for eazygrad-0.0.2.tar.gz
Algorithm Hash digest
SHA256 64f386a7ee3951ca8ab2f04a383c803ee94e9fa2a28674ad3cb6398c41aa947d
MD5 8fbb4f2a2b5c4e32aa5a140d2f824293
BLAKE2b-256 e71bbe691c0e4d3cffd874799fa5856b29f543e260e63d915d98bdd5d7fde484

See more details on using hashes here.

File details

Details for the file eazygrad-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: eazygrad-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 32.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for eazygrad-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5a3d458045969fc62ae4ff0b1c6470545b8586223b10ca7b839597752baf3c59
MD5 09e47a3fcd1f1157e2b7607d50493ac2
BLAKE2b-256 8c36b867d958fb460f5253cc41d60efe31dc9bb2f79b9d244fb4940cdeaf9eb4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page