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:
@@ -1,6 +1,6 @@
|
||||
//! # DQN Benchmark Runner - Production GPU Training Benchmarks
|
||||
//!
|
||||
//! This module implements comprehensive benchmarking for the WorkingDQN model
|
||||
//! This module implements comprehensive benchmarking for the DQN model
|
||||
//! using real market data from DBN files. It measures actual GPU training performance,
|
||||
//! memory usage, stability, and convergence metrics.
|
||||
//!
|
||||
@@ -50,7 +50,7 @@ use std::time::Instant;
|
||||
use tokio::sync::Mutex;
|
||||
use tracing::info;
|
||||
|
||||
use crate::dqn::{Experience, WorkingDQN, WorkingDQNConfig};
|
||||
use crate::dqn::{Experience, DQN, DQNConfig};
|
||||
use crate::real_data_loader::{FeatureMatrix, RealDataLoader};
|
||||
|
||||
use super::batch_size_finder::{BatchSizeConfig, BatchSizeFinder};
|
||||
@@ -82,7 +82,7 @@ pub struct DqnBenchmarkResult {
|
||||
|
||||
/// DQN Benchmark Runner
|
||||
///
|
||||
/// Runs comprehensive benchmarks on WorkingDQN using real market data.
|
||||
/// Runs comprehensive benchmarks on DQN using real market data.
|
||||
/// Measures GPU performance, memory usage, training stability, and convergence.
|
||||
#[derive(Debug)]
|
||||
pub struct DqnBenchmarkRunner {
|
||||
@@ -233,7 +233,7 @@ impl DqnBenchmarkRunner {
|
||||
info!(" Training stable: {}", stability.is_stable);
|
||||
|
||||
Ok(DqnBenchmarkResult {
|
||||
model_name: "WorkingDQN".to_string(),
|
||||
model_name: "DQN".to_string(),
|
||||
total_epochs: epochs,
|
||||
statistics,
|
||||
memory_peak_mb,
|
||||
@@ -388,14 +388,14 @@ impl DqnBenchmarkRunner {
|
||||
}
|
||||
|
||||
/// Create DQN model with specified state dimension
|
||||
fn create_dqn_model(&self, state_dim: usize) -> Result<WorkingDQN> {
|
||||
fn create_dqn_model(&self, state_dim: usize) -> Result<DQN> {
|
||||
let config = Self::create_dqn_config(state_dim);
|
||||
WorkingDQN::new(config).context("Failed to create WorkingDQN model")
|
||||
DQN::new(config).context("Failed to create DQN model")
|
||||
}
|
||||
|
||||
/// Create DQN configuration
|
||||
fn create_dqn_config(state_dim: usize) -> WorkingDQNConfig {
|
||||
WorkingDQNConfig {
|
||||
fn create_dqn_config(state_dim: usize) -> DQNConfig {
|
||||
DQNConfig {
|
||||
state_dim,
|
||||
num_actions: 3, // Buy, Sell, Hold
|
||||
hidden_dims: vec![256, 128, 64],
|
||||
@@ -460,7 +460,7 @@ impl DqnBenchmarkRunner {
|
||||
}
|
||||
|
||||
/// Populate replay buffer with real market data
|
||||
fn populate_replay_buffer(&self, dqn: &mut WorkingDQN, state_data: &[Vec<f32>]) -> Result<()> {
|
||||
fn populate_replay_buffer(&self, dqn: &mut DQN, state_data: &[Vec<f32>]) -> Result<()> {
|
||||
let min_samples = 1000; // Minimum samples for meaningful training
|
||||
let samples_to_add = min_samples.min(state_data.len().saturating_sub(1));
|
||||
|
||||
@@ -551,7 +551,7 @@ mod tests {
|
||||
|
||||
// Validate results
|
||||
assert_eq!(result.total_epochs, 2);
|
||||
assert_eq!(result.model_name, "WorkingDQN");
|
||||
assert_eq!(result.model_name, "DQN");
|
||||
assert!(result.memory_peak_mb > 0.0);
|
||||
assert!(result.statistics.mean_seconds > 0.0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user