Skip to main content

Module turboquant

Module turboquant 

Source
Expand description

Walsh–Hadamard transform helpers for TurboQuant-style KV compression.

Host FWHT + group quant; Metal FERROX_CTK=turbo4 stores the 4-bit groups (WHT optional on host upload). turbo8 aliases ggml Q8_0 on Metal. Algorithm follows the public TurboQuant line (randomized Hadamard + per-group scale).

In-place FWHT on x of length n = 2^k. Output is unnormalized (each butterfly is a+b, a-b); callers that need orthonormal Hadamard divide by sqrt(n).

Functions§

dequantize_turbo4_groups
Inverse of quantize_turbo4_groups (ignores WHT; dequant only).
fwht_inplace
In-place Fast Walsh–Hadamard Transform. x.len() must be a power of two.
fwht_orthonormal_inplace
Orthonormal FWHT: fwht_inplace then scale by 1/sqrt(n).
quantize_turbo4_groups
Per-group absmax quantize after optional WHT (turbo4-style sketch).