90 lines
2.9 KiB
Rust
90 lines
2.9 KiB
Rust
//! RTX-Synthesis Bayesian Optimization Autotuning Engine
|
|
//!
|
|
//! This module provides a comprehensive autotuning system using Gaussian processes
|
|
//! for optimal kernel parameter exploration, with hardware-aware optimization,
|
|
//! multi-objective support, and persistent caching.
|
|
|
|
mod bayesian_tuner;
|
|
mod config;
|
|
mod gaussian_process;
|
|
mod legacy_tuner;
|
|
mod metrics;
|
|
mod parameters;
|
|
mod types;
|
|
|
|
// Re-export all public types
|
|
pub use bayesian_tuner::BayesianAutoTuner;
|
|
pub use config::{ConvergenceConfig, MultiObjectiveConfig, TuningConfig};
|
|
pub use gaussian_process::{CacheEntry, GaussianProcess, PersistentCache};
|
|
pub use legacy_tuner::AutoTuner;
|
|
pub use metrics::{
|
|
AcquisitionHistoryEntry, GPPrediction, Observation, PerformanceMetrics, PerformanceStatistics,
|
|
TuningResult,
|
|
};
|
|
pub use parameters::{ParameterDimension, ParameterRange, ParameterSpace};
|
|
pub use types::{AcquisitionFunction, ObjectiveMetric, ParameterType, SearchStrategy};
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
use crate::templates::{ElementwiseOp, KernelOperation};
|
|
|
|
#[tokio::test]
|
|
async fn test_autotuner_creation() {
|
|
let result = AutoTuner::new();
|
|
assert!(result.is_ok());
|
|
let autotuner = result.unwrap();
|
|
assert_eq!(autotuner.cache_stats().0, 0);
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn test_parameter_range_generation() {
|
|
let range = ParameterRange::new("block_size", 64, 256, 64);
|
|
let values = range.generate_values();
|
|
assert_eq!(values, vec![64, 128, 192, 256]);
|
|
|
|
let candidates_range = ParameterRange::with_candidates("tile_size", vec![1, 2, 4, 8]);
|
|
let candidates = candidates_range.generate_values();
|
|
assert_eq!(candidates, vec![1, 2, 4, 8]);
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn test_tuning_config_for_gemm() {
|
|
let autotuner = AutoTuner::new().unwrap();
|
|
let operation = KernelOperation::Gemm {
|
|
m: 1024,
|
|
n: 1024,
|
|
k: 1024,
|
|
transpose_a: false,
|
|
transpose_b: false,
|
|
};
|
|
|
|
let config = autotuner.create_tuning_config(&operation).unwrap();
|
|
|
|
assert!(matches!(
|
|
config.search_strategy,
|
|
SearchStrategy::BayesianOptimization { .. }
|
|
));
|
|
assert!(!config.parameter_ranges.is_empty());
|
|
|
|
let param_names: Vec<_> = config.parameter_ranges.iter().map(|r| &r.name).collect();
|
|
assert!(param_names.contains(&&"block_size_m".to_string()));
|
|
assert!(param_names.contains(&&"block_size_n".to_string()));
|
|
assert!(param_names.contains(&&"unroll_factor".to_string()));
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn test_cache_functionality() {
|
|
let mut autotuner = AutoTuner::new().unwrap();
|
|
|
|
let (total, expired) = autotuner.cache_stats();
|
|
assert_eq!(total, 0);
|
|
assert_eq!(expired, 0);
|
|
|
|
autotuner.clear_cache();
|
|
|
|
let (total_after_clear, _) = autotuner.cache_stats();
|
|
assert_eq!(total_after_clear, 0);
|
|
}
|
|
}
|