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
| Ready | In Progress | Coming 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:
| Part | Modules | What You Build |
|---|---|---|
| I. Foundations | 01-08 | Tensors, activations, layers, losses, dataloader, autograd, optimizers, training |
| II. Vision | 09 | Conv2d, CNNs for image classification |
| III. Language | 10-13 | Tokenization, embeddings, attention, transformers |
| IV. Optimization | 14-20 | Profiling, 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:
| Year | Milestone | Your Achievement |
|---|---|---|
| 1958 | Perceptron | Binary classification with gradient descent |
| 1969 | XOR Crisis | Multi-layer networks solve non-linear problems |
| 1986 | Backpropagation | Multi-layer network training |
| 1998 | CNN Revolution | Image classification with convolutions |
| 2017 | Transformer Era | Language generation with self-attention |
| 2018+ | MLPerf | Production-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.
License
MIT License - see LICENSE for details.
Start Small. Go Deep. Then Add Weight.