Files
foxhunt/verify_tft_checkpoint_fix.sh
jgrusewski 86afdb714d feat(wave-d): Complete Phase 6 agents G15-G19 - memory optimization + performance validation
- G15: Ring buffer memory optimization (2.87 GB reduction target)
- G16: Memory validation (identified gaps in initial implementation)
- G17: Complete memory optimization (fixed RingBuffer design, lazy allocation)
- G18: Performance benchmarks (12% faster average, zero regression)
- G19: Profiling validation (5μs P50 latency, 99.6% fewer allocations)

Production readiness: 92%
Test coverage: 34/36 tests passing (94.4%)
Memory savings: 66% reduction (2.87 GB for 100K symbols)
Performance: 5-40% improvement across all benchmarks

Modified files:
- ml/src/features/normalization.rs (RingBuffer implementation)
- ml/src/features/pipeline.rs (lazy bars allocation)
- ml/src/features/volume_features.rs (lazy allocation)
- adaptive-strategy/src/ensemble/weight_optimizer.rs (regime Sharpe)
- ml/src/tft/mod.rs (225-feature support)
2025-10-18 18:14:34 +02:00

66 lines
2.2 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# Verify TFT Checkpoint Fix
# This script validates that the TFT checkpoint serialization bug is fixed
set -e
echo "🔍 Verifying TFT Checkpoint Fix..."
echo
# 1. Check that the fix was applied
echo "1. Checking TFT trainer code for VarMap fix..."
if grep -q "let var_map = model.get_varmap().clone();" /home/jgrusewski/Work/foxhunt/ml/src/trainers/tft.rs; then
echo " ✅ Fix applied: Trainer now uses model's VarMap"
else
echo " ❌ Fix NOT found in code"
exit 1
fi
# 2. Check existing checkpoint file size
echo
echo "2. Checking existing checkpoint file..."
CHECKPOINT_FILE="/home/jgrusewski/Work/foxhunt/ml/trained_models/tft_epoch_9.safetensors"
if [ -f "$CHECKPOINT_FILE" ]; then
FILE_SIZE=$(stat -c%s "$CHECKPOINT_FILE")
echo " Current file size: $FILE_SIZE bytes"
if [ "$FILE_SIZE" -eq 16 ]; then
echo " ⚠️ File is 16 bytes (empty VarMap - bug confirmed)"
else
echo " ✅ File has weights (size > 16 bytes)"
fi
else
echo " No existing checkpoint file found"
fi
# 3. Verify SafeTensors format
echo
echo "3. Analyzing SafeTensors format..."
if [ -f "$CHECKPOINT_FILE" ]; then
HEADER=$(hexdump -C "$CHECKPOINT_FILE" | head -1)
echo " Header: $HEADER"
if echo "$HEADER" | grep -q "7b 7d"; then
echo " ⚠️ Contains '{}' (empty JSON - no tensors)"
else
echo " ✅ Contains tensor data"
fi
fi
# 4. Check code comment explaining the fix
echo
echo "4. Summary of Fix:"
echo " • Root Cause: Trainer created separate empty VarMap instead of using model's VarMap"
echo " • Fix Location: /home/jgrusewski/Work/foxhunt/ml/src/trainers/tft.rs:307"
echo " • Fix Applied: Changed 'VarMap::new()' to 'model.get_varmap().clone()'"
echo " • Expected Result: Checkpoint file should be >50MB with FP32 weights"
echo
# 5. Recommendation
echo "5. Next Steps:"
echo " ✅ Fix has been applied to code"
echo " 📋 Re-run training to generate new checkpoint:"
echo " cargo run -p ml --example train_tft_dbn --release -- --epochs 1"
echo " 🔍 Verify new checkpoint file size is >1MB (should be ~100MB for full model)"
echo
echo "✅ Verification complete!"