Commit Graph

33 Commits

Author SHA1 Message Date
Vijay Janapa Reddi
d7d288dace Fix UnicodeDecodeError on Windows in tito module complete (fixes #1184)
Add encoding='utf-8' and errors='replace' to subprocess.run() calls in
workflow.py so unit and integration test output decode correctly on
Windows (cp1252) when output contains UTF-8 characters.

Co-authored-by: Pratham-ja <114498234+Pratham-ja@users.noreply.github.com>
2026-02-21 09:38:08 -05:00
Vijay Janapa Reddi
672a35335f feat(vscode-ext, tito): make extension a thin client over Tito CLI
The VS Code extension no longer implements any business logic — every
capability (module discovery, path resolution, system info, builds,
tests, clean) lives in Tito CLI commands. The extension is a pure UI
shell that delegates via `python3 -m tito.main`.

Tito CLI additions:
- `module list --json` for machine-readable module discovery
- `module path <num> --notebook|--source|--about` for file resolution
- `system info --json` for environment info
- `dev build html|serve|pdf|paper` wrapping make targets
- `dev clean [all|site]` wrapping make clean
- Banner suppression for --json and module path output

Extension hardening:
- Centralized CLI integration in utils/tito.ts (single TITO_CMD constant,
  callTito, callTitoJson, titoTerminalCommand, isTitoAvailable, log/logError)
- Replaced all silent catch{} blocks with logged errors and user feedback
- Module tree shows error/empty states with actionable Setup/Health buttons
- Info tree shows "Tito CLI unavailable" when CLI is unreachable
- Removed all setTimeout refresh hacks — file watcher on .tito/progress.json
  is the sole refresh mechanism
- Exit code tracking via onDidEndTerminalShellExecution
- Tito availability pre-flight check on activation
- BUILD_OUTPUTS constants for build artifact paths
- Zero execSync calls outside tito.ts, zero hardcoded command strings
2026-02-17 10:08:00 -05:00
Vijay Janapa Reddi
25fc9e4848 fix(tito): resolve Jupyter kernel mismatch causing ModuleNotFoundError (#1147)
Students hit "No module named 'tinytorch.core.tensor'" in notebooks because
the Jupyter kernel used a different Python than where tinytorch was installed.

- setup: install ipykernel + nbdev, register named kernel during tito setup
- health: add Notebook Readiness checks (import, kernel, Python match)
- export: verify exported file exists and has content (fail loudly)
- Windows: add get_venv_bin_dir() helper for cross-platform venv paths
2026-02-04 10:24:37 -05:00
Vijay Janapa Reddi
bb5dd7a9f6 fix(export): use nbdev Python API instead of CLI for reliable export
The nbdev_export CLI was not reading settings.ini correctly in CI,
causing exports to silently fail. Using nbdev.export.nb_export()
Python API directly with explicit lib_path ensures exports work
reliably regardless of environment.
2026-01-29 14:28:40 -05:00
Vijay Janapa Reddi
2ec60a6f5c fix(export): use python -m nbdev.export instead of nbdev_export command
The nbdev_export command wasn't in PATH in CI. Using sys.executable
with -m nbdev.export ensures we use the same Python environment that's
running tito, which is more reliable across different environments.

Fixed in:
- tito/commands/dev/export.py (both _export_all_modules and _run_nbdev_export)
- tito/commands/module/workflow.py (_export_notebook)
2026-01-29 14:19:26 -05:00
Vijay Janapa Reddi
a70c724a02 fix: export failure now blocks progress + add user journey test
Bug Fix:
- Export failures now return early in module complete, preventing
  progress from being updated when export fails. This fixes the issue
  where students could start Module 02 even though tensor.py was
  never exported.

New --user-journey test:
- Simulates exact student flow: module start --no-jupyter → module complete
- Runs milestones at natural unlock checkpoints (not all at end)
- Milestone checkpoints: after modules 03, 08, 09, 13, 19
- Explicit step-by-step output for easy CI debugging

New --no-jupyter flag:
- Added to 'tito module start' for CI/testing
- Creates notebook but skips opening Jupyter

Ref: https://github.com/harvard-edge/cs249r_book/discussions/1147
2026-01-28 09:28:15 -05:00
Vijay Janapa Reddi
7169ad6529 fix(ci): remove milestone stage and fix interactive prompt in CI
- Remove Stage 6 (milestone tests) from CI workflow since test files were
  removed as redundant with integration tests
- Renumber Stage 7 (release) to Stage 6
- Update summary job to remove milestone references
- Fix _trigger_submission() to skip interactive prompts in CI mode
  by checking CI, GITHUB_ACTIONS env vars and stdin.isatty()

The milestone demo scripts remain available for student use via
'tito milestone run', but are no longer run as automated tests.
2026-01-24 14:30:22 -05:00
Vijay Janapa Reddi
975c92a1c6 fix(cli): resolve Rich markup rendering in module completion message
Text.append() does not interpret Rich markup - it treats strings as
literal text. Split the markup into separate append calls with proper
style parameters so the 'Next: tito module start XX' hint renders
correctly instead of showing literal [bold cyan] tags.
2026-01-24 09:29:51 -05:00
Vijay Janapa Reddi
42bc991d75 fix(tests): add PYTHONPATH to inline test subprocess
Source files like src/02_activations/02_activations.py import from
tinytorch.core.tensor. When running these as subprocesses, the Python
path needs to include the project root so the imports resolve correctly.

This was causing CI to fail at module 02 because it couldn't find
tinytorch.core.tensor even though module 01 had exported it.
2026-01-23 16:56:17 -05:00
Vijay Janapa Reddi
102eacaaa2 feat(cli): implement tito module complete --all
- Added complete_all_modules() method that iterates through all modules
- Runs tests + export for each module in sequence (01 → 20)
- Stops on first failure for fail-fast behavior
- Skips modules without notebooks (shows as 'skipped')
- Useful for CI validation and students exporting all work

Distinction from dev export --all:
- dev export --all: Rebuilds from src/ (overwrites student notebooks)
- module complete --all: Tests + exports existing notebooks (safe for students)
2026-01-23 16:52:36 -05:00
Vijay Janapa Reddi
b7fa2f8e81 feat(workflow): LLM-powered all-contributors with natural language
- Update all-contributors-add.yml to use Ollama (llama3.1:8b) for parsing
  natural language descriptions instead of requiring exact syntax
- Trim contribution types to 8 actually used: bug, code, doc, design,
  ideas, review, test, tool
- Update generate_main_readme.py and generate_readme_tables.py to match
- Remove unused tito module export subcommand (fixes #1134)
  Students should use tito module complete instead

Now you can write naturally:
  @all-contributors @user helped verify the fix worked
  @all-contributors @user found a bug in the dataloader
2026-01-23 09:01:16 -05:00
Vijay Janapa Reddi
186615c18a fix(tinytorch): fix test ordering and non-interactive mode issues
Bug fixes:
- Move test_autograd_core.py from 05_dataloader/ to 06_autograd/ (fixes #1127)
- Fix integration test mapping: tests now only run after their dependencies
  are available (module 4 loss tests moved to module 7+)
- Remove premature test_unit_function_classes() call in 06_autograd.py
  that ran before enable_autograd() (fixes #1128)
- Handle EOFError in milestone prompts for non-interactive mode (fixes #1129)

Improvements:
- Read version from pyproject.toml as single source of truth
- Add try/except for sync prompt in milestone completion

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 12:17:32 -05:00
Vijay Janapa Reddi
871d1f473a docs: complete Perceptron 1958 standardization and add tito dev CLI docs
- Update remaining 1957→1958 references across all documentation
- Add tito dev commands (preflight, export, validate) to CLI reference
- Update CLI validation script to recognize new dev subcommands
- Fix milestone year references in tests and workflow code
- Update timeline visualization JavaScript

This completes the Perceptron year standardization to align with
the publication year and academic citation format (rosenblatt1958perceptron).

Cherry-picked from: ebf3fb17b (feature/tito-dev-validate)
2026-01-17 12:18:23 -05:00
Vijay Janapa Reddi
f9fd2c8fe1 style(tito): use Panel warnings consistently for destructive actions
Standardize warning dialogs across all tito commands that perform
destructive operations (reset, delete, overwrite). All confirmation
prompts now use Rich Panel with yellow/red borders for visibility.

Updated commands:
- module reset
- package reset (all variants)
- login (force re-login)
- setup (recreate venv)
2026-01-15 09:52:40 -05:00
Vijay Janapa Reddi
2ed310d6f2 fix(tinytorch): fix integration tests and improve update command
- Fix gradient accumulation scaling in Trainer (divide gradient, not just loss)
- Fix evaluation loop to count batches correctly instead of using len(dataloader)
- Ensure optimizer params have requires_grad=True and grad initialized
- Add pytest -o addopts= to prevent config pollution in integration tests
- Improve update command messaging with Panel warning

Fixes #1112
2026-01-15 09:52:28 -05:00
Vijay Janapa Reddi
fd7c0f5e2f fix(tinytorch): tito module complete no longer overwrites student notebooks
- Create tito dev export for developers (rebuilds src→notebook→package)
- Fix tito module complete to only export notebook→package (preserves student work)
- Remove deprecated tito src command
- Add module name normalization to dev export (supports 01 shorthand)
2026-01-14 12:51:02 -05:00
Vijay Janapa Reddi
1f7a2bb82e fix(tinytorch): reorder workflow to run integration tests AFTER export
Fixes #1110

The integration tests import from tinytorch.core.* which requires
the module to be exported first. Previously, tests ran before export,
causing ModuleNotFoundError for tinytorch.core.layers.

New workflow order:
1. Unit tests (test source files)
2. Export (creates tinytorch/core/*.py)
3. Integration tests (test exported package)
4. Track progress
2026-01-14 09:46:26 -05:00
Vijay Janapa Reddi
96b4914e61 fix(tito): update CLI module dependencies and mappings
- Update milestone required_modules to include full training infrastructure (modules 1-8)
- Fix module-to-test mappings: DataLoader (05), Autograd (06), Optimizers (07), Training (08)
- Update profiler mappings in status_analyzer for current module numbers
- Fix workflow milestone mappings to reflect correct module dependencies
- Correct Acceleration (17) and Memoization (18) references
2025-12-19 20:52:46 -05:00
Vijay Janapa Reddi
0d076aee26 fix: update tier boundaries across all documentation
Comprehensive update to reflect correct module assignments:
- Foundation Tier: 01-08 (was incorrectly 01-07 in many places)
- Architecture Tier: 09-13 (was incorrectly 08-13 in many places)

Updated files:
- Site pages: intro.md, big-picture.md, getting-started.md
- Tier docs: olympics.md, optimization.md
- TITO docs: milestones.md
- Source ABOUT.md: 09, 10, 11, 12, 13, 14, 16
- Paper diagrams: module_flow.dot, module_flow_horizontal.tex
- Milestones: README.md, 02_1969_xor/ABOUT.md
- Tests: integration/README.md
- CLI: tito/commands/module/test.py
2025-12-19 20:12:24 -05:00
Vijay Janapa Reddi
42f5b34ceb chore: update tools and remaining files for module swap 2025-12-19 19:30:46 -05:00
Vijay Janapa Reddi
a6f9bc3b0b feat(tinytorch): add module.yaml metadata files for CLI module descriptions
Add machine-readable module.yaml files to each of the 20 modules with
title, subtitle, and description fields. Update tito CLI to read from
these files instead of parsing Python files.

- Create module.yaml in src/NN_*/ directories
- Add YAML parser with validation in tito/core/modules.py
- Update list_modules() to display descriptions from YAML
2025-12-15 20:30:32 -05:00
Vijay Janapa Reddi
0c12edd231 fix(tito): remove top-level export and test shortcuts
These commands should only be accessible via 'tito module export'
and 'tito module test' to maintain consistent CLI structure.
2025-12-15 19:00:21 -05:00
Vijay Janapa Reddi
ed5951cc33 fix(tito): use correct notebook paths in module commands
- Fix notebook naming: use short name (tensor.ipynb) not full name (01_tensor.ipynb)
- Fix module directory: use modules/ not src/ for notebook locations
- Open notebook directly in JupyterLab instead of just the folder
2025-12-15 13:14:15 -05:00
Vijay Janapa Reddi
0c3c75678e refactor: rename Module 09 from Spatial to Convolutions
- Rename directories: src/09_spatial → src/09_convolutions,
  tests/09_spatial → tests/09_convolutions
- Rename files: 09_spatial.py → 09_convolutions.py,
  test_spatial_*.py → test_convolutions_*.py
- Update TOC files, TITO CLI mappings, and documentation
- Update navigation links between modules
- Remove misplaced duplicate test file from tests/06_optimizers/
- Use "CNNs" in diagrams, "Convolutions" in prose for consistency

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2025-12-14 13:13:18 -05:00
Vijay Janapa Reddi
853eb03ee8 style: apply consistent whitespace and formatting across codebase 2025-12-13 14:05:34 -05:00
Vijay Janapa Reddi
fc02b1d293 fix: module status now correctly shows unlocked vs ready milestones
- Fixed integer to string comparison for module numbers
- Now checks .tito/milestones.json to see if milestone was actually run
- Updated milestone requirements to match MILESTONE_SCRIPTS
2025-12-11 18:38:51 -08:00
Vijay Janapa Reddi
e7caea65cf fix: milestone status and progress file location
- MilestoneSystem now falls back to MILESTONE_SCRIPTS when no YAML config
- Fixed trigger_module logic for milestones without explicit triggers
- Added fallback for victory_condition to use description field
- Changed progress file location from root to .tito/progress.json
- Updated workflow and reset commands to use .tito/ directory
2025-12-11 18:35:59 -08:00
Vijay Janapa Reddi
3cbb4e98a2 refactor: simplify tito module reset command
Reduced from 800+ lines to ~310 lines with cleaner interface:
- tito module reset: prompts for module selection
- tito module reset 02: resets specific module
- tito module reset --all: resets all modules
- tito module reset --force: skips confirmation

Removed complex options (--soft, --hard, --from-git, --restore-backup,
--list-backups, --no-backup). Reset now simply recreates notebook from src/.
2025-12-11 18:27:21 -08:00
Vijay Janapa Reddi
125dd5f636 fix: correct module workflow export and milestone prerequisites
- Fix notebook path mismatch in SrcCommand._handle_export
  (was looking for 01_tensor.ipynb but actual file is tensor.ipynb)

- Update install.sh to preserve needed files for student workflow:
  - Keep settings.ini (required for nbdev_export)
  - Keep milestones/ (required for tito milestone run)
  - Clear tinytorch/core/*.py (students rebuild via exports)
  - Clear progress.json (students start fresh)

- Fix milestone module requirements to match actual script imports:
  - Milestone 01: [1,2,3] (Tensor, Activations, Layers)
  - Milestone 02: [1,2,3,4,5,6] (+ Losses, Autograd, Optimizers)
  - Milestone 03: [1,2,3,4,5,6,8] (+ DataLoader)
  - Milestone 04: [1,2,3,4,5,6,8,9] (+ Spatial)
  - Milestone 05: [1,2,3,4,5,6,11,12,13] (+ Embeddings, Attention, Transformers)

- Fix progress file path: read from progress.json not .tito/progress.json

- Fix module number comparison: convert string IDs to integers

- Update health check to validate modules_dir (src/) not assignments_dir

- Rename 'milestones' command to 'milestone' (singular)

- Fix test files to check correct directories for student install
2025-12-11 17:22:15 -08:00
Vijay Janapa Reddi
71119b86b4 feat(tito): add module view command and auto-create from src
- Add tito module view XX to open notebook without status ceremony
- Auto-create module from src/ when tito module start XX is called
  if module does not exist in modules/ yet
- Reuse convert_py_to_notebook from export_utils for consistency
- Update help text to include view command
2025-12-11 13:28:54 -08:00
Vijay Janapa Reddi
90212103d6 fix(tito): correct module naming and centralize module discovery
Fixes MLSysBook/TinyTorch#22

The module mappings were hardcoded in multiple files and had drifted
out of sync with actual folder names. Module 15 was incorrectly mapped
to "15_acceleration" instead of "15_quantization".

Changes:
- Add tito/core/modules.py that auto-discovers modules from src/ directory
- Remove hardcoded module mappings from workflow.py, reset.py, test.py
- Replace hardcoded next_modules dicts in export.py and src.py
- Single source of truth: filesystem is now the source

This prevents future sync issues - adding/renaming module folders
automatically updates the CLI without code changes.
2025-12-09 20:05:33 -08:00
Vijay Janapa Reddi
fa6d951a8a fix(tinytorch): fix test flakiness and coverage requirements
- Add np.random.seed(42) to test_deep_network_gradient_chain for reproducibility
- Add --no-cov to tito module test to avoid root pyproject.toml coverage requirements
- Skip test_layers_networks_integration.py when tinytorch.core.dense is not implemented
2025-12-07 04:32:14 -08:00
Vijay Janapa Reddi
c602f97364 feat: integrate TinyTorch into MLSysBook repository
TinyTorch educational deep learning framework now lives at tinytorch/

Structure:
- tinytorch/src/         - Source modules (single source of truth)
- tinytorch/tito/        - CLI tool
- tinytorch/tests/       - Test suite
- tinytorch/site/        - Jupyter Book website
- tinytorch/milestones/  - Historical ML implementations
- tinytorch/datasets/    - Educational datasets (tinydigits, tinytalks)
- tinytorch/assignments/ - NBGrader assignments
- tinytorch/instructor/  - Teaching materials

Workflows (with tinytorch- prefix):
- tinytorch-ci.yml           - CI/CD pipeline
- tinytorch-publish-dev.yml  - Dev site deployment
- tinytorch-publish-live.yml - Live site deployment
- tinytorch-build-pdf.yml    - PDF generation
- tinytorch-release-check.yml - Release validation

Repository Variables added:
- TINYTORCH_ROOT  = tinytorch
- TINYTORCH_SRC   = tinytorch/src
- TINYTORCH_SITE  = tinytorch/site
- TINYTORCH_TESTS = tinytorch/tests

All workflows use \${{ vars.TINYTORCH_* }} for path configuration.

Note: tinytorch/site/_static/favicon.svg kept as SVG (valid for favicons)
2025-12-05 19:23:18 -08:00