Files
foxhunt/ml/examples/test_cuda_basic.rs
jgrusewski 4d0efa82df feat(wave1-2): Complete multi-model training architecture + TLI commands
Wave 1 (Architecture & Design - 5 agents):
- Multi-model training orchestration (DQN, PPO, MAMBA-2, TFT-INT8)
- Sequential training strategy (95.9% GPU headroom, 6.3min total)
- Hybrid multi-asset strategy (2x parallel, 22% GPU usage, 12-18min)
- Backward compatible gRPC API design with oneof pattern
- TDD test pyramid (67 tests: 24 unit + 28 integration + 15 E2E)
- Implementation roadmap (20 agents, 2.5 weeks, 13,280 LOC)

Wave 2 (Core TLI Commands - 5 agents):
- tli train start: Multi-model, multi-asset job submission (14 tests )
- tli train watch: Real-time streaming with weighted progress (10 tests )
- tli train status: Color-coded formatted status display (10 tests )
- tli train list: Filtering, sorting, pagination support (12 tests )
- tli train stop: Graceful cancellation with checkpoints (11 tests )

Status:
- 57/57 tests passing (100% TDD compliance)
- ~4,095 LOC (tests + implementation + docs)
- 3.5 hours actual vs 15-20 hours estimated (78% faster)
- Zero compilation errors, production-ready code
- Full documentation: WAVE_2_TLI_COMMANDS_COMPLETE.md

Next: Wave 3 (Multi-Asset Multi-Model Backend Logic - 5 agents)

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-22 20:50:43 +02:00

68 lines
3.5 KiB
Rust

//! Basic CUDA functionality test
//! Tests if basic tensor operations work on CUDA device without hanging
use anyhow::Result;
use candle_core::{Device, Tensor};
fn main() -> Result<()> {
println!("╔═══════════════════════════════════════════════════════════╗");
println!("║ Basic CUDA Test ║");
println!("╚═══════════════════════════════════════════════════════════╝");
// Test 1: Device creation
println!("\n[TEST 1] Creating CUDA device...");
let device = Device::new_cuda(0)?;
println!("✓ CUDA device created successfully");
// Test 2: Simple tensor creation on CUDA
println!("\n[TEST 2] Creating tensor on CUDA...");
let tensor_cuda = Tensor::zeros((32, 225), candle_core::DType::F64, &device)?;
println!("✓ Tensor created on CUDA: {:?}", tensor_cuda.dims());
// Test 3: CPU tensor creation and device transfer
println!("\n[TEST 3] Creating CPU tensor and transferring to CUDA...");
let data: Vec<f64> = (0..100).map(|i| i as f64).collect();
let tensor_cpu = Tensor::new(&data[..], &Device::Cpu)?;
println!(" CPU tensor shape: {:?}", tensor_cpu.dims());
let tensor_moved = tensor_cpu.to_device(&device)?;
println!("✓ Tensor moved to CUDA: {:?}", tensor_moved.dims());
// Test 4: Basic arithmetic on CUDA
println!("\n[TEST 4] Testing arithmetic operations on CUDA...");
let a = Tensor::ones((10, 10), candle_core::DType::F64, &device)?;
let b = Tensor::ones((10, 10), candle_core::DType::F64, &device)?;
let c = (&a + &b)?;
println!("✓ Addition completed: result shape {:?}", c.dims());
// Test 5: Matrix multiplication on CUDA
println!("\n[TEST 5] Testing matmul on CUDA...");
let x = Tensor::randn(0.0, 1.0, (32, 225), &device)?;
let y = Tensor::randn(0.0, 1.0, (225, 16), &device)?;
let z = x.matmul(&y)?;
println!("✓ Matmul completed: result shape {:?}", z.dims());
// Test 6: Concatenation on CUDA
println!("\n[TEST 6] Testing concatenation on CUDA...");
let t1 = Tensor::ones((1, 60, 225), candle_core::DType::F64, &device)?;
let t2 = Tensor::ones((1, 60, 225), candle_core::DType::F64, &device)?;
let t_cat = Tensor::cat(&[&t1, &t2], 0)?;
println!("✓ Concatenation completed: result shape {:?}", t_cat.dims());
// Test 7: Device transfer after concatenation
println!("\n[TEST 7] Testing device transfer after concatenation...");
let t1_cpu = Tensor::ones((1, 60, 225), candle_core::DType::F64, &Device::Cpu)?;
let t2_cpu = Tensor::ones((1, 60, 225), candle_core::DType::F64, &Device::Cpu)?;
let t_cat_cpu = Tensor::cat(&[&t1_cpu, &t2_cpu], 0)?;
println!(" CPU concatenated tensor: {:?}", t_cat_cpu.dims());
let t_cat_cuda = t_cat_cpu.to_device(&device)?;
println!("✓ Device transfer completed: {:?}", t_cat_cuda.dims());
println!("\n╔═══════════════════════════════════════════════════════════╗");
println!("║ All CUDA Tests PASSED ║");
println!("╚═══════════════════════════════════════════════════════════╝");
Ok(())
}