From 5f95cad41606c2c32ef2fcd4aa79931c27b46f0a Mon Sep 17 00:00:00 2001 From: jgrusewski Date: Thu, 23 Apr 2026 10:50:56 +0200 Subject: [PATCH] fix(ensemble): DQN adapter tests use correct STATE_DIM input size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The DQN inference adapter tests hardcoded `vec![0.1; 56]` as the feature vector, but the DQN model's first shared layer expects STATE_DIM=96 inputs. cuBLAS gemm_ex was reading 40 elements past the end of the 56-allocated CudaSlice — uninitialized memory that happened to give consistent-enough values for the deterministic test to pass on the pre-change heap layout, and for other tests not to notice the out-of-bounds read. Surfaced by the Part 1 checkpoint-load work: adding the CUDA_LOCK mutex and a new weight_mu_mut method to NoisyLinear shifted allocation patterns enough that the uninitialized tail now reads different values between the two predict() calls in test_dqn_adapter_deterministic, flipping the argmax. Replace all three `vec![0.1|0.3; 56]` occurrences with `vec![...; ml_core::state_layout::STATE_DIM]` so the tests actually exercise the model with in-bounds memory. Co-Authored-By: Claude Opus 4.7 (1M context) --- crates/ml/src/ensemble/adapters/dqn.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/ml/src/ensemble/adapters/dqn.rs b/crates/ml/src/ensemble/adapters/dqn.rs index 21a6bfaff..062de4b08 100644 --- a/crates/ml/src/ensemble/adapters/dqn.rs +++ b/crates/ml/src/ensemble/adapters/dqn.rs @@ -303,7 +303,7 @@ mod tests { let _guard = CUDA_LOCK.lock().unwrap_or_else(|p| p.into_inner()); let adapter = DqnInferenceAdapter::new_on_device(test_config(), shared_device()).unwrap(); let fv = FeatureVector { - values: vec![0.1; 56], + values: vec![0.1; ml_core::state_layout::STATE_DIM], timestamp: 1700000000_000_000, }; let pred = adapter.predict(&fv).unwrap(); @@ -328,7 +328,7 @@ mod tests { let _guard = CUDA_LOCK.lock().unwrap_or_else(|p| p.into_inner()); let adapter = DqnInferenceAdapter::new_on_device(test_config(), shared_device()).unwrap(); let fv = FeatureVector { - values: vec![0.1; 56], + values: vec![0.1; ml_core::state_layout::STATE_DIM], timestamp: 1700000000_000_000, }; let pred1 = adapter.predict(&fv).unwrap(); @@ -361,7 +361,7 @@ mod tests { } let fv = FeatureVector { - values: vec![0.3; 56], + values: vec![0.3; ml_core::state_layout::STATE_DIM], timestamp: 1700000000, }; let pred1 = adapter.predict(&fv).expect("first predict");