TrenTorch README

The project's README from github.com/TrenTorch/TrenTorch. As one markdown file: README.md.

TrenTorch pulsing bolt mark

Tren⚡Torch

Validate Contributors CodeFactor Python License Built From Scratch Status

Most people learn ML frameworks by importing them. We built ours by hand, then made it hit harder.

Quick Start · The Vision · 20 Modules · Milestones


[!NOTE] This is our implementation of TinyTorch (Harvard CS249r), rebuilt in our own style and pushed further. Same bones, more muscle.


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.

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

🎯 Mission: NLP - we teach NLP

🎯 Mission: LLM - we teach LLM

🎯 Mission: Inference - we teach Inference

🎯 Mission: LLMOps - we teach LLMOps

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?


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:

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.

maanas1234
maanas1234
Core Engineer
Catches bugs, builds solutions and ships products
Issues: 11 · PRs: 12
Aadityansha
Aadityansha
Maintainer
Reducing CPU stalls, one commit at a time.
Issues: 0 · PRs: 1
Rocky
Rocky
Principal Maintainer
IIT Guwahati, Debugs autograd for fun, ships before sunrise.
Issues: 12 · PRs: 118
Shivtej Gaikwad
Shivtej Gaikwad
Maintainer
IIT Guwahati. Shows up, ships, moves on to the next thing.
Issues: 0 · PRs: 7
MahekPatel-2403
MahekPatel-2403
Spots bugs, corrects them and contributes
Issues: 0 · PRs: 1

License

MIT License - see LICENSE for details.

Code of Conduct

This project follows the Contributor Covenant. Participation in issues, pull requests, and discussions is expected to stay within it.


Start Small. Go Deep. Then Add Weight.

TrenTorch (TrenTorch/TrenTorch)

Searching Database…

Что это?TrenTorch — ML-фреймворк и учебная программа, написанные с нуля поверх гарвардского TinyTorch (CS249r): те же обучающие блоки, но развитые дальше, с более чистой внутренней архитектурой и большим числом модулей, покрывающих глубокое обучение, CNN, трансформеры и инференс.
Нужны ли установленные PyTorch или TensorFlow?Нет, весь фреймворк реализован только на чистом NumPy, с нулевой зависимостью от PyTorch или TensorFlow.
Локальная установка сейчас полностью отполирована?Локальная установка работает, но сам README предупреждает «взять страхующего», а полировка документации и укрепление краевых случаев всё ещё значатся как незавершённые.
Для кого предназначена эта учебная программа?Для инженеров и учащихся, которые хотят глубоко понимать внутренности ML, а не просто вызывать функции библиотек, включая готовящихся к интервью по ML-системам.
Где это работает?Работает как локальный CLI в терминале на любой машине с Python, поскольку об ограничениях по ОС ничего не говорится.
Что на самом деле строят 20 модулей?Они сгруппированы в четыре части: Foundations (тензоры, autograd, оптимизаторы), Vision (Conv2d/CNN), Language (токенизация, эмбеддинги, трансформеры) и Optimization (профилирование, квантизация, ускорение, финальный проект).
Что за исторические вехи, которые вы открываете?По мере продвижения вы воссоздаёте вехи ML на собственном фреймворке: от перцептрона 1958 года и XOR-кризиса 1969-го через backpropagation 1986 года, CNN 1998-го и трансформеры 2017-го вплоть до production-оптимизации в духе MLPerf.
Чем TrenTorch отличается от оригинального TinyTorch?Он использует ту же учебную программу и основу, созданные гарвардским TinyTorch (проф. Vijay Janapa Reddi), но перестраивает их с более чистой внутренней архитектурой, более резкой производительностью и дополнительными экспериментальными модулями, вышедшими за исходную спецификацию.
Зачем писать свой ML-фреймворк вместо того, чтобы просто использовать PyTorch?Цель — глубокое понимание: точно знать, что делает loss.backward(), мыслить категориями памяти и вычислений, а не абстракций, и уметь отлаживать на уровне тензоров — навыки, которые приходят от написания механизма своими руками.
Creator
TrenTorch
Size
58.9 MB
Stars
559
Age
1mo
Commits · 90 Days