GitHub
All wiki pages

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

PageWhat's there
Getting StartedClone, install, and run your first module
Curriculum & MilestonesThe 20 modules and the 6 historical milestones you unlock along the way
CLI ReferenceEvery tren command, condensed
ArchitectureHow a student's edit becomes a real, importable symbol, the short version
ContributingHow 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:

  1. Foundations (modules 01-08): tensors, activations, layers, losses, a dataloader, autograd, optimizers, a real training loop
  2. Vision (module 09): Conv2d, pooling, CNNs
  3. Language (modules 10-13): tokenization, embeddings, attention, transformer blocks
  4. 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 tren CLI drives the entire student and maintainer workflow
  • CI runs the full curriculum, every stage, on every push; see Architecture for how that pipeline works