Files
foxhunt/crates/ml/src/training.rs
jgrusewski fb6d0f40f9 audit(dqn-v2): A.5 orphan audit complete
Populated docs/dqn-wire-up-audit.md with every pub module and CUDA
kernel in the DQN path. Each entry classified Wired / Partial / Orphan /
Ghost / OUT-of-DQN-scope with the action plan linking to the plan+task
that resolves any non-Wired status.

No Orphan left unclassified. Orphans fall into three buckets:
1. Scheduled for wiring by a later Plan (gpu_statistics → Plan 2 D.2;
   tlob_loader → Plan 2 D.8).
2. OUT-of-DQN-scope because supervised consumers exist (PPO kernels,
   xLSTM, KAN trainable adapter, flash_attention, benchmarks).
3. Genuinely unused — escalated to user review in the task output,
   not deleted autonomously (streaming_dbn_loader, unified_data_loader,
   training/orchestrator, training_pipeline, inference_validator,
   model_loader_integration, paper_trading/mod.rs,
   portfolio_transformer, regime_detection/mod.rs).

Summary: 109 total modules/kernels, 74 wired, 7 partial, 11 orphan,
0 ghost, 17 OUT-of-DQN-scope.

Plan 1 Task 6. Spec §4.A.5, Invariant 2.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-24 13:10:49 +02:00

84 lines
2.3 KiB
Rust

//! Simplified ML Training Implementation for Foxhunt HFT System
//!
//! This module provides basic ML training functionality optimized for compilation success.
//! Focus on working implementation over advanced features.
//!
//! ## New Unified Data Pipeline
//!
//! The training system now uses UnifiedDataLoader with dual data providers:
//! - DatabentoHistoricalProvider for market data
//! - BenzingaHistoricalProvider for news sentiment
//! - UnifiedFeatureExtractor for consistent feature extraction
// Sub-modules for specialized training components
pub mod unified_trainer; // Unified training trait for all models
// NO RE-EXPORTS - Use explicit imports: unified_data_loader::{...}
use serde::{Deserialize, Serialize};
/// Training configuration
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TrainingConfig {
pub learning_rate: f64,
pub batch_size: usize,
pub epochs: usize,
pub validation_split: f64,
pub early_stopping_patience: Option<usize>,
pub random_seed: Option<u64>,
}
impl Default for TrainingConfig {
fn default() -> Self {
Self {
learning_rate: 0.001,
batch_size: 32,
epochs: 100,
validation_split: 0.2,
early_stopping_patience: Some(10),
random_seed: None,
}
}
}
/// Device capabilities for performance scoring
#[derive(Debug, Clone)]
pub struct DeviceCapabilities {
pub performance_score: f64,
pub memory_gb: f64,
pub compute_units: u32,
}
impl DeviceCapabilities {
pub fn cpu_default() -> Self {
Self {
performance_score: 1.0,
memory_gb: 8.0,
compute_units: num_cpus::get() as u32,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
use approx::assert_relative_eq;
#[test]
fn test_training_config_default() {
let config = TrainingConfig::default();
assert_eq!(config.learning_rate, 0.001);
assert_eq!(config.batch_size, 32);
assert_eq!(config.epochs, 100);
assert_relative_eq!(config.validation_split, 0.2, epsilon = 1e-10);
}
#[test]
fn test_device_capabilities_cpu_default() {
let caps = DeviceCapabilities::cpu_default();
assert_eq!(caps.performance_score, 1.0);
assert_eq!(caps.memory_gb, 8.0);
assert!(caps.compute_units > 0);
}
}