From f4059a7510fff2c8339baf3acd107ffe0c1926ec Mon Sep 17 00:00:00 2001 From: jgrusewski Date: Wed, 15 Apr 2026 13:56:05 +0200 Subject: [PATCH] fix: concat_ofi_features uses state_dim_padded stride, not state_dim MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit states_buf has stride pad128(state_dim) for CUTLASS alignment. The concat_ofi kernel was reading with stride state_dim → OOB for sample 1+. With state_dim=50, pad=128: sample 1 OFI at offset 128+42=170, but kernel read at 50+42=92 (sample 0 padding area). Silent data corruption. Co-Authored-By: Claude Opus 4.6 (1M context) --- crates/ml/src/cuda_pipeline/gpu_dqn_trainer.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/ml/src/cuda_pipeline/gpu_dqn_trainer.rs b/crates/ml/src/cuda_pipeline/gpu_dqn_trainer.rs index 38cb37dd3..304f80b09 100644 --- a/crates/ml/src/cuda_pipeline/gpu_dqn_trainer.rs +++ b/crates/ml/src/cuda_pipeline/gpu_dqn_trainer.rs @@ -1438,7 +1438,8 @@ impl GpuDqnTrainer { }; let b = self.config.batch_size as i32; let sh2 = self.config.shared_h2 as i32; - let sd = self.config.state_dim as i32; + // states_buf has stride state_dim_padded (pad128), NOT state_dim + let sd = ((self.config.state_dim + 127) & !127) as i32; let total = b * (sh2 + 3); let blocks = ((total as u32 + 255) / 256).max(1); let vsn_masked_ptr = self.vsn_masked_buf.raw_ptr();