Files
foxhunt/archive/scripts/deploy_dqn_hyperopt_optimized.sh
jgrusewski 2df1ea92e1 feat(ml): WAVE 29 DQN Codebase Cleanup & Refactoring Campaign
BREAKING CHANGES:
- Removed orphaned dqn.rs monolithic trainer (4,975 lines)
- Removed orphaned dqn_ensemble.rs module (816 lines)
- Removed orphaned tft.rs and tft_complete_int8_integration_test.rs
- TFT trainer split into modular directory structure

DQN Module Refactoring:
- Split trainers/dqn.rs into modular structure (config.rs, statistics.rs, trainer.rs)
- Fixed hyperopt 39D search space (continuous params only)
- Boolean flags (use_dueling, use_double_dqn, use_per, use_noisy_nets) are now FIXED architectural decisions
- use_distributional defaults to false (Candle BUG #36 - scatter_add gradient issues)

Clean Module Structure:
- ml/src/trainers/dqn/ directory with proper mod.rs exports
- ml/src/trainers/tft/ directory with config.rs, types.rs, model.rs, trainer.rs, tests.rs
- All P0 features validated: TD-error clamping, batch diversity, LR scheduler, priority staleness

Documentation:
- Added comprehensive docs in docs/codebase-cleanup/
- ADR-001 for DQN refactoring decisions
- Rainbow DQN component matrix and quick reference guides

Build Status: Compiles with zero errors

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 23:46:13 +01:00

99 lines
3.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# DQN Hyperparameter Optimization Deployment (Optimized Parameters)
# Generated: 2025-11-02
# Based on: DQN_HYPEROPT_RESULTS_SUMMARY.md (Trial #8, Run 1)
#
# BEST HYPERPARAMETERS:
# - Learning Rate: 4.89e-5 (ultra-low, critical for DQN stability)
# - Batch Size: 151
# - Gamma: 0.9838
# - Epsilon Decay: 0.9917
# - Buffer Size: 185066
# - Trials: 50 (complete the hyperopt properly)
#
# CRITICAL NOTE: DQN requires ultra-low learning rates (4.89e-5 to 1.40e-4)
# This is 10-100x lower than PPO's optimal range due to off-policy replay buffer dynamics.
set -euo pipefail
# Configuration
GPU_TYPE="${1:-RTX A4000}" # Default: RTX A4000 ($0.25/hr), alternative: RTX 4090 ($0.59/hr)
DOCKER_IMAGE="jgrusewski/foxhunt:dqn-checkpoint-fix"
PARQUET_FILE="/runpod-volume/test_data/ES_FUT_180d.parquet"
OUTPUT_BASE="/runpod-volume/ml_training"
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
OUTPUT_DIR="${OUTPUT_BASE}/dqn_hyperopt_optimized_${TIMESTAMP}"
# Best hyperparameters from Trial #8 (Run 1)
TRIALS=50
EPOCHS=20 # Per trial
N_INITIAL=2 # Initial random samples
SEED=42 # Reproducibility
# Early stopping configuration
EARLY_STOPPING_PLATEAU_WINDOW=5
EARLY_STOPPING_MIN_EPOCHS=10
# Display configuration
echo "=========================================="
echo "DQN Hyperopt Deployment (Optimized)"
echo "=========================================="
echo "GPU: ${GPU_TYPE}"
echo "Docker Image: ${DOCKER_IMAGE}"
echo "Parquet File: ${PARQUET_FILE}"
echo "Output Directory: ${OUTPUT_DIR}"
echo ""
echo "Hyperopt Configuration:"
echo " Trials: ${TRIALS}"
echo " Epochs per trial: ${EPOCHS}"
echo " Initial random samples: ${N_INITIAL}"
echo " Random seed: ${SEED}"
echo ""
echo "Expected Duration: ~40 min (RTX A4000) or ~25 min (RTX 4090)"
echo "Expected Cost: ~\$0.17 (RTX A4000) or ~\$0.25 (RTX 4090)"
echo "=========================================="
echo ""
# Build hyperopt command
COMMAND="hyperopt_dqn_demo \
--parquet-file ${PARQUET_FILE} \
--trials ${TRIALS} \
--epochs ${EPOCHS} \
--n-initial ${N_INITIAL} \
--seed ${SEED} \
--base-dir ${OUTPUT_DIR} \
--run-type hyperopt \
--early-stopping-plateau-window ${EARLY_STOPPING_PLATEAU_WINDOW} \
--early-stopping-min-epochs ${EARLY_STOPPING_MIN_EPOCHS}"
echo "Command: ${COMMAND}"
echo ""
# Deploy using foxhunt-deploy CLI
if [ ! -f "/home/jgrusewski/Work/foxhunt/target/release/foxhunt-deploy" ]; then
echo "ERROR: foxhunt-deploy CLI not found at /home/jgrusewski/Work/foxhunt/target/release/foxhunt-deploy"
echo "Please build it first: cargo build --release -p foxhunt-deploy"
exit 1
fi
# Deploy pod
echo "Deploying RunPod pod..."
/home/jgrusewski/Work/foxhunt/target/release/foxhunt-deploy deploy \
--gpu-type "${GPU_TYPE}" \
--tag dqn-checkpoint-fix \
--command "${COMMAND}" \
--name "dqn-hyperopt-optimized-$(date +%Y%m%d-%H%M%S)" \
--yes
echo ""
echo "=========================================="
echo "Deployment Complete!"
echo "=========================================="
echo ""
echo "Monitor progress:"
echo " python3 scripts/python/runpod/monitor_logs.py <pod_id>"
echo ""
echo "Verify results (after completion):"
echo " aws s3 ls s3://se3zdnb5o4/ml_training/dqn_hyperopt_optimized_${TIMESTAMP}/ --profile runpod --endpoint-url https://s3api-eur-is-1.runpod.io --recursive"
echo ""