Tren⚡Torch
Most people learn ML frameworks by importing them. This one is built by hand.
TrenTorch is a from-scratch machine learning framework, built one module at a time on nothing but NumPy: tensors and autograd, layers and losses, a dataloader, optimizers, a full training loop, CNNs, tokenization, embeddings, attention, transformers, and then the systems layer on top: profiling, quantization, compression, acceleration, memoization, benchmarking. No import torch. Every line is yours.
This is a personal, from-scratch implementation of TinyTorch (Harvard CS249r), rebuilt independently and pushed further, with cleaner internals, a much faster CI pipeline, and an implementation extended past the original spec wherever there was room to.
Where to go
| Page | What's there |
|---|---|
| Getting Started | Clone, install, and run your first module |
| Curriculum & Milestones | The 20 modules and the 6 historical milestones you unlock along the way |
| CLI Reference | Every tren command, condensed |
| Architecture | How a student's edit becomes a real, importable symbol, the short version |
| Contributing | How to set up a dev environment and submit changes |
The shape of it
You don't import a framework here, you build one, in order:
- Foundations (modules 01-08): tensors, activations, layers, losses, a dataloader, autograd, optimizers, a real training loop
- Vision (module 09): Conv2d, pooling, CNNs
- Language (modules 10-13): tokenization, embeddings, attention, transformer blocks
- Optimization (modules 14-20): profiling, quantization, compression, acceleration, memoization, benchmarking, and a capstone that ties it together
Along the way, six milestones let you re-run landmark moments in ML history: the 1958 perceptron, the 1969 XOR crisis, 1986 backpropagation, the 1998 CNN revolution, the 2017 transformer, and an MLPerf-style optimization round, on the framework you actually wrote.
Repository layout (current)
TrenTorch/
├── data/
│ ├── src/ # Curriculum source: 20_capstone/, 09_convolutions/, etc., edit here
│ ├── modules/ # Generated stub notebooks (what a student opens and solves)
│ ├── solutions/ # Reference implementations (maintainer/CI-only, gitignored)
│ ├── milestones/ # The six historical milestone scripts
│ └── trentorch/ # The real, importable package, built from your solved modules
├── platforms/
│ └── cli/ # The `tren` CLI itself (setup, module workflow, dev/CI tooling)
├── tests/ # Integration, e2e, and environment tests
├── docs/ # Deep technical docs: design, system architecture, CLI reference
└── bin/tren # Entry point
Everything under data/src/ is what you actually write; everything else is generated from it or drives the workflow around it.
Status
- All 20 modules implemented, with unit, integration, CLI, and milestone tests
- The
trenCLI drives the entire student and maintainer workflow - CI runs the full curriculum, every stage, on every push; see Architecture for how that pipeline works