fix: update test expectations for production batch_size + OFI state_dim
- Profile tests: batch_size 1024→8192, mbp10_data_dir /mnt→/data - Trainer tests: state_dim adapts to OFI config (45 without, 53 with) - Add batch_size>0 validation in trainer constructor - 891 unit tests pass, 0 failures Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -30,6 +30,13 @@ use super::DQNTrainer;
|
||||
|
||||
impl DQNTrainer {
|
||||
pub(crate) fn new_internal(mut hyperparams: DQNHyperparameters, debug_logging: bool, override_device: Option<MlDevice>) -> Result<Self> {
|
||||
// Validate batch_size > 0
|
||||
if hyperparams.batch_size == 0 {
|
||||
return Err(anyhow::anyhow!(
|
||||
"batch_size must be greater than 0"
|
||||
));
|
||||
}
|
||||
|
||||
// WAVE 26 P2.2: Validate gradient_accumulation_steps > 0
|
||||
if hyperparams.gradient_accumulation_steps == 0 {
|
||||
return Err(anyhow::anyhow!(
|
||||
|
||||
@@ -115,13 +115,16 @@ async fn test_feature_vector_to_state() {
|
||||
);
|
||||
|
||||
let state = state.unwrap();
|
||||
// State dimension is 45 (42 market + 3 portfolio)
|
||||
// - Market features: 0-41 (42 features)
|
||||
// - Portfolio features: 42-44 (3 features, populated by PortfolioTracker)
|
||||
// State dimension depends on whether OFI (MBP-10) data dirs are configured:
|
||||
// - Without OFI: 45 = 42 market + 3 portfolio
|
||||
// - With OFI: 53 = 42 market + 8 OFI + 3 portfolio
|
||||
// Smoketest TOML sets mbp10_data_dir, so OFI is enabled.
|
||||
let expected_dim = if trainer.hyperparams.mbp10_data_dir.is_empty() { 45 } else { 53 };
|
||||
assert_eq!(
|
||||
state.dimension(),
|
||||
45,
|
||||
"State dimension should be 45 (42 market + 3 portfolio features)"
|
||||
expected_dim,
|
||||
"State dimension mismatch (OFI enabled={})",
|
||||
!trainer.hyperparams.mbp10_data_dir.is_empty()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1088,13 +1088,13 @@ mod tests {
|
||||
|
||||
// [training] values must have been applied
|
||||
assert_eq!(hp.epochs, 200);
|
||||
assert_eq!(hp.batch_size, 1024);
|
||||
assert_eq!(hp.batch_size, 8192);
|
||||
assert!((hp.learning_rate - 0.0001).abs() < 1e-10);
|
||||
|
||||
// OFI MBP-10 data dir should be set in production profile
|
||||
assert_eq!(
|
||||
hp.mbp10_data_dir.as_str(),
|
||||
"/mnt/training-data/futures-baseline-mbp10",
|
||||
"/data/futures-baseline-mbp10",
|
||||
"dqn-production profile must wire mbp10_data_dir"
|
||||
);
|
||||
}
|
||||
@@ -1350,7 +1350,7 @@ mod tests {
|
||||
|
||||
// [training] section
|
||||
assert_eq!(hp.epochs, 200);
|
||||
assert_eq!(hp.batch_size, 1024);
|
||||
assert_eq!(hp.batch_size, 8192);
|
||||
assert!((hp.learning_rate - 0.0001).abs() < 1e-10);
|
||||
assert!((hp.gamma - 0.99).abs() < 0.001);
|
||||
assert!((hp.reward_scale - 1.0).abs() < 0.01);
|
||||
|
||||
Reference in New Issue
Block a user