OCTOPUS: Optimized KV Cache for Transformers via Octahedral Parametrization Under optimal Squared error quantization
Abstract
The key-value (KV) cache dominates memory bandwidth and footprint in long-context autoregressive inference. Recent rotation-preconditioned codecs (TurboQuant, PolarQuant) show that a structured random rotation followed by a per-coordinate scalar quantizer matched to an analytically tractable marginal is a near-optimal recipe for KV compression. OCTOPUS advances this paradigm through joint quantization of rotated coordinate triplets. Each triplet's direction is mapped to a square via an octahedral parameterization, and the two resulting coordinates and the triplet norm are Lloyd-Max quantized against implementation-matched marginals. Optimizing the per-triplet squared error gives a strictly non-uniform bit allocation independent of the total dimensionality of the keys, reducing MSE over balanced scalar Lloyd-Max for every model family we test. The codec is data-oblivious, online, and deterministic given a seed. Across text, video, and audio, OCTOPUS matches or beats every prior rotation codec at all but a few operating points, with a lead that grows with more extreme compression. Furthermore, a fused Triton implementation reconstructs keys on the fly without materializing the uncompressed key, with a small constant per-step overhead over scalar dequantization. End-to-end decode on Qwen2.5-7B is 1.11 to 1.16 times faster than TurboQuant-MSE at matched bit width. Code and project page: https://octopus-quant.github.io/