1use thiserror::Error;
4
5pub type Result<T> = std::result::Result<T, LittleBitError>;
7
8#[derive(Debug, Error)]
10pub enum LittleBitError {
11 #[error("tensor operation failed: {0}")]
13 Candle(#[from] candle_core::Error),
14
15 #[error("safetensors error: {0}")]
17 SafeTensors(#[from] safetensors::SafeTensorError),
18
19 #[error("i/o error: {0}")]
21 Io(#[from] std::io::Error),
22
23 #[error("json error: {0}")]
25 Json(#[from] serde_json::Error),
26
27 #[error("invalid quantization config: {0}")]
29 InvalidConfig(String),
30
31 #[error("invalid tensor shape: expected {expected}, got {actual}")]
33 InvalidShape {
34 expected: String,
36 actual: String,
38 },
39
40 #[error("invalid binary value {value} at ({row}, {col}); expected -1 or +1")]
42 InvalidBinaryValue {
43 row: usize,
45 col: usize,
47 value: i8,
49 },
50
51 #[error("svd decomposition failed: {0}")]
53 SvdFailed(String),
54
55 #[error("missing tensor `{0}` in state dict")]
57 MissingTensor(String),
58
59 #[error("unsupported tensor dtype: {0}")]
61 UnsupportedDtype(String),
62
63 #[error("no model weights found in `{0}`")]
65 CheckpointNotFound(String),
66}
67
68const _: () = {
69 const fn assert_send_sync<T: Send + Sync + 'static>() {}
70 assert_send_sync::<LittleBitError>();
71};