cleanup: remove AutoBatchSizer — batch_size from config is source of truth

AutoBatchSizer didn't account for experience collector VRAM, causing
OOM on H100 with state_dim=96. batch_size is configured per GPU
profile (h100.toml=8192, rtx3050.toml=64). No auto-sizing needed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
jgrusewski
2026-04-17 09:35:16 +02:00
parent d144171b92
commit 5836280a34

View File

@@ -23,7 +23,6 @@ use crate::dqn::regime_conditional::RegimeConditionalDQN;
use crate::dqn::reward::{RewardConfig, RewardFunction};
use crate::features::microstructure_features::*;
use crate::labeling::triple_barrier::TripleBarrierEngine;
use crate::memory_optimization::auto_batch_size::{AutoBatchSizer, BatchSizeConfig};
use crate::TrainingMetrics;
use super::super::config::{DQNAgentType, DQNHyperparameters};
use super::DQNTrainer;
@@ -77,43 +76,12 @@ impl DQNTrainer {
full_dims, param_count, model_overhead_mb
);
// Dynamic batch sizing: fully VRAM-derived, no hardcoded caps.
// AutoBatchSizer computes the safe maximum from free GPU memory.
let max_safe_batch = match AutoBatchSizer::new() {
Ok(sizer) => {
let config = BatchSizeConfig {
model_memory_mb: model_overhead_mb,
safety_margin: 0.15,
..BatchSizeConfig::default()
};
let safe = sizer.max_safe_batch_size(&config);
info!(
"AutoBatchSizer: GPU VRAM ceiling = {} (configured: {})",
safe, hyperparams.batch_size
);
safe
}
Err(e) => {
info!("AutoBatchSizer unavailable ({e}), using batch_size as-is");
hyperparams.batch_size.max(64)
}
};
// batch_size == 0 -> auto-compute from VRAM (no artificial cap)
// batch_size is configured per GPU profile (h100.toml, rtx3050.toml).
// No auto-sizing — the config is the source of truth.
if hyperparams.batch_size == 0 {
hyperparams.batch_size = max_safe_batch.min(8192); // fallback only — profiles should set batch_size
info!("AutoBatchSizer: batch_size auto-computed to {}", hyperparams.batch_size);
}
// Cap to VRAM ceiling (never exceed what the GPU can handle)
if hyperparams.batch_size > max_safe_batch {
info!(
"DQN batch_size capped from {} -> {} (VRAM ceiling)",
hyperparams.batch_size, max_safe_batch
);
hyperparams.batch_size = max_safe_batch.min(8192); // fallback only — profiles should set batch_size
hyperparams.batch_size = 1024; // sensible default if somehow unset
}
info!("DQN batch_size: {} (from config)", hyperparams.batch_size);
// Use override device if provided (hyperopt shares one CUDA context),
// otherwise require CUDA GPU -- no CPU fallback in CUDA builds.