Files
cs249r_book/tinytorch/tests/environment
Vijay Janapa Reddi 389989ece7 refactor(tests): clean up test folder and fix gradient flow issues
Test Cleanup (113 files, -22,000 lines):
- Remove 21 redundant run_all_tests.py files
- Remove checkpoints/ folder (22 obsolete checkpoint files)
- Remove progressive/, debugging/, diagnostic/ folders
- Remove duplicate integration tests and examples
- Remove orphaned dev artifacts and generated outputs
- Consolidate test_gradient_flow_overall.py into system/

Documentation Cleanup (4 files removed):
- Remove duplicate HOW_TO_USE.md, WORKFLOW.md, SYSTEM_DESIGN.md
- Trim environment/README.md from 334 to 86 lines
- Update capstone/README.md removing outdated bug references

Test Fixes:
- Add requires_grad=True to layer parameters in gradient tests
- Fix PositionalEncoding argument order in test_shapes.py
- Adjust performance thresholds for realistic expectations
- Fix gradient clipping to handle memoryview correctly
- Update zero_grad assertions to accept None or zeros
2026-01-24 12:22:37 -05:00
..

Environment Validation Tests

Comprehensive tests to ensure TinyTorch environment is correctly configured.

For Students

# Quick health check
tito system health

# Verbose output for debugging
tito system health --verbose

Use when:

  • After running tito setup
  • Before starting a new module
  • When something isn't working
  • Sharing output with TAs for help

Test Suites

Setup Validation (test_setup_validation.py)

Tests 50+ environment checks:

  • Python Environment: Version (3.8+), virtual environment, pip
  • Core Dependencies: NumPy, Matplotlib, pytest, PyYAML, Rich
  • Jupyter Environment: Jupyter, JupyterLab, kernels, Jupytext
  • TinyTorch Package: Import, core modules, version
  • Project Structure: tinytorch/, modules/, src/, tests/, TITO CLI
  • System Resources: Disk space, memory
  • Git Configuration: Git available, user configured

Requirements Validation (test_all_requirements.py)

Auto-discovers and tests ALL packages from requirements files:

  • Package installation (can be imported)
  • Version matching (meets specification)
  • Functionality (actually works, not just installed)

Running Tests

# Via TITO (recommended)
tito system health

# Via pytest
pytest tests/environment/ -v

# Specific suite
pytest tests/environment/test_setup_validation.py -v

Troubleshooting

"No module named 'X'":

pip install -r requirements.txt

Version mismatch:

pip install --upgrade X

Virtual environment not detected:

source .venv/bin/activate  # Mac/Linux
.venv\Scripts\activate     # Windows

Jupyter tests fail:

pip install --upgrade jupyter jupyterlab
python -m ipykernel install --user

CI Integration

- name: Validate Environment
  run: pytest tests/environment/ -v