pub struct BrickTuner { /* private fields */ }Expand description
ML-based ComputeBrick tuner ensemble.
Combines three models for comprehensive recommendations:
- ThroughputRegressor: Predicts tok/s
- KernelClassifier: Selects best kernel
- BottleneckClassifier: Identifies performance bottleneck
Implementations§
Source§impl BrickTuner
impl BrickTuner
Sourcepub fn to_json(&self) -> Result<String, TunerError>
pub fn to_json(&self) -> Result<String, TunerError>
Serialize to JSON
Sourcepub fn from_json(json: &str) -> Result<Self, TunerError>
pub fn from_json(json: &str) -> Result<Self, TunerError>
Deserialize from JSON
Sourcepub fn cache_path() -> PathBuf
pub fn cache_path() -> PathBuf
Get the default cache path for tuner models.
Returns ~/.cache/trueno/tuner_model_v{VERSION}.apr
Sourcepub fn load_or_default() -> Self
pub fn load_or_default() -> Self
Load tuner from cache or create new with defaults.
This is the recommended way to create a BrickTuner for production use. It will:
- Check for cached model at
~/.cache/trueno/tuner_model_v{VERSION}.apr - Load if exists and version matches
- Create new with defaults if not found or version mismatch
Sourcepub fn save_apr<P: AsRef<Path>>(&self, path: P) -> Result<(), TunerError>
pub fn save_apr<P: AsRef<Path>>(&self, path: P) -> Result<(), TunerError>
Save tuner model to .apr file.
APR1 format (uncompressed):
- 4-byte magic: “APR1”
- 4-byte metadata_len: u32 LE
- JSON metadata
- 4-byte CRC32: checksum
Sourcepub fn load_apr<P: AsRef<Path>>(path: P) -> Result<Self, TunerError>
pub fn load_apr<P: AsRef<Path>>(path: P) -> Result<Self, TunerError>
Load tuner model from .apr file.
Sourcepub fn save_to_cache(&self) -> Result<(), TunerError>
pub fn save_to_cache(&self) -> Result<(), TunerError>
Save to default cache path.
Source§impl BrickTuner
impl BrickTuner
Sourcepub fn print_recommendation(&self, rec: &TunerRecommendation)
pub fn print_recommendation(&self, rec: &TunerRecommendation)
Print recommendations to console (TUI-friendly)
Sourcepub fn render_panel(&self, rec: &TunerRecommendation) -> Vec<String>
pub fn render_panel(&self, rec: &TunerRecommendation) -> Vec<String>
Render recommendation as TUI panel lines (for cbtop integration)
Returns a vector of strings that can be rendered in a TUI widget. Each line is formatted for fixed-width display (width=61 chars).
Sourcepub fn render_compact(&self, rec: &TunerRecommendation) -> String
pub fn render_compact(&self, rec: &TunerRecommendation) -> String
Render compact recommendation (single line for status bar)
Sourcepub fn render_comparison(
&self,
rec: &TunerRecommendation,
actual_tps: f32,
) -> Vec<String>
pub fn render_comparison( &self, rec: &TunerRecommendation, actual_tps: f32, ) -> Vec<String>
Render prediction vs actual comparison
Source§impl BrickTuner
impl BrickTuner
Sourcepub fn throughput_mape(&self) -> f32
pub fn throughput_mape(&self) -> f32
Get the throughput regressor’s MAPE (Mean Absolute Percentage Error)
Sourcepub fn throughput_sample_count(&self) -> usize
pub fn throughput_sample_count(&self) -> usize
Get the number of training samples used
Sourcepub fn recommend(&self, features: &TunerFeatures) -> TunerRecommendation
pub fn recommend(&self, features: &TunerFeatures) -> TunerRecommendation
Get comprehensive tuning recommendation
Sourcepub fn suggest_experiments(
&self,
features: &TunerFeatures,
bottleneck: &BottleneckPrediction,
) -> Vec<ExperimentSuggestion>
pub fn suggest_experiments( &self, features: &TunerFeatures, bottleneck: &BottleneckPrediction, ) -> Vec<ExperimentSuggestion>
Suggest experiments based on current bottleneck
Sourcepub fn train(&mut self, data: &[(TunerFeatures, f32)]) -> Result<(), TunerError>
pub fn train(&mut self, data: &[(TunerFeatures, f32)]) -> Result<(), TunerError>
Train all models on labeled data
Source§impl BrickTuner
impl BrickTuner
Sourcepub fn with_pretrained() -> Self
pub fn with_pretrained() -> Self
Create tuner with pre-trained weights from benchmark corpus
This is the recommended initialization for production use. Pre-trained on 10,000+ samples from CI benchmark runs.
Sourcepub fn calibrate(&mut self) -> Result<CalibrationResult, TunerError>
pub fn calibrate(&mut self) -> Result<CalibrationResult, TunerError>
Run first-run calibration to tune for local hardware
Runs micro-benchmarks and trains a local model. Typically completes in < 30 seconds.
Sourcepub fn online_learner(&self) -> OnlineLearner
pub fn online_learner(&self) -> OnlineLearner
Create an online learner for continuous improvement
Sourcepub fn apply_online_updates(&mut self, learner: &OnlineLearner)
pub fn apply_online_updates(&mut self, learner: &OnlineLearner)
Update tuner with observations from online learner
Sourcepub fn kernel_bandit(&self) -> KernelBandit
pub fn kernel_bandit(&self) -> KernelBandit
Create a bandit for kernel exploration
Sourcepub fn recommend_kernel_with_exploration(
&self,
features: &TunerFeatures,
bandit: &KernelBandit,
explore_prob: f32,
) -> KernelRecommendation
pub fn recommend_kernel_with_exploration( &self, features: &TunerFeatures, bandit: &KernelBandit, explore_prob: f32, ) -> KernelRecommendation
Get kernel recommendation using bandit (exploration mode)
Trait Implementations§
Source§impl Clone for BrickTuner
impl Clone for BrickTuner
Source§fn clone(&self) -> BrickTuner
fn clone(&self) -> BrickTuner
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BrickTuner
impl Debug for BrickTuner
Source§impl Default for BrickTuner
impl Default for BrickTuner
Source§impl<'de> Deserialize<'de> for BrickTuner
impl<'de> Deserialize<'de> for BrickTuner
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for BrickTuner
impl RefUnwindSafe for BrickTuner
impl Send for BrickTuner
impl Sync for BrickTuner
impl Unpin for BrickTuner
impl UnsafeUnpin for BrickTuner
impl UnwindSafe for BrickTuner
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.