Commit Graph

25 Commits

Author SHA1 Message Date
Vijay Janapa Reddi
c8555bdb78 Module improvements: Core modules (01-08)
- Update tensor module notebook
- Enhance activations module
- Expand layers module functionality
- Improve autograd implementation
- Add optimizers enhancements
- Update training module
- Refine dataloader notebook
2025-11-11 19:05:00 -05:00
Vijay Janapa Reddi
832c569cad Add module development files to new structure
Added all module development files to modules/XX_name/ directories:

Module notebooks and scripts:
- 18 modules with .ipynb and .py files (01-20, excluding some gaps)
- Moved from modules/source/ to direct module directories
- Includes tensor, autograd, layers, transformers, optimization modules

Module README files:
- Added README.md for modules with additional documentation
- Complements ABOUT.md files added earlier

This completes the module restructuring:
- Before: modules/source/XX_name/*_dev.{py,ipynb}
- After: modules/XX_name/*_dev.{py,ipynb}

All development happens directly in numbered module directories now.
2025-11-10 19:43:36 -05:00
Vijay Janapa Reddi
a5679de141 Update documentation after module reordering
All module references updated to reflect new ordering:
- Module 15: Quantization (was 16)
- Module 16: Compression (was 17)
- Module 17: Memoization (was 15)

Updated by module-developer and website-manager agents:
- Module ABOUT files with correct numbers and prerequisites
- Cross-references and "What's Next" chains
- Website navigation (_toc.yml) and content
- Learning path progression in LEARNING_PATH.md
- Profile milestone completion message (Module 17)

Pedagogical flow now: Profile → Quantize → Prune → Cache → Accelerate
2025-11-10 19:37:41 -05:00
Vijay Janapa Reddi
acb772dd92 Clean up module imports: convert tinytorch.core to sys.path style
- Remove circular imports where modules imported from themselves
- Convert tinytorch.core imports to sys.path relative imports
- Only import dependencies that are actually used in each module
- Preserve documentation imports in markdown cells
- Use consistent relative path pattern across all modules
- Remove hardcoded absolute paths in favor of relative imports

Affected modules: 02_activations, 03_layers, 04_losses, 06_optimizers,
07_training, 09_spatial, 12_attention, 17_quantization
2025-09-30 08:58:58 -04:00
Vijay Janapa Reddi
69b2a7fd4f Clean up modules 04, 05, and 06 by removing unnecessary demonstration functions
- Remove demonstrate_complex_computation_graph() function from Module 05 (autograd)
- Remove demonstrate_optimizer_integration() function from Module 06 (optimizers)
- Module 04 (losses) had no demonstration functions to remove
- Keep all core implementations and unit test functions intact
- Keep final test_module() function for integration testing
- All module tests continue to pass after cleanup(https://claude.ai/code)
2025-09-30 08:09:29 -04:00
Vijay Janapa Reddi
6622bb226c Fix module test execution pattern with if __name__ == '__main__' guards
This change ensures tests run immediately when developing modules but don't execute when modules are imported by other modules.

Changes:
- Protected all test executions with if __name__ == "__main__" blocks
- Unit tests run immediately after function definitions during development
- Module integration test (test_module()) runs at end when executed directly
- Updated module-developer.md with new testing patterns and examples

Benefits:
- Students see immediate feedback when developing (python module_dev.py runs all tests)
- Clean imports: later modules can import earlier ones without triggering tests
- Maintains educational flow: tests visible right after implementations
- Compatible with nbgrader and notebook environments

Tested:
- Module 01 runs all tests when executed directly ✓
- Importing Tensor from tensor_dev doesn't run tests ✓
- Cross-module imports work without test interference ✓
2025-09-30 07:42:42 -04:00
Vijay Janapa Reddi
b19acb6266 Simplify module test execution for notebook compatibility
Removed redundant test calls from all modules:
- Eliminated verbose if __name__ == '__main__': blocks
- Removed duplicate individual test calls
- Each module now simply calls test_module() directly

Changes made to all 9 modules:
- Module 01 (Tensor): Simplified from 16-line main block to 1 line
- Module 02 (Activations): Simplified from 13-line main block to 1 line
- Module 03 (Layers): Simplified from 17-line main block to 1 line
- Module 04 (Losses): Simplified from 20-line main block to 1 line
- Module 05 (Autograd): Simplified from 19-line main block to 1 line
- Module 06 (Optimizers): Simplified from 17-line main block to 1 line
- Module 07 (Training): Simplified from 16-line main block to 1 line
- Module 08 (DataLoader): Simplified from 17-line main block to 1 line
- Module 09 (Spatial): Simplified from 14-line main block to 1 line

Impact:
- Notebook-friendly: Tests run immediately in Jupyter environments
- No redundancy: test_module() already runs all unit tests
- Cleaner code: ~140 lines of redundant code removed
- Better for students: Simpler, more direct execution flow
2025-09-30 06:51:30 -04:00
Vijay Janapa Reddi
a691e14b37 Remove ML Systems Thinking sections from all modules
Cleaned up module structure by removing reflection questions:
- Updated module-developer.md to remove ML Systems Thinking from template
- Removed ML Systems Thinking sections from all 9 modules:
  * Module 01 (Tensor): Removed 113 lines of questions
  * Module 02 (Activations): Removed 24 lines of questions
  * Module 03 (Layers): Removed 84 lines of questions
  * Module 04 (Losses): Removed 93 lines of questions
  * Module 05 (Autograd): Removed 64 lines of questions
  * Module 06 (Optimizers): Removed questions section
  * Module 07 (Training): Removed questions section
  * Module 08 (DataLoader): Removed 35 lines of questions
  * Module 09 (Spatial): Removed 34 lines of questions

Impact:
- Modules now flow directly from tests to summary
- Cleaner, more focused module structure
- Removes assessment burden from implementation modules
- Keeps focus on building and understanding code
2025-09-30 06:44:36 -04:00
Vijay Janapa Reddi
64fb1ae730 Fix module dependency chain - clean imports now work
Critical fixes to resolve module import issues:

1. Module 01 (tensor_dev.py):
   - Wrapped all test calls in if __name__ == '__main__': guards
   - Tests no longer execute during import
   - Clean imports now work: from tensor_dev import Tensor

2. Module 08 (dataloader_dev.py):
   - REMOVED redefined Tensor class (was breaking dependency chain)
   - Now imports real Tensor from Module 01
   - DataLoader uses actual Tensor with full gradient support

Impact:
- Modules properly build on previous work (no isolated implementations)
- Clean dependency chain: each module imports from previous modules
- No test execution during imports = fast, clean module loading

This resolves the root cause where DataLoader had to redefine Tensor
because importing tensor_dev.py would execute all test code.
2025-09-30 06:37:52 -04:00
Vijay Janapa Reddi
5a08d9cfd3 Complete TinyTorch module rebuild with explanations and milestone testing
Major Accomplishments:
• Rebuilt all 20 modules with comprehensive explanations before each function
• Fixed explanatory placement: detailed explanations before implementations, brief descriptions before tests
• Enhanced all modules with ASCII diagrams for visual learning
• Comprehensive individual module testing and validation
• Created milestone directory structure with working examples
• Fixed critical Module 01 indentation error (methods were outside Tensor class)

Module Status:
 Modules 01-07: Fully working (Tensor → Training pipeline)
 Milestone 1: Perceptron - ACHIEVED (95% accuracy on 2D data)
 Milestone 2: MLP - ACHIEVED (complete training with autograd)
⚠️ Modules 08-20: Mixed results (import dependencies need fixes)

Educational Impact:
• Students can now learn complete ML pipeline from tensors to training
• Clear progression: basic operations → neural networks → optimization
• Explanatory sections provide proper context before implementation
• Working milestones demonstrate practical ML capabilities

Next Steps:
• Fix import dependencies in advanced modules (9, 11, 12, 17-20)
• Debug timeout issues in modules 14, 15
• First 7 modules provide solid foundation for immediate educational use(https://claude.ai/code)
2025-09-29 20:55:55 -04:00
Vijay Janapa Reddi
0ca2ab1efe Enhance modules 01-04 with ASCII diagrams and improved flow
Following Module 05's successful visual learning patterns:
- Add ASCII diagrams for complex concepts
- Natural markdown flow explaining what's about to happen
- Visual memory layouts, data flows, and computation graphs
- Enhanced test sections with clear explanations
- Consistent with new MODULE_DEVELOPMENT guidelines

Module 01 (Tensor):
- Tensor dimension hierarchy visualization
- Memory layout and broadcasting diagrams
- Matrix multiplication step-by-step

Module 02 (Activations):
- Linearity problem and activation curves
- Dead neuron visualization for ReLU
- Softmax probability transformation

Module 03 (Layers):
- Linear layer computation visualization
- Parameter management hierarchy
- Batch processing shape transformations

Module 04 (Losses):
- Loss landscape visualizations
- MSE quadratic penalty diagrams
- CrossEntropy confidence patterns

All modules tested and working correctly
2025-09-29 13:49:08 -04:00
Vijay Janapa Reddi
4c50ac35fd Implement pure Tensor with decorator extension pattern
- Module 01: Pure Tensor class - ZERO gradient code, perfect data structure focus
- Modules 02-04: Clean usage of basic Tensor, no hasattr() hacks anywhere
- Removed Parameter wrapper complexity, use direct Tensor operations
- Each module now focuses ONLY on its core teaching concept
- Prepared elegant decorator pattern for Module 05 autograd extension
- Perfect separation of concerns: data structure → operations → enhancement
2025-09-29 12:15:12 -04:00
Vijay Janapa Reddi
06b35c34bd Fix training pipeline: Parameter class, Variable.sum(), gradient handling
Major fixes for complete training pipeline functionality:

Core Components Fixed:
- Parameter class: Now wraps Variables with requires_grad=True for proper gradient tracking
- Variable.sum(): Essential for scalar loss computation from multi-element tensors
- Gradient handling: Fixed memoryview issues in autograd and activations
- Tensor indexing: Added __getitem__ support for weight inspection

Training Results:
- XOR learning: 100% accuracy (4/4) - network successfully learns XOR function
- Linear regression: Weight=1.991 (target=2.0), Bias=0.980 (target=1.0)
- Integration tests: 21/22 passing (95.5% success rate)
- Module tests: All individual modules passing
- General functionality: 4/5 tests passing with core training working

Technical Details:
- Fixed gradient data access patterns throughout activations.py
- Added safe memoryview handling in Variable.backward()
- Implemented proper Parameter-Variable delegation
- Added Tensor subscripting for debugging access(https://claude.ai/code)
2025-09-28 19:14:11 -04:00
Vijay Janapa Reddi
415d8bc3b8 Clean up tensor module: Essential operations only, improved testing pattern 2025-09-28 14:53:37 -04:00
Vijay Janapa Reddi
c52a5dc789 Improve module-developer guidelines and fix all module issues
- Added progressive complexity guidelines (Foundation/Intermediate/Advanced)
- Added measurement function consolidation to prevent information overload
- Fixed all diagnostic issues in losses_dev.py
- Fixed markdown formatting across all modules
- Consolidated redundant analysis functions in foundation modules
- Fixed syntax errors and unused variables
- Ensured all educational content is in proper markdown cells for Jupyter
2025-09-28 09:42:25 -04:00
Vijay Janapa Reddi
55f4f780f1 Enhance tensor module: Add deep systems analysis and production insights
TENSOR MODULE IMPROVEMENTS: Enhanced pedagogical quality and systems thinking

Key Enhancements:
 Fixed module reference numbers (Module 05 Autograd, Module 02 Activations)
 Updated export instructions (tito module complete 01)
 Added comprehensive systems analysis sections:
   - Memory efficiency at production scale (7B parameter models)
   - Broadcasting in transformer architectures
   - Gradient compatibility and computational graphs

Deep Systems Insights Added:
🧠 Memory optimization strategies for large language models
🧠 Transformer broadcasting patterns and attention mechanisms
🧠 Gradient flow architecture and autograd preparation
🧠 Production connections to PyTorch/TensorFlow patterns

Educational Improvements:
📚 Enhanced Build → Use → Reflect pedagogical framework
📚 Concrete production examples (GPT-3 memory requirements)
📚 Clear connections between tensor design and ML system constraints
📚 Actionable analysis replacing generic placeholder questions

Result: Tensor module now provides deep systems understanding while maintaining
strong implementation foundation. All tests pass, ready for student use.
2025-09-28 08:14:46 -04:00
Vijay Janapa Reddi
6ef7f12f5a Fix import paths: Update all modules to use new numbering
IMPORT PATH FIXES: All modules now reference correct directories

Fixed Paths:
 02_tensor → 01_tensor (in all modules)
 03_activations → 02_activations (in all modules)
 04_layers → 03_layers (in all modules)
 05_losses → 04_losses (in all modules)
 Added comprehensive fallback imports for 07_training

Module Test Status:
 01_tensor, 02_activations, 03_layers: All tests pass
 06_optimizers, 08_spatial: All tests pass
🔧 04_losses: Syntax error (markdown in Python)
🔧 05_autograd: Test assertion failure
🔧 07_training: Import paths fixed, ready for retest

All import dependencies now correctly reference reorganized module structure.
2025-09-28 08:07:44 -04:00
Vijay Janapa Reddi
95f001a485 Clean up: Remove old numbered .yml files, CLI uses module.yaml
CLEANUP: Removed duplicate/obsolete configuration files

Removed Files:
- All old numbered .yml files (02_tensor.yml, 03_activations.yml, etc.)
- These were leftover from the module reorganization
- Had incorrect dependencies (still referenced 'setup')

Current State:
 CLI correctly uses module.yaml files (19 modules)
 All module.yaml files have correct dependencies
 No more duplicate/conflicting configuration files
 Clean module structure with single source of truth

The CLI was already using module.yaml correctly, so this cleanup removes
the confusing duplicate files without affecting functionality.
2025-09-28 08:01:26 -04:00
Vijay Janapa Reddi
45a9cef548 Major reorganization: Remove setup module, renumber all modules, add tito setup command and numeric shortcuts
- Removed 01_setup module (archived to archive/setup_module)
- Renumbered all modules: tensor is now 01, activations is 02, etc.
- Added tito setup command for environment setup and package installation
- Added numeric shortcuts: tito 01, tito 02, etc. for quick module access
- Fixed view command to find dev files correctly
- Updated module dependencies and references
- Improved user experience: immediate ML learning instead of boring setup
2025-09-28 07:02:08 -04:00
Vijay Janapa Reddi
83fb269d9f Complete migration from modules/ to assignments/source/ structure
- Migrated all Python source files to assignments/source/ structure
- Updated nbdev configuration to use assignments/source as nbs_path
- Updated all tito commands (nbgrader, export, test) to use new structure
- Fixed hardcoded paths in Python files and documentation
- Updated config.py to use assignments/source instead of modules
- Fixed test command to use correct file naming (short names vs full module names)
- Regenerated all notebook files with clean metadata
- Verified complete workflow: Python source → NBGrader → nbdev export → testing

All systems now working: NBGrader (14 source assignments, 1 released), nbdev export (7 generated files), and pytest integration.

The modules/ directory has been retired and replaced with standard NBGrader structure.
2025-07-12 12:06:56 -04:00
Vijay Janapa Reddi
9b94b588d2 Perfect NBGrader Setup Complete - Python-First Workflow
🎯 NBGRADER STRUCTURE IMPLEMENTED:
- Added proper NBGrader cell metadata to modules/00_setup/setup_dev.py
- Solution cells: nbgrader={'solution': true, 'locked': false}
- Test cells: nbgrader={'grade': true, 'locked': true, 'points': X}
- Proper grade_id for each cell for tracking

🧹 CLEAN STUDENT ASSIGNMENTS:
- No hidden instructor solutions in student version
- Only TODO stubs with clear instructions and hints
- NBGrader automatically replaces with 'YOUR CODE HERE'
- Proper point allocation: hello_tinytorch (3pts), add_numbers (2pts), SystemInfo (5pts)

🔧 WORKING WORKFLOW VERIFIED:
1. Edit modules/XX/XX_dev.py (Python source)
2. tito nbgrader generate XX (Python → Jupyter with NBGrader metadata)
3. tito nbgrader release XX (Clean student version generated)
4. Students work on assignments/release/XX/XX.ipynb
5. tito nbgrader collect/autograde for grading

 TESTED COMPONENTS:
- Python file with proper Jupytext headers 
- NBGrader cell metadata generation 
- Student assignment generation 
- Clean TODO stubs without solutions 
- Release process working 

🎓 EDUCATIONAL STRUCTURE:
- Clear learning objectives and explanations
- Step-by-step TODO instructions with hints
- Immediate testing with auto-graded cells
- Progressive difficulty (functions → classes → optional challenges)
- Real-world context and examples

Perfect implementation of Python-first development with NBGrader compliance
2025-07-12 11:37:39 -04:00
Vijay Janapa Reddi
77150be3a6 Module 00_setup migration: Core functionality complete, NBGrader architecture issue discovered
 COMPLETED:
- Instructor solution executes perfectly
- NBDev export works (fixed import directives)
- Package functionality verified
- Student assignment generation works
- CLI integration complete
- Systematic testing framework established

⚠️ CRITICAL DISCOVERY:
- NBGrader requires cell metadata architecture changes
- Current generator creates content correctly but wrong cell types
- Would require major rework of assignment generation pipeline

📊 STATUS:
- Core TinyTorch functionality:  READY FOR STUDENTS
- NBGrader integration: Requires Phase 2 rework
- Ready to continue systematic testing of modules 01-06

🔧 FIXES APPLIED:
- Added #| export directive to imports in enhanced modules
- Fixed generator logic for student scaffolding
- Updated testing framework and documentation
2025-07-12 09:08:45 -04:00
Vijay Janapa Reddi
0c61394659 Implement comprehensive nbgrader integration for TinyTorch
- Add enhanced student notebook generator with dual-purpose content
- Create complete setup module with 100-point nbgrader allocation
- Implement nbgrader CLI commands (init, generate, release, collect, autograde, feedback)
- Add nbgrader configuration and directory structure
- Create comprehensive documentation and implementation plan
- Support both self-learning and formal assessment workflows
- Maintain backward compatibility with existing TinyTorch system

This implementation provides:
- Single source → multiple outputs (learning + assessment)
- Automated grading with 80% workload reduction
- Scalable course management for 100+ students
- Comprehensive analytics and reporting
- Production-ready nbgrader integration
2025-07-12 08:46:22 -04:00
Vijay Janapa Reddi
215b1e22c9 Fix test imports to use rock solid foundation approach
- Update all test files to import from tinytorch.core.* instead of relative paths
- Consistent with rock solid foundation principle
- Tests now use stable package imports, not local module imports
- Ensures tests validate the actual exported package functionality
- Aligns with production usage patterns
2025-07-12 02:13:31 -04:00
Vijay Janapa Reddi
23c2f53c2b Add numbered prefixes to complete modules
- Rename complete modules to numbered progression:
  - setup → 00_setup
  - tensor → 01_tensor
  - activations → 02_activations
  - layers → 03_layers
  - networks → 04_networks
  - dataloader → 05_dataloader

- Update test imports to use new numbered module names
- Keep incomplete modules (autograd, training, etc.) unnumbered
- Clear progression: 6 complete modules ready for students
- Maintains rock solid foundation approach with proper imports
2025-07-12 02:12:12 -04:00