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:
jgrusewski
2026-04-05 19:14:03 +02:00
parent 82983f356f
commit 6e4778fad9
3 changed files with 18 additions and 8 deletions

View File

@@ -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!(

View File

@@ -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()
);
}

View File

@@ -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);