TASK - Testing (144 tests + smoke test)
Objective: green suite before every merge and before/after every training run. Code: tests/, scripts/smoke_test.py.
Layers (run in this order - each is cheaper than the next one's failure)
- Fast unit tests (no downloads, seconds–minutes):
python -m pytest tests/ -m "not slow"
Covers: SLIS roundtrips, FGVLA shapes/gradients, projector, modality processors, schema validation, loss masking (test_loss_masking.py - zero grad from prompt/visual positions), leakage validator, converters, controller.
2. Smoke test (real weights Qwen3-0.6B + SigLIP-2-base, synthetic data, 12 steps, Apple Silicon):
bash scripts/download_models.sh # once, ~1.6GB
bash scripts/smoke_test.sh
Exercises the exact train path: forward → loss → backward → optimizer step → checkpoint save/load → generate → decode. 3. Slow suite (real weights end-to-end incl. HTTP app round-trip):
python -m pytest tests/ -m slow
- App round-trip:
tests/test_app.py(agentic routing + compatibility + report JSON over HTTP).
Done criteria
-
not slow: 100% pass, zero skips due to env (if GDAL missing:nix developor install gdal, then rerun) - Smoke: 12/12 steps pass on MPS
- New code ships with a test in the matching
test_*.py- no untested modality, metric, or tool
Debug
| Symptom | Cause → fix |
|---|---|
slow fails on first run | weights not cached - run download_models.sh first |
| MPS-only failure, CUDA passes | check docs/assumptions.md #A13 workarounds are intact (CPU vision tower, eager attention) |
test_app.py fails | backend API contract changed - fix app/backend/*.py or the test, never both silently |
| Flaky ordering | tests must be order-independent; seed synthetic data with torch.manual_seed like existing tests |