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>
This commit is contained in:
176
archive/scripts/deploy_hyperopt_direct.sh
Executable file
176
archive/scripts/deploy_hyperopt_direct.sh
Executable file
@@ -0,0 +1,176 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Load RunPod credentials
|
||||
source .env.runpod
|
||||
|
||||
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
|
||||
|
||||
echo "========================================="
|
||||
echo "RunPod Hyperopt Deployment (Direct REST API)"
|
||||
echo "========================================="
|
||||
echo ""
|
||||
echo "Deploying 2 pods:"
|
||||
echo " 1. DQN Hyperopt"
|
||||
echo " 2. PPO Hyperopt"
|
||||
echo ""
|
||||
|
||||
# Deploy DQN Hyperopt Pod
|
||||
echo "========================================="
|
||||
echo "1. DEPLOYING DQN HYPEROPT POD"
|
||||
echo "========================================="
|
||||
|
||||
DQN_OUTPUT_DIR="dqn_hyperopt_${TIMESTAMP}"
|
||||
|
||||
DQN_PAYLOAD=$(cat <<EOF
|
||||
{
|
||||
"cloudType": "SECURE",
|
||||
"computeType": "GPU",
|
||||
"dataCenterIds": ["EUR-IS-1"],
|
||||
"dataCenterPriority": "availability",
|
||||
"gpuTypeIds": ["NVIDIA RTX A4000"],
|
||||
"gpuCount": 1,
|
||||
"name": "foxhunt-dqn-hyperopt-${TIMESTAMP}",
|
||||
"imageName": "jgrusewski/foxhunt-hyperopt:latest",
|
||||
"containerDiskInGb": 50,
|
||||
"networkVolumeId": "${RUNPOD_VOLUME_ID}",
|
||||
"volumeMountPath": "/runpod-volume",
|
||||
"dockerStartCmd": [
|
||||
"hyperopt_dqn_demo",
|
||||
"--parquet-file", "/runpod-volume/test_data/ES_FUT_180d.parquet",
|
||||
"--trials", "50",
|
||||
"--epochs", "100",
|
||||
"--base-dir", "/runpod-volume/ml_training/${DQN_OUTPUT_DIR}"
|
||||
],
|
||||
"containerRegistryAuthId": "${RUNPOD_CONTAINER_REGISTRY_AUTH_ID}",
|
||||
"ports": ["8888/http", "22/tcp"],
|
||||
"interruptible": false
|
||||
}
|
||||
EOF
|
||||
)
|
||||
|
||||
echo "Deploying DQN pod..."
|
||||
DQN_RESPONSE=$(curl -s -X POST https://rest.runpod.io/v1/pods \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer ${RUNPOD_API_KEY}" \
|
||||
-d "$DQN_PAYLOAD")
|
||||
|
||||
DQN_POD_ID=$(echo "$DQN_RESPONSE" | jq -r '.id // "ERROR"')
|
||||
|
||||
if [ "$DQN_POD_ID" = "ERROR" ] || [ "$DQN_POD_ID" = "null" ]; then
|
||||
echo "ERROR: Failed to deploy DQN pod"
|
||||
echo "Response: $DQN_RESPONSE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ DQN Pod Deployed Successfully"
|
||||
echo " Pod ID: $DQN_POD_ID"
|
||||
echo " GPU: $(echo "$DQN_RESPONSE" | jq -r '.machine.gpuType.displayName // "RTX A4000"')"
|
||||
echo " Datacenter: $(echo "$DQN_RESPONSE" | jq -r '.machine.dataCenterId // "EUR-IS-1"')"
|
||||
echo " Cost: \$$(echo "$DQN_RESPONSE" | jq -r '.costPerHr // "0.25"')/hr"
|
||||
echo " Output: /runpod-volume/ml_training/${DQN_OUTPUT_DIR}"
|
||||
echo ""
|
||||
|
||||
# Deploy PPO Hyperopt Pod
|
||||
echo "========================================="
|
||||
echo "2. DEPLOYING PPO HYPEROPT POD"
|
||||
echo "========================================="
|
||||
|
||||
PPO_OUTPUT_DIR="ppo_hyperopt_${TIMESTAMP}"
|
||||
|
||||
PPO_PAYLOAD=$(cat <<EOF
|
||||
{
|
||||
"cloudType": "SECURE",
|
||||
"computeType": "GPU",
|
||||
"dataCenterIds": ["EUR-IS-1"],
|
||||
"dataCenterPriority": "availability",
|
||||
"gpuTypeIds": ["NVIDIA RTX A4000"],
|
||||
"gpuCount": 1,
|
||||
"name": "foxhunt-ppo-hyperopt-${TIMESTAMP}",
|
||||
"imageName": "jgrusewski/foxhunt-hyperopt:latest",
|
||||
"containerDiskInGb": 50,
|
||||
"networkVolumeId": "${RUNPOD_VOLUME_ID}",
|
||||
"volumeMountPath": "/runpod-volume",
|
||||
"dockerStartCmd": [
|
||||
"hyperopt_ppo_demo",
|
||||
"--parquet-file", "/runpod-volume/test_data/ES_FUT_180d.parquet",
|
||||
"--trials", "50",
|
||||
"--episodes", "2000",
|
||||
"--base-dir", "/runpod-volume/ml_training/${PPO_OUTPUT_DIR}",
|
||||
"--early-stopping-min-epochs", "50"
|
||||
],
|
||||
"containerRegistryAuthId": "${RUNPOD_CONTAINER_REGISTRY_AUTH_ID}",
|
||||
"ports": ["8888/http", "22/tcp"],
|
||||
"interruptible": false
|
||||
}
|
||||
EOF
|
||||
)
|
||||
|
||||
echo "Deploying PPO pod..."
|
||||
PPO_RESPONSE=$(curl -s -X POST https://rest.runpod.io/v1/pods \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer ${RUNPOD_API_KEY}" \
|
||||
-d "$PPO_PAYLOAD")
|
||||
|
||||
PPO_POD_ID=$(echo "$PPO_RESPONSE" | jq -r '.id // "ERROR"')
|
||||
|
||||
if [ "$PPO_POD_ID" = "ERROR" ] || [ "$PPO_POD_ID" = "null" ]; then
|
||||
echo "ERROR: Failed to deploy PPO pod"
|
||||
echo "Response: $PPO_RESPONSE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ PPO Pod Deployed Successfully"
|
||||
echo " Pod ID: $PPO_POD_ID"
|
||||
echo " GPU: $(echo "$PPO_RESPONSE" | jq -r '.machine.gpuType.displayName // "RTX A4000"')"
|
||||
echo " Datacenter: $(echo "$PPO_RESPONSE" | jq -r '.machine.dataCenterId // "EUR-IS-1"')"
|
||||
echo " Cost: \$$(echo "$PPO_RESPONSE" | jq -r '.costPerHr // "0.25"')/hr"
|
||||
echo " Output: /runpod-volume/ml_training/${PPO_OUTPUT_DIR}"
|
||||
echo ""
|
||||
|
||||
# Summary
|
||||
echo "========================================="
|
||||
echo "DEPLOYMENT SUMMARY"
|
||||
echo "========================================="
|
||||
echo ""
|
||||
echo "DQN Hyperopt:"
|
||||
echo " Pod ID: $DQN_POD_ID"
|
||||
echo " Output: /runpod-volume/ml_training/${DQN_OUTPUT_DIR}"
|
||||
echo " Trials: 50"
|
||||
echo " Epochs/trial: 100"
|
||||
echo " Expected duration: 12-25 min"
|
||||
echo " Expected cost: \$0.05-\$0.10"
|
||||
echo ""
|
||||
echo "PPO Hyperopt:"
|
||||
echo " Pod ID: $PPO_POD_ID"
|
||||
echo " Output: /runpod-volume/ml_training/${PPO_OUTPUT_DIR}"
|
||||
echo " Trials: 50"
|
||||
echo " Episodes/trial: 2000"
|
||||
echo " Expected duration: 10-20 min"
|
||||
echo " Expected cost: \$0.04-\$0.08"
|
||||
echo ""
|
||||
echo "TOTAL ESTIMATED COST: \$0.09-\$0.18"
|
||||
echo ""
|
||||
echo "========================================="
|
||||
echo "MONITORING COMMANDS"
|
||||
echo "========================================="
|
||||
echo ""
|
||||
echo "Monitor DQN logs:"
|
||||
echo " ./monitor_dqn_hyperopt_pod.sh $DQN_POD_ID"
|
||||
echo ""
|
||||
echo "Monitor PPO logs:"
|
||||
echo " ./monitor_ppo_hyperopt_pod.sh $PPO_POD_ID"
|
||||
echo ""
|
||||
echo "View pods in dashboard:"
|
||||
echo " https://www.runpod.io/console/pods"
|
||||
echo ""
|
||||
echo "Check S3 results (after completion):"
|
||||
echo " aws s3 ls s3://se3zdnb5o4/ml_training/${DQN_OUTPUT_DIR}/ --profile runpod --recursive"
|
||||
echo " aws s3 ls s3://se3zdnb5o4/ml_training/${PPO_OUTPUT_DIR}/ --profile runpod --recursive"
|
||||
echo ""
|
||||
echo "Terminate pods (when complete):"
|
||||
echo " curl -X POST https://rest.runpod.io/v1/pods/${DQN_POD_ID}/terminate \\"
|
||||
echo " -H \"Authorization: Bearer \$RUNPOD_API_KEY\""
|
||||
echo " curl -X POST https://rest.runpod.io/v1/pods/${PPO_POD_ID}/terminate \\"
|
||||
echo " -H \"Authorization: Bearer \$RUNPOD_API_KEY\""
|
||||
echo ""
|
||||
Reference in New Issue
Block a user