
Double quantization of the scale constants (Kamath Ch 4)
Source:R/kamath_llm2_native.R
morie_kamath_double_quantization.Rdint8 codes for the block scales plus one shared fp32 constant. Rounding is banker's rounding in both languages.
Examples
V <- c(1, 2, 3, 4, 5, 6, 7, 8)
morie_kamath_double_quantization(V)
#> $estimate
#> [1] 0.03149606
#>
#> $scales_int8
#> [1] 16 32 48 64 79 95 111 127
#>
#> $shared_const
#> [1] 0.06299213
#>
#> $dequantized
#> [1] 1.007874 2.015748 3.023622 4.031496 4.976378 5.984252 6.992126 8.000000
#>
#> $max_abs_error
#> [1] 0.03149606
#>
#> $bits_saved_per_block
#> [1] 24
#>
#> $n
#> [1] 8
#>
#> $method
#> [1] "double quantization of the scale constants (Kamath Ch 4)"
#>