Files
foxhunt/ml/examples
jgrusewski 0fced7619d fix(ml): Add max_validation_batches to prevent validation OOM
Workaround for Candle's lack of CUDA memory clearing APIs

Problem:
- Validation needs 1760MB for 176 batches
- Only 2485MB available after training
- Candle doesn't expose cuda::empty_cache() to free optimizer memory
- Result: OOM during validation despite optimizer drop

Solution:
- Add max_validation_batches parameter to limit validation batches
- Default: None (unlimited, backward compatible)
- Recommended for 4GB GPUs: 50 batches (~500MB vs 1760MB)

Changes:
1. CLI parameter: --max-validation-batches <num>
2. TFTTrainerConfig: max_validation_batches field
3. TFTTrainingConfig: max_validation_batches field
4. Validation loop: .take(max_batches) to limit batches
5. Updated: benchmarks, legacy binary for compatibility

Impact:
- 50 batches: 1611MB + 500MB = 2111MB < 2485MB 
- 176 batches: 1611MB + 1760MB = 3371MB > 2485MB 
- Memory savings: 1260MB (72% reduction)
- Trade-off: Validates on subset (28% of data)

Files Modified:
- ml/examples/train_tft_parquet.rs (CLI + config)
- ml/src/trainers/tft.rs (config + validation loop)
- ml/src/tft/training.rs (internal config)
- ml/src/benchmark/tft_benchmark.rs (compatibility)
- ml/src/bin/train_tft.rs (compatibility)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-26 20:58:49 +01:00
..