Skip to main content

entrenar_bench/
lib.rs

1//! Distillation benchmarking and hyperparameter sweep tool.
2//!
3//! This crate provides tools for:
4//! - Systematic hyperparameter sweeps
5//! - Statistical analysis of results
6//! - Comparison of distillation strategies
7//! - Cost-performance analysis and recommendations
8//!
9//! # Toyota Way Principles
10//!
11//! - **Kaizen**: Data-driven optimization through systematic experimentation
12//! - **Muda Elimination**: Avoid wasted training runs through early stopping
13//! - **Visual Control**: Clear visualization of benchmark results
14
15pub mod cost;
16pub mod stats;
17pub mod strategies;
18pub mod sweep;
19
20pub use cost::{
21    ConfigParams, Constraints, CostModel, CostPerformanceAnalysis, CostPerformancePoint,
22    Recommendation,
23};
24pub use stats::{StatisticalAnalyzer, TestResult};
25pub use strategies::{DistillStrategy, StrategyComparison};
26pub use sweep::{SweepConfig, SweepResult, Sweeper};
27
28use entrenar_common::Result;
29
30/// Run a temperature sweep.
31pub fn temperature_sweep(
32    range: std::ops::Range<f32>,
33    step: f32,
34    runs_per_point: usize,
35) -> Result<SweepResult> {
36    let config = SweepConfig::temperature(range, step).with_runs(runs_per_point);
37    Sweeper::new(config).run()
38}
39
40/// Compare multiple distillation strategies.
41pub fn compare_strategies(strategies: &[DistillStrategy]) -> Result<StrategyComparison> {
42    strategies::compare(strategies)
43}
44
45#[cfg(test)]
46mod tests {
47    use super::*;
48
49    #[test]
50    fn test_temperature_sweep_returns_results() {
51        let result = temperature_sweep(1.0..4.0, 1.0, 1);
52        assert!(result.is_ok());
53    }
54}