GitHub

Quick Start

# macOS / Linux
git clone https://github.com/TrenTorch/TrenTorch.git
cd TrenTorch
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install -e .
tren setup
tren
# Windows (PowerShell)
git clone https://github.com/TrenTorch/TrenTorch.git
cd TrenTorch
python -m venv .venv
.venv\Scripts\Activate.ps1
pip install -r requirements.txt
pip install -e .
tren setup
tren

tren setup will ask to add tren to your PATH: say yes, and every terminal after that just needs tren, from any directory, with no activating first.


Why TrenTorch?

Be the best engineer yourself !

We wanted to know. So we built one. Then we didn't stop at "good enough."

The Bricks ๐Ÿงฑ

TinyTorch teaches the fundamentals. TrenTorch takes those same bricks and adds the reps: cleaner internals, sharper performance instincts, and an implementation pushed past the original spec wherever we saw the chance.

  • Small enough to read in one sitting - every op traceable back to raw NumPy
  • Big enough to actually flex - the real architecture real frameworks run on
  • Ours - rebuilt, refactored, and hardened in our own hands

No black boxes. No import torch. Just the machinery, exposed.


What You'll Build

A complete ML framework, built from zero. No single finish line, a set of missions you clear on the way there:

๐ŸŽฏ Mission: Image - we teach Image

  • Real computer vision on standard benchmarks
  • Conv2d, pooling, and CNNs, built entirely from scratch on NumPy
  • Performance that holds its own against the frameworks it's built to demystify

๐ŸŽฏ Mission: NLP - we teach NLP

  • Tokenization, embeddings, and multi-head attention, hand-rolled
  • The groundwork every language model stands on

๐ŸŽฏ Mission: LLM - we teach LLM

  • Full GPT-style transformer blocks, not a wrapper around someone else's
  • Real self-attention, real language generation

๐ŸŽฏ Mission: Inference - we teach Inference

  • Profiling, quantization, and acceleration, so your model doesn't just train, it runs
  • KV-cache and memoization for the speed that production demands

๐ŸŽฏ Mission: LLMOps - we teach LLMOps

  • Modern optimizers with learning rate scheduling: SGD, Adam, AdamW, Lion, Muon
  • Competitive benchmarking and the capstone that ties it all together

Zero PyTorch. Zero TensorFlow. Every line is ours.


Current Status

ReadyIn ProgressComing Soon
โœ… All 20 modules implemented๐Ÿ”ง Documentation polish๐Ÿ“… Community leaderboard
โœ… Module, CLI, integration, and milestone tests๐Ÿ”ง Edge case hardening๐Ÿ“… More milestone exercises
โœ… tren CLI for workflows๐Ÿ”ง Performance tuning passes๐Ÿ“… More milestones beyond MLPerf
โœ… Historical milestone scripts

Want to explore the code? Browse the repository structure.

Adventurous? Local installation works, but bring a spotter. See the setup notes on the wiki's Getting Started page.


๐Ÿ— 20 Progressive Modules

Build your framework through four progressive parts:

PartModulesWhat You Build
I. Foundations01-08Tensors, activations, layers, losses, dataloader, autograd, optimizers, training
II. Vision09Conv2d, CNNs for image classification
III. Language10-13Tokenization, embeddings, attention, transformers
IV. Optimization14-20Profiling, quantization, compression, acceleration, memoization, benchmarking, capstone

Each module asks one question: "Can I build this from scratch, and can I build it well?"


๐Ÿ† Historical Milestones

As you progress, you unlock recreations of landmark ML achievements, run on YOUR framework:

YearMilestoneYour Achievement
1958PerceptronBinary classification with gradient descent
1969XOR CrisisMulti-layer networks solve non-linear problems
1986BackpropagationMulti-layer network training
1998CNN RevolutionImage classification with convolutions
2017Transformer EraLanguage generation with self-attention
2018+MLPerfProduction-ready optimization

Not toy demos. Historically significant ML achievements, rebuilt with a framework we wrote ourselves.


Learning Philosophy

# Most courses:
import torch

model.fit(X, y)  # magic happens somewhere else

# TrenTorch:
# You implement every component
# You measure memory usage
# You optimize performance
# You own every layer of the stack

Why build your own framework?

  • Deep understanding - know exactly what loss.backward() does, because you wrote it
  • Systems thinking - memory, compute, and scaling stop being abstractions
  • Debugging at any depth - fix problems at the model level or the tensor level
  • Production instincts - the same patterns real ML systems run on

Repository Structure

