Skip to main content

qlora_rs/
error.rs

1//! Error types for qlora-rs.
2
3use thiserror::Error;
4
5/// Result type alias for qlora-rs operations.
6pub type Result<T> = std::result::Result<T, QLoraError>;
7
8/// Errors that can occur in qlora-rs operations.
9#[derive(Error, Debug)]
10#[non_exhaustive]
11pub enum QLoraError {
12    /// Invalid quantization configuration.
13    #[error("invalid quantization config: {0}")]
14    InvalidConfig(String),
15
16    /// Quantization error.
17    #[error("quantization error: {0}")]
18    Quantization(String),
19
20    /// Shape mismatch.
21    #[error("shape mismatch: expected {expected:?}, got {actual:?}")]
22    ShapeMismatch {
23        /// Expected shape
24        expected: Vec<usize>,
25        /// Actual shape
26        actual: Vec<usize>,
27    },
28
29    /// GGUF export error.
30    #[error("GGUF export error: {0}")]
31    GgufExport(String),
32
33    /// Native format export error.
34    #[error("native format export error: {0}")]
35    NativeExport(String),
36
37    /// IO error.
38    #[error("IO error: {0}")]
39    Io(#[from] std::io::Error),
40
41    /// PEFT error.
42    #[error("PEFT error: {0}")]
43    Peft(#[from] peft_rs::PeftError),
44
45    /// Candle error.
46    #[error("candle error: {0}")]
47    Candle(#[from] candle_core::Error),
48}