Skip to main content

cubecl_std/quant/
base.rs

1use cubecl_common::quant::scheme::QuantLevel;
2use cubecl_core::prelude::Scalar;
3
4/// Run an arbitrary function with the quantization types from the scheme.
5/// Useful when concrete types aren't available.
6pub trait RunWithQuantType {
7    type Output;
8
9    fn execute<Q: Scalar, S: Scalar>(self) -> Self::Output;
10}
11
12/// Panic for a level these kernels cannot reconstruct.
13///
14/// They apply one scale per value and never consult the level, so a per-tensor scale would be
15/// dropped and every value would come back short by that factor. Levels are matched exhaustively so
16/// a new one has to make a support decision here rather than inherit silence.
17pub fn assert_level_supported(level: QuantLevel) {
18    match level {
19        QuantLevel::Tensor | QuantLevel::Block(_) => {}
20        QuantLevel::BlockTensor { .. } => {
21            panic!("two-level quantization is not supported by these kernels, got {level:?}")
22        }
23    }
24}