A quantization strategy that can create a VarBuilder with appropriate dequantization and estimate in-memory VRAM from on-disk size. Implementations: `NoQuantization`, `Fp8Quantization`, `GptqQuantization`.
| 30 | /// |
| 31 | /// Implementations: `NoQuantization`, `Fp8Quantization`, `GptqQuantization`. |
| 32 | pub trait Quantization: Send + Sync { |
| 33 | /// Human-readable name for logging. |
| 34 | fn name(&self) -> &str; |
| 35 | |
| 36 | /// Create a VarBuilder from safetensors files with this quantization. |
| 37 | /// |
| 38 | /// # Safety |
| 39 | /// Inherits the mmap safety requirements from candle's safetensors loading. |
| 40 | unsafe fn load_var_builder<'a>( |
| 41 | &self, |
| 42 | filenames: &[PathBuf], |
| 43 | dtype: DType, |
| 44 | device: &Device, |
| 45 | ) -> Result<VarBuilder<'a>>; |
| 46 | |
| 47 | /// Returns the GPTQ group size if this is GPTQ quantization, None otherwise. |
| 48 | fn gptq_group_size(&self) -> Option<usize> { |
| 49 | None |
| 50 | } |
| 51 | |
| 52 | /// Estimate in-memory layer size given on-disk size and target dtype bytes. |
| 53 | /// Default: no expansion (on-disk size = in-memory size). |
| 54 | fn estimate_layer_vram(&self, on_disk_bytes: u64, _dtype_bytes: u64) -> u64 { |
| 55 | on_disk_bytes |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | /// No quantization — plain safetensors, loaded as-is. |
| 60 | pub struct NoQuantization; |
nothing calls this directly
no outgoing calls
no test coverage detected