SkillAgentSearch skills...

Tinytorch

A really tiny autograd engine

Install / Use

/learn @joey00072/Tinytorch
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

tinytorch

Newest ML framework that you propbaly don't need, <br> this is really autograd engine backed by numpy<br><br>

tinytorch.py shall always remain under <b>1000 lines</b>. if not we will <i>revert commit</i>

Python package

$$ f(x) =x^3+x $$

import tinytorch as tt      #👀

def f(x):
  return x**3 + x

x = tt.tensor((tt.arange(700) - 400)/100 , requires_grad=True)
z = f(x)
z.sum().backward()
print(x.grad)

<p align="center"> <img src="images/image-1.png" alt="Alt text" width="70%"> </p> <p align="center"> <img src="images/image.png" alt="Alt text"> </p>

What can you do with it?

Automatic diffecrtion, yep

import tinytorch as tt 

def f(x,y):
  return x**2 + x*y + (y**3+y) **0.5

x = tt.rand((5,5), requires_grad=True)
y = tt.rand((5,5), requires_grad=True)
z = f(x,y)
z.sum().backward()
print(x.grad)
print(y.grad)

Train MNITST, no problemo

python mnist.py

Open In Colab

GPT?? you bet (yes LLM fr fr)

GPU=1 python mnist.py

Open In Colab

note: numpy is too slow to train llm you need to install jax (just using it as faster numpy)

Visulization

If you want to see your computation graph run visulize.py

requirements

pip install graphviz
sudo apt-get install -y graphviz # IDK what to do for windows I use wsl
<p align="center"> <img src="images/image-2.png" width="50%" > </p>

why this exists

Bcs I was bored

DEV BLOG

powerlevel

1.0 - karpathy micrograd (really simple, not much you can do with it) <br> 3.14 - tinytorch (simpile and you can do lot of things with it) <= ❤️ <br> 69 - tinygrad (no longer simple you can do lot more)<br> ∞ - pytorch (goat library, that makes gpu go burrr)<br>

contribution guideline

  • be nice
  • performance optimization / more examples welcome
  • doc sources if any
  • keep tinytorch.py under 1000 lines

Buy me Chai/Coffee

ko-fi

License

MIT

Related Skills

View on GitHub
GitHub Stars100
CategoryDevelopment
Updated1mo ago
Forks3

Languages

Python

Security Score

95/100

Audited on Feb 26, 2026

No findings