TrenTorch/
โ”œโ”€โ”€ data/
โ”‚   โ”œโ”€โ”€ src/                     # ๐Ÿ’ป Curriculum source (edit here)
โ”‚   โ”‚   โ”œโ”€โ”€ 01_tensor/           # Module 01: Tensor operations from scratch
โ”‚   โ”‚   โ”œโ”€โ”€ 02_activations/      # Module 02: ReLU, Softmax activations
โ”‚   โ”‚   โ”œโ”€โ”€ 03_layers/           # Module 03: Linear layers, Module system
โ”‚   โ”‚   โ”œโ”€โ”€ 04_losses/           # Module 04: MSE, CrossEntropy losses
โ”‚   โ”‚   โ”œโ”€โ”€ 05_dataloader/       # Module 05: Efficient data pipelines
โ”‚   โ”‚   โ”œโ”€โ”€ 06_autograd/         # Module 06: Automatic differentiation
โ”‚   โ”‚   โ”œโ”€โ”€ 07_optimizers/       # Module 07: SGD, Adam optimizers
โ”‚   โ”‚   โ”œโ”€โ”€ 08_training/         # Module 08: Complete training loops
โ”‚   โ”‚   โ”œโ”€โ”€ 09_convolutions/     # Module 09: Conv2d, MaxPool2d, CNNs
โ”‚   โ”‚   โ”œโ”€โ”€ 10_tokenization/     # Module 10: Text processing
โ”‚   โ”‚   โ”œโ”€โ”€ 11_embeddings/       # Module 11: Token & positional embeddings
โ”‚   โ”‚   โ”œโ”€โ”€ 12_attention/        # Module 12: Multi-head attention
โ”‚   โ”‚   โ”œโ”€โ”€ 13_transformers/     # Module 13: Complete transformer blocks
โ”‚   โ”‚   โ”œโ”€โ”€ 14_profiling/        # Module 14: Performance analysis
โ”‚   โ”‚   โ”œโ”€โ”€ 15_quantization/     # Module 15: Model compression (precision reduction)
โ”‚   โ”‚   โ”œโ”€โ”€ 16_compression/      # Module 16: Pruning & distillation
โ”‚   โ”‚   โ”œโ”€โ”€ 17_acceleration/     # Module 17: Hardware optimization
โ”‚   โ”‚   โ”œโ”€โ”€ 18_memoization/      # Module 18: KV-cache/memoization
โ”‚   โ”‚   โ”œโ”€โ”€ 19_benchmarking/     # Module 19: Performance measurement
โ”‚   โ”‚   โ””โ”€โ”€ 20_capstone/         # Module 20: Complete ML systems
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ modules/                 # ๐Ÿ““ Generated notebooks (learn here, stub-only)
โ”‚   โ”‚   โ””โ”€โ”€ ...                  # (20 module directories)
โ”‚   โ”œโ”€โ”€ solutions/                # ๐Ÿ”’ Reference implementations (maintainer/CI-only)
โ”‚   โ”œโ”€โ”€ datasets/                 # ๐Ÿ—‚๏ธ Curated training data (tinydigits, tinytalks)
โ”‚   โ”œโ”€โ”€ milestones/                # ๐Ÿ† Historical ML evolution - prove what you built
โ”‚   โ”‚   โ”œโ”€โ”€ 01_1958_perceptron/
โ”‚   โ”‚   โ”œโ”€โ”€ 02_1969_xor/
โ”‚   โ”‚   โ”œโ”€โ”€ 03_1986_mlp/
โ”‚   โ”‚   โ”œโ”€โ”€ 04_1998_cnn/
โ”‚   โ”‚   โ”œโ”€โ”€ 05_2017_transformer/
โ”‚   โ”‚   โ””โ”€โ”€ 06_2018_mlperf/
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ trentorch/                # ๐Ÿ“ฆ Generated package (import from here)
โ”‚       โ”œโ”€โ”€ core/                  # Core ML components
โ”‚       โ””โ”€โ”€ ...                    # The framework you built
โ”‚
โ”œโ”€โ”€ platforms/
โ”‚   โ”œโ”€โ”€ cli/                     # ๐ŸŽ›๏ธ The `tren` CLI itself
โ”‚   โ”‚   โ”œโ”€โ”€ main.py               # Entry point
โ”‚   โ”‚   โ”œโ”€โ”€ core/                  # Shared plumbing: config, console, theme, runtime
โ”‚   โ”‚   โ”œโ”€โ”€ commands/               # Genuinely shared code only: base.py, export_utils.py, jupyter.py
โ”‚   โ”‚   โ”œโ”€โ”€ cli_platform/           # The CLI's own bootstrap: setup, system, package, dev tooling
โ”‚   โ”‚   โ”œโ”€โ”€ processes/               # The student-facing workflow: module_workflow, milestone, benchmark, olympics, convert
โ”‚   โ”‚   โ””โ”€โ”€ tests/                    # The CLI's own test suite
โ”‚   โ””โ”€โ”€ dev_tools/                # Maintainer scripts (release, fresh-install verification)
โ”‚
โ”œโ”€โ”€ user_data/                  # ๐Ÿ—ƒ๏ธ Your own progress, milestones, benchmarks (not committed)
โ”‚
โ””โ”€โ”€ tests/                      # โœ… Integration, e2e, and environment tests

Key workflow: data/src/*.py โ†’ data/modules/*.ipynb (you solve it) โ†’ data/trentorch/*.py


Credit Where It's Due

TrenTorch is our implementation, built on the curriculum and foundation of TinyTorch, created by Prof. Vijay Janapa Reddi and the ML Systems Book community at Harvard University. Full respect to the original project, we just wanted to take it further.

Related educational frameworks worth knowing about:

  • tinygrad - George Hotz's minimalist framework
  • micrograd - Andrej Karpathy's tiny autograd
  • MiniTorch - Cornell's educational framework

We're addicted to making great software that runs (we're a bit of perfectionists ourselves) and is useful to humanity. This is our shot at making TinyTorch, but adding more stuff that is currently experimental and quite famous.


Team Engineers

Recomputed nightly from real issue/PR activity via .github/workflows/update-contributors.yml. Want to show up here? Open an issue or a PR: the first-contribution bot will say hello, and this grid picks you up on the next nightly run.

Aadityansha
Aadityansha
Maintainer
Reducing CPU stalls, one commit at a time.
Issues: 0 ยท PRs: 1
maanas1234
maanas1234
Core Engineer
Catches bugs, builds solutions and ships products
Issues: 11 ยท PRs: 12
Rocky
Rocky
Principal Maintainer
IIT Guwahati, Debugs autograd for fun, ships before sunrise.
Issues: 9 ยท PRs: 73
Shivtej Gaikwad
Shivtej Gaikwad
Maintainer
IIT Guwahati. Shows up, ships, moves on to the next thing.
Issues: 0 ยท PRs: 7

License

MIT License - see LICENSE for details.


Start Small. Go Deep. Then Add Weight.