- Restored tools/py_to_notebook.py as a focused, standalone tool - Updated tito notebooks command to use subprocess to call the separate tool - Maintains clean separation of concerns: tito.py for CLI orchestration, py_to_notebook.py for conversion logic - Updated documentation to use 'tito notebooks' command instead of direct tool calls - Benefits: easier debugging, better maintainability, focused single-responsibility modules
5.0 KiB
Setup Module
Welcome to TinyTorch! This is your first module in the Machine Learning Systems course.
Overview
The setup module teaches you the complete TinyTorch development workflow while introducing fundamental programming concepts. You'll learn to write code with NBDev directives, implement classes and functions, and understand the module-to-package export system.
Learning Goals
- Understand the nbdev notebook-to-Python workflow
- Write your first TinyTorch code with
#| exportdirectives - Implement system information collection and developer profiles
- Run tests and use the CLI tools
- Get comfortable with the development rhythm
Files
setup_dev.py- Main development file (Jupytext format with full educational content)setup_dev.ipynb- Jupyter notebook version (auto-generated and executed)tinytorch_flame.txt- ASCII art file containing the TinyTorch flame designtests/test_setup.py- Comprehensive pytest test suiteREADME.md- This file
What You'll Implement
1. Basic Functions
hello_tinytorch()- Display ASCII art and welcome messageadd_numbers()- Basic arithmetic (foundation of ML operations)
2. System Information Class
SystemInfo- Collect and display Python version, platform, and machine info- Compatibility checking for minimum requirements
3. Developer Profile Class
DeveloperProfile- Personalized developer information and signatures- ASCII art customization and file loading
- Professional code attribution system
Usage
Python Script
from setup_dev import hello_tinytorch, add_numbers, SystemInfo, DeveloperProfile
# Display welcome message
hello_tinytorch()
# Basic arithmetic
result = add_numbers(2, 3)
# System information
info = SystemInfo()
print(f"System: {info}")
print(f"Compatible: {info.is_compatible()}")
# Developer profile
profile = DeveloperProfile()
print(profile.get_full_profile())
Jupyter Notebook
Open setup_dev.ipynb and work through the educational content step by step.
Testing
Run the comprehensive test suite using pytest:
# Using the TinyTorch CLI (recommended)
python bin/tito.py test --module setup
# Or directly with pytest
python -m pytest modules/setup/tests/test_setup.py -v
Test Coverage
The test suite includes 20 comprehensive tests covering:
- ✅ Function execution - All functions run without errors
- ✅ Output validation - Correct content and formatting
- ✅ Arithmetic operations - Basic, negative, and floating-point math
- ✅ System information - Platform detection and compatibility
- ✅ Developer profiles - Default and custom configurations
- ✅ ASCII art handling - File loading and fallback behavior
- ✅ Error recovery - Graceful handling of missing files
- ✅ Integration testing - All components work together
Development Workflow
This module teaches the core TinyTorch development cycle:
- Write code in the notebook using
#| exportdirectives - Export code with
python bin/tito.py sync --module setup - Run tests with
python bin/tito.py test --module setup - Check progress with
python bin/tito.py info
Key Concepts
- NBDev workflow - Write in notebooks, export to Python packages
- Export directives - Use
#| exportto mark code for export - Module → Package mapping - This module exports to
tinytorch/core/utils.py - Teaching vs. Building - Learn by modules, build by function
- Student implementation - TODO sections with instructor solutions hidden
Personalization Features
ASCII Art Customization
The ASCII art is loaded from tinytorch_flame.txt. You can customize it by:
- Edit the file directly - Modify
tinytorch_flame.txtwith your own ASCII art - Custom parameter - Pass your own ASCII art to
DeveloperProfile - Create your own design - Your initials, logo, or motivational art
Developer Profile Customization
my_profile = DeveloperProfile(
name="Your Name",
affiliation="Your University",
email="your.email@example.com",
github_username="yourgithub",
ascii_art="Your custom ASCII art here!"
)
What You'll Learn
This comprehensive module introduces:
- NBDev educational patterns -
#| export,#| hidedirectives - File I/O operations - Loading ASCII art with error handling
- Object-oriented programming - Classes, methods, and properties
- System programming - Platform detection and compatibility
- Testing with pytest - Professional test structure and assertions
- Code organization - Module structure and package exports
- The TinyTorch development workflow - Complete cycle from code to tests
Next Steps
Once you've completed this module and all tests pass, you're ready to move on to the tensor module where you'll build the core data structures that power TinyTorch neural networks!
The skills you learn here - the development workflow, testing patterns, and code organization - will be used throughout every module in TinyTorch.