From b60bd030b026a50718069e9cf7782630d5dcd2cc Mon Sep 17 00:00:00 2001 From: jgrusewski Date: Thu, 2 Apr 2026 23:31:33 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20resolve=20all=20test=20warnings=20?= =?UTF-8?q?=E2=80=94=20wrap=20orphaned=20tests,=20drop=20unused=20bindings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - gpu_replay_buffer.rs: orphaned test functions (test_creation, test_beta, test_clear) and make_stream helper were at module level without #[cfg(test)] mod tests wrapper. Added proper module boundary. - gpu_residency.rs, training_stability.rs: sample_proportional() called for side effect (populates internal buffers asserted on next line). Dropped unused batch/batch2 bindings. Co-Authored-By: Claude Opus 4.6 (1M context) --- crates/ml-dqn/src/gpu_replay_buffer.rs | 4 +++- crates/ml/src/trainers/dqn/smoke_tests/gpu_residency.rs | 4 ++-- crates/ml/src/trainers/dqn/smoke_tests/training_stability.rs | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/crates/ml-dqn/src/gpu_replay_buffer.rs b/crates/ml-dqn/src/gpu_replay_buffer.rs index bd8f815ae..63bcc650f 100644 --- a/crates/ml-dqn/src/gpu_replay_buffer.rs +++ b/crates/ml-dqn/src/gpu_replay_buffer.rs @@ -918,7 +918,8 @@ fn a32i(s: &Arc, n: usize, nm: &str) -> Result, MLErr s.alloc_zeros::(n).map_err(|e| MLError::ModelError(format!("alloc {nm}: {e}"))) } -/// DtoD clone of first `n` elements from `src` into a new allocation (async on stream). +#[cfg(test)] +mod tests { use super::*; fn make_stream() -> Arc { @@ -951,3 +952,4 @@ fn a32i(s: &Arc, n: usize, nm: &str) -> Result, MLErr b.step(); b.clear().expect("clear"); assert_eq!(b.len(), 0); assert_eq!(b.current_step, 0); } +} diff --git a/crates/ml/src/trainers/dqn/smoke_tests/gpu_residency.rs b/crates/ml/src/trainers/dqn/smoke_tests/gpu_residency.rs index 81b109714..bf8ccd7fc 100644 --- a/crates/ml/src/trainers/dqn/smoke_tests/gpu_residency.rs +++ b/crates/ml/src/trainers/dqn/smoke_tests/gpu_residency.rs @@ -193,7 +193,7 @@ fn test_gpu_replay_buffer_priority_update_valid() -> anyhow::Result<()> { let idx = batch.indices_ptr; buf.update_priorities_gpu_raw(idx, &td_errors, 16)?; // Verify sampling still works with updated priorities (proves update succeeded) - let batch2 = buf.sample_proportional(16)?; + buf.sample_proportional(16)?; let weights_host = dtoh_f32(buf.sample_weights_ref(), &stream)?; // Weights should still be positive after priority update @@ -221,7 +221,7 @@ fn test_searchsorted_gpu_correctness() -> anyhow::Result<()> { // Sample multiple times to exercise the searchsorted codepath (GPU-resident) for trial in 0..5 { - let batch = buf.sample_proportional(10)?; + buf.sample_proportional(10)?; let indices_host = dtoh_u32(buf.sample_indices_ref(), &stream)?; for (i, &idx) in indices_host.iter().enumerate() { assert!( diff --git a/crates/ml/src/trainers/dqn/smoke_tests/training_stability.rs b/crates/ml/src/trainers/dqn/smoke_tests/training_stability.rs index afd78853f..6e34ecba2 100644 --- a/crates/ml/src/trainers/dqn/smoke_tests/training_stability.rs +++ b/crates/ml/src/trainers/dqn/smoke_tests/training_stability.rs @@ -114,7 +114,7 @@ fn test_per_weights_valid() -> anyhow::Result<()> { buf.insert_batch(&states, &next_states, &actions, &rewards, &dones, 1)?; } - let batch = buf.sample_proportional(16)?; + buf.sample_proportional(16)?; // Download f32 weights to host for assertion let mut weights_host = vec![0.0_f32; 16]; @@ -158,7 +158,7 @@ fn test_per_indices_valid() -> anyhow::Result<()> { buf.insert_batch(&states, &next_states, &actions, &rewards, &dones, 1)?; } - let batch = buf.sample_proportional(16)?; + buf.sample_proportional(16)?; // Download indices to host for assertion let mut indices_host = vec![0_u32; 16];