blazen_train_tune/lib.rs
1//! AutoML / hyperparameter search on top of `blazen-train`.
2//!
3//! This crate is intentionally separate from `blazen-train` itself so that
4//! the heavy training engine (candle, hf-hub, tokenizers) doesn't have to
5//! be compiled in to use the searchers — the `Evaluator` trait is the only
6//! coupling point, and callers wire their own training loop into it.
7//!
8//! Pieces:
9//! - [`space`] — `SearchSpace` + `Distribution` (Categorical / IntUniform /
10//! Uniform / LogUniform / Discrete). The space defines what hyperparams
11//! exist and what each one's prior looks like.
12//! - [`trial`] — `Trial` record + status state machine.
13//! - [`searcher`] — `Searcher` trait + three real implementations:
14//! `RandomSearch`, `GridSearch`, and `TpeSearch` (Tree-structured
15//! Parzen Estimator, Bergstra et al. 2011, Algorithm 1).
16//! - [`journal`] — JSONL append-only `TrialJournal` for crash recovery.
17//! - [`runner`] — `Runner` glues a `SearchSpace` + `Searcher` + `Evaluator`
18//! + `TrialJournal` into a budgeted (max-trials / time-budget) loop,
19//! optionally fan-out across N tokio workers.
20//!
21//! See `examples/lora_sft_search.rs` for an end-to-end LoRA SFT search.
22//!
23//! ML acronyms (LoRA, TPE, KDE, SFT, ...) saturate the docs; backticking
24//! each one would hurt readability without adding clarity.
25#![allow(clippy::doc_markdown)]
26#![allow(clippy::doc_lazy_continuation)]
27// pedantic warns about returning Result from internal helpers; the API
28// shape is intentional (errors bubble up to the runner).
29#![allow(clippy::missing_errors_doc)]
30#![allow(clippy::module_name_repetitions)]
31
32pub mod error;
33pub mod journal;
34pub mod runner;
35pub mod searcher;
36pub mod space;
37pub mod trial;
38
39pub use error::TuneError;
40pub use journal::TrialJournal;
41pub use runner::{EvalFuture, Evaluator, Runner, RunnerBudget};
42pub use searcher::{GridSearch, RandomSearch, Searcher, TpeSearch};
43pub use space::{Distribution, SearchSpace};
44pub use trial::{Trial, TrialId, TrialStatus};