Detect quantization strategy from a model's config.json.
(config_path: &Path)
| 126 | |
| 127 | /// Detect quantization strategy from a model's config.json. |
| 128 | pub fn detect_quantization(config_path: &Path) -> Box<dyn Quantization> { |
| 129 | if fp8::is_fp8_quantized(config_path) { |
| 130 | log::info!("model uses FP8 quantization — weights will be dequantized at load time"); |
| 131 | Box::new(Fp8Quantization) |
| 132 | } else if gptq::is_gptq_quantized(config_path) { |
| 133 | let gs = gptq::gptq_group_size(config_path); |
| 134 | log::info!("model uses GPTQ quantization (group_size={gs}) — weights will be dequantized at load time"); |
| 135 | Box::new(GptqQuantization { group_size: gs }) |
| 136 | } else { |
| 137 | Box::new(NoQuantization) |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | // ─── End quantization trait ────────────────────────────────────────────────── |
| 142 |