fix: resolve all test warnings — wrap orphaned tests, drop unused bindings

- 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) <noreply@anthropic.com>
This commit is contained in:
jgrusewski
2026-04-02 23:31:33 +02:00
parent 8c75665722
commit b60bd030b0
3 changed files with 7 additions and 5 deletions

View File

@@ -918,7 +918,8 @@ fn a32i(s: &Arc<CudaStream>, n: usize, nm: &str) -> Result<CudaSlice<i32>, MLErr
s.alloc_zeros::<i32>(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<CudaStream> {
@@ -951,3 +952,4 @@ fn a32i(s: &Arc<CudaStream>, n: usize, nm: &str) -> Result<CudaSlice<i32>, MLErr
b.step(); b.clear().expect("clear");
assert_eq!(b.len(), 0); assert_eq!(b.current_step, 0);
}
}

View File

@@ -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!(

View File

@@ -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];