MCPcopy Create free account
hub / github.com/evilsocket/cake / Quantization

Interface Quantization

cake-core/src/utils/mod.rs:32–57  ·  view source on GitHub ↗

A quantization strategy that can create a VarBuilder with appropriate dequantization and estimate in-memory VRAM from on-disk size. Implementations: `NoQuantization`, `Fp8Quantization`, `GptqQuantization`.

Source from the content-addressed store, hash-verified

30///
31/// Implementations: `NoQuantization`, `Fp8Quantization`, `GptqQuantization`.
32pub 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.
60pub struct NoQuantization;

Callers

nothing calls this directly

Implementers 1

mod.rscake-core/src/utils/mod.rs

Calls

no outgoing calls

Tested by

no test coverage detected