Move 17 library crates into crates/, CLI binary into bin/fxt, consolidate 10 test crates into testing/, split config crate from deployment config files. Root directory reduced from 38+ to ~17 directories. All Cargo.toml paths and build.rs proto refs updated. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
80 lines
2.9 KiB
Rust
80 lines
2.9 KiB
Rust
// Minimal test to verify PPO minibatch_size fix
|
|
// Run with: cargo run --example test_ppo_fix --features cuda
|
|
|
|
use ml::hyperopt::adapters::ppo::PPOParams;
|
|
use ml::hyperopt::traits::ParameterSpace;
|
|
|
|
fn main() {
|
|
println!("Testing PPO minibatch_size parameter integration...\n");
|
|
|
|
// Test 1: Roundtrip for each valid divisor
|
|
let valid_divisors = [64, 128, 256, 512, 1024, 2048];
|
|
for &size in &valid_divisors {
|
|
let params = PPOParams {
|
|
policy_learning_rate: 1e-5,
|
|
value_learning_rate: 1e-4,
|
|
clip_epsilon: 0.2,
|
|
value_loss_coeff: 1.0,
|
|
entropy_coeff: 0.01,
|
|
minibatch_size: size,
|
|
};
|
|
|
|
let continuous = params.to_continuous();
|
|
let recovered = PPOParams::from_continuous(&continuous).expect("Failed to recover params");
|
|
|
|
assert_eq!(
|
|
recovered.minibatch_size, size,
|
|
"Roundtrip failed for minibatch_size={}",
|
|
size
|
|
);
|
|
println!("✓ Roundtrip test passed for minibatch_size={}", size);
|
|
}
|
|
|
|
// Test 2: Verify discrete sampling
|
|
println!("\nTesting discrete sampling from continuous space...");
|
|
|
|
for idx in 0..=5 {
|
|
let continuous = vec![
|
|
1e-5_f64.ln(), // policy_learning_rate
|
|
1e-4_f64.ln(), // value_learning_rate
|
|
0.2, // clip_epsilon
|
|
1.0, // value_loss_coeff
|
|
0.01_f64.ln(), // entropy_coeff
|
|
idx as f64, // minibatch_size index
|
|
];
|
|
|
|
let params = PPOParams::from_continuous(&continuous).expect("Failed to parse params");
|
|
let expected = valid_divisors[idx];
|
|
|
|
assert_eq!(
|
|
params.minibatch_size, expected,
|
|
"Index {} should map to {}",
|
|
idx, expected
|
|
);
|
|
println!("✓ Index {} -> minibatch_size={}", idx, expected);
|
|
}
|
|
|
|
// Test 3: Verify bounds
|
|
println!("\nTesting bounds...");
|
|
let bounds = PPOParams::continuous_bounds();
|
|
assert_eq!(bounds.len(), 6, "Should have 6 parameters");
|
|
assert_eq!(bounds[5], (0.0, 5.0), "Minibatch index should be [0, 5]");
|
|
println!("✓ Bounds test passed: {:?}", bounds[5]);
|
|
|
|
// Test 4: Verify parameter names
|
|
println!("\nTesting parameter names...");
|
|
let names = PPOParams::param_names();
|
|
assert_eq!(names.len(), 6, "Should have 6 parameter names");
|
|
assert_eq!(
|
|
names[5], "minibatch_size",
|
|
"6th parameter should be 'minibatch_size'"
|
|
);
|
|
println!("✓ Parameter names test passed: {}", names[5]);
|
|
|
|
println!("\n✅ ALL TESTS PASSED! Bug #1 fix verified.");
|
|
println!("\nSummary:");
|
|
println!(" - File: ml/src/hyperopt/adapters/ppo.rs line 385");
|
|
println!(" - Fix: Changed `mini_batch_size: 512` to `mini_batch_size: params.minibatch_size`");
|
|
println!(" - Impact: Hyperopt now correctly samples minibatch_size from [64, 128, 256, 512, 1024, 2048]");
|
|
}
|