fix: cudarc 0.19 API fixes in tests — CudaDevice→CudaContext, no Arc double-wrap
Test code used CudaDevice (cudarc 0.17) instead of CudaContext (0.19), and wrapped Arc::new(CudaContext::new().new_stream()) which double-wraps since new_stream() already returns Arc<CudaStream>. 740 tests pass across ml-core, ml-ppo, ml-supervised, ml-ensemble. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -595,12 +595,10 @@ mod tests {
|
||||
use super::*;
|
||||
|
||||
fn make_stream() -> Arc<CudaStream> {
|
||||
Arc::new(
|
||||
cudarc::driver::CudaDevice::new(0)
|
||||
cudarc::driver::CudaContext::new(0)
|
||||
.expect("CUDA required")
|
||||
.fork_default_stream()
|
||||
.expect("fork stream"),
|
||||
)
|
||||
.new_stream()
|
||||
.expect("fork stream")
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -892,12 +892,10 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_zeros_shape() {
|
||||
let stream = Arc::new(
|
||||
cudarc::driver::CudaDevice::new(0)
|
||||
let stream = cudarc::driver::CudaContext::new(0)
|
||||
.expect("CUDA required")
|
||||
.fork_default_stream()
|
||||
.expect("fork stream"),
|
||||
);
|
||||
.new_stream()
|
||||
.expect("fork stream");
|
||||
let t = GpuTensor::zeros(&[4, 8], &stream).unwrap();
|
||||
assert_eq!(t.shape(), &[4, 8]);
|
||||
assert_eq!(t.numel(), 32);
|
||||
@@ -905,12 +903,10 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_roundtrip() {
|
||||
let stream = Arc::new(
|
||||
cudarc::driver::CudaDevice::new(0)
|
||||
let stream = cudarc::driver::CudaContext::new(0)
|
||||
.expect("CUDA required")
|
||||
.fork_default_stream()
|
||||
.expect("fork stream"),
|
||||
);
|
||||
.new_stream()
|
||||
.expect("fork stream");
|
||||
let host_data: Vec<f32> = (0..12).map(|i| i as f32).collect();
|
||||
let t = GpuTensor::from_host(&host_data, vec![3, 4], &stream).unwrap();
|
||||
let back = t.to_host(&stream).unwrap();
|
||||
@@ -919,12 +915,10 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_shape_mismatch() {
|
||||
let stream = Arc::new(
|
||||
cudarc::driver::CudaDevice::new(0)
|
||||
let stream = cudarc::driver::CudaContext::new(0)
|
||||
.expect("CUDA required")
|
||||
.fork_default_stream()
|
||||
.expect("fork stream"),
|
||||
);
|
||||
.new_stream()
|
||||
.expect("fork stream");
|
||||
let host_data = vec![1.0_f32; 10];
|
||||
let result = GpuTensor::from_host(&host_data, vec![3, 4], &stream);
|
||||
assert!(result.is_err());
|
||||
@@ -932,12 +926,10 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_reshape() {
|
||||
let stream = Arc::new(
|
||||
cudarc::driver::CudaDevice::new(0)
|
||||
let stream = cudarc::driver::CudaContext::new(0)
|
||||
.expect("CUDA required")
|
||||
.fork_default_stream()
|
||||
.expect("fork stream"),
|
||||
);
|
||||
.new_stream()
|
||||
.expect("fork stream");
|
||||
let t = GpuTensor::zeros(&[6, 4], &stream).unwrap();
|
||||
let t2 = t.reshape(vec![2, 12]).unwrap();
|
||||
assert_eq!(t2.shape(), &[2, 12]);
|
||||
|
||||
@@ -141,12 +141,10 @@ mod tests {
|
||||
use super::*;
|
||||
|
||||
fn make_stream() -> Arc<CudaStream> {
|
||||
Arc::new(
|
||||
cudarc::driver::CudaDevice::new(0)
|
||||
cudarc::driver::CudaContext::new(0)
|
||||
.expect("CUDA required")
|
||||
.fork_default_stream()
|
||||
.expect("fork stream"),
|
||||
)
|
||||
.new_stream()
|
||||
.expect("fork stream")
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -362,12 +362,10 @@ mod tests {
|
||||
use super::super::var_store::GpuVarStore;
|
||||
|
||||
fn make_stream() -> Arc<CudaStream> {
|
||||
Arc::new(
|
||||
cudarc::driver::CudaDevice::new(0)
|
||||
cudarc::driver::CudaContext::new(0)
|
||||
.expect("CUDA required")
|
||||
.fork_default_stream()
|
||||
.expect("fork stream"),
|
||||
)
|
||||
.new_stream()
|
||||
.expect("fork stream")
|
||||
}
|
||||
|
||||
fn make_cublas(stream: &Arc<CudaStream>) -> CudaBlas {
|
||||
|
||||
@@ -218,12 +218,10 @@ mod tests {
|
||||
use super::*;
|
||||
|
||||
fn make_stream() -> Arc<CudaStream> {
|
||||
Arc::new(
|
||||
cudarc::driver::CudaDevice::new(0)
|
||||
cudarc::driver::CudaContext::new(0)
|
||||
.expect("CUDA required")
|
||||
.fork_default_stream()
|
||||
.expect("fork stream"),
|
||||
)
|
||||
.new_stream()
|
||||
.expect("fork stream")
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -368,12 +368,10 @@ mod tests {
|
||||
use super::super::init;
|
||||
|
||||
fn make_stream() -> Arc<CudaStream> {
|
||||
Arc::new(
|
||||
cudarc::driver::CudaDevice::new(0)
|
||||
cudarc::driver::CudaContext::new(0)
|
||||
.expect("CUDA required")
|
||||
.fork_default_stream()
|
||||
.expect("fork stream"),
|
||||
)
|
||||
.new_stream()
|
||||
.expect("fork stream")
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -353,12 +353,10 @@ mod tests {
|
||||
use super::*;
|
||||
|
||||
fn make_stream() -> Arc<CudaStream> {
|
||||
Arc::new(
|
||||
cudarc::driver::CudaDevice::new(0)
|
||||
.expect("CUDA required")
|
||||
.fork_default_stream()
|
||||
.expect("fork stream"),
|
||||
)
|
||||
cudarc::driver::CudaContext::new(0)
|
||||
.expect("CUDA required")
|
||||
.new_stream()
|
||||
.expect("fork stream")
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -88,7 +88,8 @@ pub fn directional_mse_loss(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use cudarc::driver::CudaContext;
|
||||
use std::sync::Arc;
|
||||
use cudarc::driver::{CudaContext, CudaStream};
|
||||
|
||||
fn test_stream() -> Arc<CudaStream> {
|
||||
let ctx = CudaContext::new(0).expect("CUDA context required");
|
||||
|
||||
@@ -3019,6 +3019,7 @@ impl Clone for Mamba2SSM {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use anyhow::Result;
|
||||
use cudarc::driver::CudaContext;
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_mamba_creation() -> Result<()> {
|
||||
|
||||
Reference in New Issue
Block a user