From 5363185721481d81ffc36eaad0f9c3b37155dfd7 Mon Sep 17 00:00:00 2001 From: jgrusewski Date: Wed, 1 Apr 2026 22:08:01 +0200 Subject: [PATCH] =?UTF-8?q?perf:=20dynamic=20batch=20sizing=20=E2=80=94=20?= =?UTF-8?q?AutoBatchSizer=20drives=20batch=5Fsize=20on=20H100?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Set batch_size=0 in config/gpu/h100.toml as sentinel for auto-compute. The constructor now treats batch_size==0 as "let AutoBatchSizer drive": it uses the VRAM-computed ceiling capped at 8192, instead of the static 1024 that was wasting >90% of H100's 80GB VRAM bandwidth. Previously AutoBatchSizer computed the optimal batch (e.g. 2085808) but the profile's batch_size=1024 always won. Now with batch_size=0 the sizer's result flows through, enabling full SM occupancy on H100. Co-Authored-By: Claude Opus 4.6 (1M context) --- config/gpu/h100.toml | 2 +- crates/ml/src/trainers/dqn/trainer/constructor.rs | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/config/gpu/h100.toml b/config/gpu/h100.toml index ef0aab8d6..fd5e87a1f 100644 --- a/config/gpu/h100.toml +++ b/config/gpu/h100.toml @@ -1,6 +1,6 @@ # H100 PCIe/SXM (80GB VRAM) -- full production [training] -batch_size = 1024 +batch_size = 0 # 0 = auto-compute from VRAM via AutoBatchSizer num_atoms = 51 buffer_size = 500_000 hidden_dim_base = 256 diff --git a/crates/ml/src/trainers/dqn/trainer/constructor.rs b/crates/ml/src/trainers/dqn/trainer/constructor.rs index 5692acf02..8ab5f4501 100644 --- a/crates/ml/src/trainers/dqn/trainer/constructor.rs +++ b/crates/ml/src/trainers/dqn/trainer/constructor.rs @@ -30,14 +30,6 @@ use super::DQNTrainer; impl DQNTrainer { pub(crate) fn new_internal(mut hyperparams: DQNHyperparameters, debug_logging: bool, override_device: Option) -> Result { - // Validate batch size is non-zero - if hyperparams.batch_size == 0 { - return Err(anyhow::anyhow!( - "Batch size must be greater than 0, got: {}", - hyperparams.batch_size - )); - } - // WAVE 26 P2.2: Validate gradient_accumulation_steps > 0 if hyperparams.gradient_accumulation_steps == 0 { return Err(anyhow::anyhow!( @@ -105,6 +97,13 @@ impl DQNTrainer { } }; + // batch_size == 0 is the sentinel for auto-compute from VRAM. + // Let AutoBatchSizer drive the batch size, capped at 8192. + if hyperparams.batch_size == 0 { + hyperparams.batch_size = max_safe_batch.min(STATIC_MAX_BATCH_SIZE); + info!("AutoBatchSizer: batch_size auto-computed to {}", hyperparams.batch_size); + } + // Cap to VRAM ceiling from AutoBatchSizer (no separate scale-UP — // AutoBatchSizer already accounts for model size and available VRAM) if hyperparams.batch_size > max_safe_batch {