mistralrs_quant/dummy/
mod.rs

1use candle_core::Result;
2
3use crate::{QuantMethod, QuantizeOntoGuard, QuantizedSerde};
4
5#[derive(Debug, Copy, Clone)]
6pub struct DummyLayer;
7
8impl QuantMethod for DummyLayer {
9    fn new(_method: crate::QuantMethodConfig) -> candle_core::Result<Self>
10    where
11        Self: Sized,
12    {
13        Ok(Self)
14    }
15    fn dequantize_w(&self) -> Result<candle_core::Tensor> {
16        candle_core::bail!("DummyLayer cannot be dequantized!")
17    }
18    fn add_delta_w(
19        &self,
20        _delta: &candle_core::Tensor,
21    ) -> candle_core::Result<std::sync::Arc<dyn QuantMethod>> {
22        candle_core::bail!("DummyLayer should not ever be present in forward pass!")
23    }
24    fn apply_isq(
25        self: std::sync::Arc<Self>,
26        _dtype: Option<crate::IsqType>,
27        _device: candle_core::Device,
28        _n_quantized: &std::sync::atomic::AtomicUsize,
29        _imatrix_weight: Option<Vec<f32>>,
30        _guard: QuantizeOntoGuard,
31    ) -> candle_core::Result<std::sync::Arc<dyn QuantMethod>> {
32        // This is necessary for the immediate ISQ
33        Ok(self)
34    }
35    fn dtype_and_device(&self) -> (candle_core::DType, candle_core::Device) {
36        (candle_core::DType::F32, candle_core::Device::Cpu)
37    }
38    fn forward(&self, _a: &candle_core::Tensor) -> candle_core::Result<candle_core::Tensor> {
39        candle_core::bail!("DummyLayer should not ever be present in forward pass!")
40    }
41    fn quantized_act_type(&self) -> Option<candle_core::DType> {
42        None
43    }
44}
45
46impl QuantizedSerde for DummyLayer {
47    fn name(&self) -> &'static str {
48        "dummy"
49    }
50}