Module Workflow#
Build ML Systems from Scratch
The core workflow for implementing and exporting TinyTorch modules
Purpose: Master the module development workflow - the heart of TinyTorch. Learn how to implement modules, export them to your package, and validate with tests.
The Core Workflow#
TinyTorch follows a simple build-export-validate cycle:
graph LR
A[Start/Resume Module] --> B[Edit in Jupyter]
B --> C[Complete & Export]
C --> D[Test Import]
D --> E[Next Module]
style A fill:#e3f2fd
style B fill:#fffbeb
style C fill:#f0fdf4
style D fill:#fef3c7
style E fill:#f3e5f5
Fig. 30 Module Development Workflow. The core cycle for building TinyTorch: start a module, edit in Jupyter, export to the package, test your imports, then move to the next module.#
The essential command: tito module complete XX - exports your code to the TinyTorch package
Follow this workflow to build ML systems from scratch.
Essential Commands#
Check Environment
tito system health
Verify your setup is ready before starting
Start a Module (First Time)
tito module start 01
Opens Jupyter Lab for Module 01 (Tensor)
Resume Work (Continue Later)
tito module resume 01
Continue working on Module 01 where you left off
Export & Complete (Essential)
tito module complete 01
Export Module 01 to TinyTorch package - THE key command
Check Progress
tito module status
See which modules you've completed
Typical Development Session#
Hereβs what a complete session looks like:
1. Start Session
cd TinyTorch
source activate.sh
tito system health # Verify environment
2. Start or Resume Module
# First time working on Module 03
tito module start 03
# OR: Continue from where you left off
tito module resume 03
This opens Jupyter Lab with the module notebook.
3. Edit in Jupyter Lab
# In the generated notebook
class Linear:
def __init__(self, in_features, out_features):
# YOUR implementation here
...
Work interactively:
Implement the required functionality
Add docstrings and comments
Run and test your code inline
See immediate feedback
4. Export to Package
# From repository root
tito module complete 03
This command:
Runs tests on your implementation
Exports code to
tinytorch/nn/layers.pyMakes your code importable
Tracks completion
5. Test Your Implementation
# Your code is now in the package!
python -c "from tinytorch import Linear; print(Linear(10, 5))"
6. Check Progress
tito module status
System Commands#
Environment Health#
Check Setup (Run This First)
tito system health
Verifies:
Virtual environment activated
Dependencies installed (NumPy, Jupyter, Rich)
TinyTorch in development mode
All systems ready
Output:
Environment validation passed
β’ Virtual environment: Active
β’ Dependencies: NumPy, Jupyter, Rich installed
β’ TinyTorch: Development mode
System Information
tito system info
Shows:
Python version
Environment paths
Package versions
Configuration settings
Start Jupyter Lab
tito system jupyter
Convenience command to launch Jupyter Lab from the correct directory.
Module Lifecycle Commands#
Start a Module (First Time)#
tito module start 01
What this does:
Opens Jupyter Lab for Module 01 (Tensor)
Shows module README and learning objectives
Provides clean starting point
Creates backup of any existing work
Example:
tito module start 05 # Start Module 05 (Autograd)
Jupyter Lab opens with the generated notebook for Module 05
Resume Work (Continue Later)#
tito module resume 01
What this does:
Opens Jupyter Lab with your previous work
Preserves all your changes
Shows where you left off
No backup created (youβre continuing)
Use this when: Coming back to a module you started earlier
Complete & Export (Essential)#
tito module complete 01
THE KEY COMMAND - This is what makes your code real!
What this does:
Tests your implementation (inline tests)
Exports to
tinytorch/packageTracks completion in
.tito/progress.jsonValidates NBGrader metadata
Makes read-only exported files (protection)
Example:
tito module complete 05 # Export Module 05 (Autograd)
After exporting:
# YOUR code is now importable!
from tinytorch.autograd import backward
from tinytorch import Tensor
# Use YOUR implementations
x = Tensor([[1.0, 2.0]], requires_grad=True)
y = x * 2
y.backward()
print(x.grad) # Uses YOUR autograd!
View Progress#
tito module status
Shows:
Which modules (01-20) youβve completed
Completion dates
Next recommended module
Example Output:
Module Progress
Module 01: Tensor (completed 2025-11-16)
Module 02: Activations (completed 2025-11-16)
Module 03: Layers (completed 2025-11-16)
Module 04: Losses (not started)
Module 05: Autograd (not started)
Progress: 3/20 modules (15%)
Next: Complete Module 04 to continue Foundation Tier
Reset Module (Advanced)#
tito module reset 01
What this does:
Creates backup of current work
Unexports from
tinytorch/packageRestores module to clean state
Removes from completion tracking
Use this when: You want to start a module completely fresh
Warning: This removes your implementation. Use with caution!
Understanding the Export Process#
When you run tito module complete XX, hereβs what happens:
Step 1: Validation
Checking NBGrader metadata
Validating Python syntax
Running inline tests
Step 2: Export
Converting src/XX_name/XX_name.py
β modules/XX_name/XX_name.ipynb (notebook)
β tinytorch/path/name.py (package)
Adding "DO NOT EDIT" warning
Making file read-only
Step 3: Tracking
Recording completion in .tito/progress.json
Updating module status
Step 4: Success
Module XX complete!
Your code is now part of TinyTorch!
Import with: from tinytorch import YourClass
Module Structure#
Development Structure#
src/ β Developer source code
βββ 01_tensor/
β βββ 01_tensor.py β SOURCE OF TRUTH (devs edit)
βββ 02_activations/
β βββ 02_activations.py β SOURCE OF TRUTH (devs edit)
βββ 03_layers/
βββ 03_layers.py β SOURCE OF TRUTH (devs edit)
modules/ β Generated notebooks (students use)
βββ 01_tensor/
β βββ 01_tensor.ipynb β AUTO-GENERATED for students
βββ 02_activations/
β βββ 02_activations.ipynb β AUTO-GENERATED for students
βββ 03_layers/
βββ 03_layers.ipynb β AUTO-GENERATED for students
Where Code Exports#
tinytorch/
βββ core/
β βββ tensor.py β AUTO-GENERATED (DO NOT EDIT)
βββ nn/
β βββ activations.py β AUTO-GENERATED (DO NOT EDIT)
β βββ layers.py β AUTO-GENERATED (DO NOT EDIT)
βββ ...
IMPORTANT: Understanding the flow
Developers: Edit
src/XX_name/XX_name.pyβ Runtito src exportβ Generates notebooks & packageStudents: Work in generated
modules/XX_name/XX_name.ipynbnotebooksNever edit
tinytorch/directly - itβs auto-generatedChanges in
tinytorch/will be lost on re-export
Troubleshooting#
Environment Not Ready#
Problem: tito system health shows errors
Solution:
# Re-run setup
./setup-environment.sh
source activate.sh
# Verify
tito system health
Export Fails#
Problem: tito module complete XX fails
Common causes:
Syntax errors in your code
Failing tests
Missing required functions
Solution:
Check error message for details
Fix issues in
modules/XX_name/Test in Jupyter Lab first
Re-run
tito module complete XX
Import Errors#
Problem: from tinytorch import X fails
Solution:
# Re-export the module
tito module complete XX
# Test import
python -c "from tinytorch import Tensor"
See Troubleshooting Guide for more issues and solutions.
Next Steps#
Ready to Build Your First Module?
Start with Module 01 (Tensor) and build the foundation of neural networks
Foundation Tier β Milestone System βThe module workflow is the heart of TinyTorch. Master these commands and youβll build ML systems with confidence. Every line of code you write becomes part of a real, working framework.