mirror of
https://github.com/MLSysBook/TinyTorch.git
synced 2026-04-28 21:32:33 -05:00
Documentation updates across the codebase: Root documentation: - README.md: Updated references from book/ to site/ - CONTRIBUTING.md: Updated build and workflow instructions - .shared-ai-rules.md: Updated AI assistant rules for new structure GitHub configuration: - Issue templates updated for new module locations - Workflow references updated from book/ to site/ docs/ updates: - STUDENT_QUICKSTART.md: New paths and structure - module-rules.md: Updated module development guidelines - NBGrader documentation: Updated for module restructuring - Archive documentation: Updated references Module documentation: - modules/17_memoization/README.md: Updated after reordering All documentation now correctly references: - site/ instead of book/ - modules/XX_name/ instead of modules/source/
3.3 KiB
3.3 KiB
Development Workflow Rules
Branch-First Development
- Always create a branch for any work - never work directly on main
- Branch naming:
feature/description,fix/issue,refactor/component - Remind user to create branches if they forget
🚨 CRITICAL: TinyTorch Development Workflow
The Golden Rule: Source → Export → Use
modules/ → tito export → tinytorch/ → milestones/
(EDIT HERE!) (BUILD STEP) (NEVER EDIT!) (USE IT!)
Three Sacred Principles
- ONLY edit files in
modules/- This is your source of truth - ALWAYS use
tito exportto build thetinytorch/package - NEVER modify anything in
tinytorch/directly - It's generated code!
Why This Matters
modules/: Educational module sources (Python.pyfiles)tinytorch/: Generated package (likenode_modules/ordist/)milestones/: Student projects that import fromtinytorch
If you edit tinytorch/ directly, your changes will be LOST on next export!
Complete Development Workflow
# 1. Edit the module source (ONLY place to make changes)
vim modules/12_attention/attention.py
# 2. Export to tinytorch package (Build step)
tito export
# 3. Test the exported module
pytest tests/12_attention/
# 4. Use in milestones
cd milestones/05_2017_transformer/
python tinytalks_dashboard.py # Uses tinytorch.core.attention
🚨 CRITICAL: Notebook Development Workflow
NEVER EDIT .ipynb FILES DIRECTLY
TinyTorch uses a literate programming approach with nbdev:
- Edit ONLY
.pyfiles inmodules/*/ - Export to tinytorch using
tito export - Run tests with
pytestto verify changes - Never manually edit .ipynb files - they are generated artifacts
- Never manually edit tinytorch/ - it's generated from modules/
Why This Matters
.ipynbfiles are JSON and hard to merge/review.pyfiles are the source of truthtinytorch/is generated code (like compiled binaries)- nbdev ensures proper sync between code, tests, and documentation
- Manual .ipynb edits will be overwritten on next export
- Manual tinytorch/ edits will be overwritten on next export
Correct Workflow Example
# 1. Edit the Python source
vim modules/12_attention/attention.py
# 2. Export to tinytorch package
tito export
# 3. Run tests
pytest tests/12_attention/
# 4. If tests pass, commit source changes
git add modules/12_attention/attention.py
git commit -m "fix(attention): Handle 3D attention masks"
Work Process
- Plan: Define what changes are needed and why
- Reason: Think through the approach and potential issues
- Test: Write tests to verify success before implementing
- Execute: Implement changes in a new Git branch
- Verify: Run all tests and ensure everything works
- Merge: Only merge when fully tested and verified
Testing Standards
- Always use pytest for all tests
- Test before implementing - write tests that define success
- Test after implementing - verify everything works
- Test edge cases and error conditions
Documentation
- Prefer Quarto for documentation generation
- Keep rules short and actionable
- Update rules as patterns emerge
This ensures quality, traceability, and prevents breaking main branch.