Skip to main content

oxillama_gpu/
error.rs

1//! Error types for the GPU compute backend.
2
3use thiserror::Error;
4
5/// Errors that can occur in the GPU compute backend.
6#[derive(Debug, Error)]
7pub enum GpuError {
8    /// No GPU adapter was found (headless CI, no GPU hardware, etc.).
9    #[error("No GPU adapter available")]
10    NoAdapter,
11
12    /// The GPU device request failed.
13    #[error("GPU device request failed: {0}")]
14    DeviceRequest(String),
15
16    /// A buffer's actual size did not match the expected size.
17    #[error("Buffer size mismatch: expected {expected}, got {got}")]
18    BufferSize { expected: usize, got: usize },
19
20    /// The requested quantization type has no GPU kernel implementation.
21    #[error("Unsupported quant type for GPU: {name}")]
22    UnsupportedType { name: String },
23
24    /// Shader compilation or pipeline creation failed.
25    #[error("Shader compilation failed: {detail}")]
26    ShaderCompilation { detail: String },
27
28    /// A GPU readback or mapping operation failed.
29    #[error("GPU buffer mapping failed: {detail}")]
30    BufferMap { detail: String },
31}
32
33/// Convenience `Result` alias for GPU operations.
34pub type GpuResult<T> = Result<T, GpuError>;