mistralrs_quant/dummy/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use candle_core::Result;

use crate::{QuantMethod, QuantizedSerde};

#[derive(Debug)]
pub struct DummyLayer;

impl QuantMethod for DummyLayer {
    fn new(_method: crate::QuantMethodConfig) -> candle_core::Result<Self>
    where
        Self: Sized,
    {
        Ok(Self)
    }
    fn dequantize_w(&self) -> Result<candle_core::Tensor> {
        candle_core::bail!("DummyLayer cannot be dequantized!")
    }
    fn add_delta_w(
        &self,
        _delta: &candle_core::Tensor,
    ) -> candle_core::Result<std::sync::Arc<dyn QuantMethod>> {
        candle_core::bail!("DummyLayer should not ever be present in forward pass!")
    }
    fn apply_isq(
        self: std::sync::Arc<Self>,
        _dtype: Option<crate::IsqType>,
        _device: candle_core::Device,
        _n_quantized: &std::sync::atomic::AtomicUsize,
        _imatrix_weight: Option<Vec<f32>>,
    ) -> candle_core::Result<std::sync::Arc<dyn QuantMethod>> {
        candle_core::bail!("DummyLayer should not ever be present in forward pass!")
    }
    fn dtype_and_device(&self) -> (candle_core::DType, candle_core::Device) {
        (candle_core::DType::F64, candle_core::Device::Cpu)
    }
    fn forward(&self, _a: &candle_core::Tensor) -> candle_core::Result<candle_core::Tensor> {
        candle_core::bail!("DummyLayer should not ever be present in forward pass!")
    }
    fn get_max_isq_cpu_threads(&self, _dtype: crate::IsqType) -> Option<std::num::NonZeroUsize> {
        None
    }
    fn quantized_act_type(&self) -> Option<candle_core::DType> {
        None
    }
}

impl QuantizedSerde for DummyLayer {
    fn name(&self) -> &'static str {
        "dummy"
    }
}