Skip to main content

littlebit_train/
error.rs

1//! Typed errors for `littlebit-train`.
2
3use thiserror::Error;
4
5/// Result alias for `littlebit-train` operations.
6pub type Result<T> = std::result::Result<T, TrainError>;
7
8/// Errors produced during QAT knowledge distillation, data preparation, or evaluation.
9#[derive(Debug, Error)]
10pub enum TrainError {
11    /// Error from `littlebit-core`.
12    #[error(transparent)]
13    Core(#[from] littlebit_core::LittleBitError),
14
15    /// Error from `littlebit-models`.
16    #[error(transparent)]
17    Model(#[from] littlebit_models::ModelError),
18
19    /// Underlying Candle tensor error.
20    #[error("tensor operation failed: {0}")]
21    Candle(#[from] candle_core::Error),
22
23    /// Filesystem I/O failure.
24    #[error("i/o error: {0}")]
25    Io(#[from] std::io::Error),
26
27    /// JSON parse or serialization failure.
28    #[error("json error: {0}")]
29    Json(#[from] serde_json::Error),
30
31    /// Hugging Face Hub error.
32    #[error("huggingface hub error: {0}")]
33    Hub(#[from] hf_hub::HFError),
34
35    /// Tokenizer error.
36    #[error("tokenizer error: {0}")]
37    Tokenizer(String),
38
39    /// HTTP dataset fetch error.
40    #[error("http fetch error: {0}")]
41    Http(String),
42
43    /// Invalid training or evaluation argument.
44    #[error("invalid argument: {0}")]
45    InvalidArgument(String),
46}
47
48const _: () = {
49    const fn assert_send_sync<T: Send + Sync + 'static>() {}
50    assert_send_sync::<TrainError>();
51};