From 6deaf86643cb0adeea16c6dcc81a64e22d128fcd Mon Sep 17 00:00:00 2001 From: jgrusewski Date: Sun, 1 Mar 2026 20:43:27 +0100 Subject: [PATCH] =?UTF-8?q?feat(ml):=20PPO=20mixed=20precision=20auto-dete?= =?UTF-8?q?ction=20=E2=80=94=20BF16=20on=20A100/H100?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 --- crates/ml/src/trainers/ppo.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/crates/ml/src/trainers/ppo.rs b/crates/ml/src/trainers/ppo.rs index 84ceef19c..fef6d21ea 100644 --- a/crates/ml/src/trainers/ppo.rs +++ b/crates/ml/src/trainers/ppo.rs @@ -305,6 +305,21 @@ impl PpoTrainer { config.gae_config.gamma = hyperparams.gamma as f32; config.gae_config.lambda = hyperparams.gae_lambda; + // Auto-detect mixed precision capability based on GPU architecture + if device.is_cuda() { + match crate::memory_optimization::auto_batch_size::detect_gpu_memory() { + Ok((_total, _free, ref name)) => { + let detected = crate::dqn::mixed_precision::detect_from_gpu_name(name); + match &detected { + Some(c) => info!("PPO mixed precision: {:?} enabled (GPU: {})", c.dtype, name), + None => info!("PPO mixed precision: disabled (GPU: {})", name), + } + config.mixed_precision = detected; + } + Err(_) => {} + } + } + // Create PPO model with specified device (GPU or CPU) let model = PPO::with_device(config, device.clone())?;