Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Google Research 7 min read Research hardMaster

TurboQuant: Redefining AI efficiency with extreme compression

TurboQuant is a data-oblivious vector quantization algorithm that removes the per-block quantization-constant overhead of traditional methods by combining PolarQuant (random rotation plus recursive polar-coordinate transforms with a fixed angle grid) and a 1-bit Quantized Johnson-Lindenstrauss residual stage that removes bias in inner-product estimates. On long-context benchmarks with Gemma, Mistral and Llama-3.1-8B, it quantizes the KV cache to 3 bits with no training and no measured accuracy loss, cutting KV memory by at least 6x. 4-bit TurboQuant computes attention logits up to 8x faster than 32-bit keys on H100s. For vector search it beats PQ and RabbiQ on 1@k recall on GloVe without large codebooks or dataset-specific tuning, and the methods come with proofs of near-optimal distortion.

Related posts

  • Unlocking Longer Generation with Key-Value Cache Quantization

    Hugging Face mediumAdept

    Hugging Face Transformers adds KV cache quantization, inspired by the KIVI paper, that stores keys and values per-token in int2/int4/int8 via quanto or HQQ backends. A residual cache of the most recent tokens (128 by default) stays in full precision to avoid re-quantizing on every step and to preserve accuracy. On Llama-2-7B, int4 matches fp16 on PG-19 perplexity and LongBench, while int2 degrades noticeably. Int4 gives roughly 2.5x memory savings and, with FlashAttention on an 80GB A100, raises max context from 40k to 128k tokens, at the cost of slower generation at larger batch sizes and about 3x slowdown when combined with weight quantization.

  • Making LLMs lighter with AutoGPTQ and transformers

    Hugging Face mediumAdept

    AutoGPTQ is now integrated into Hugging Face Transformers (via Optimum), letting users quantize and run LLMs at 8, 4, 3 or 2 bits with the GPTQ post-training method. GPTQ needs a calibration dataset and quantizes only the weights: int4 weights are dequantized on the fly in a fused kernel while compute stays in fp16. That gives nearly 4x memory savings with negligible accuracy loss at 4-bit. On an A100 at batch size 1, Llama-2-7B with the exllama kernel dropped peak memory from about 29 GB to 10.5 GB with slightly better per-token latency than fp16. Text-Generation-Inference can now serve a 70B model on a single 80GB GPU and PEFT adapters can be fine-tuned on top, but the kernels slow down at larger batch sizes and W4A8 or Triton kernels remain open work.

  • Quantization-Aware Healing: a compressed, 4-bit model that outperforms its full-precision original

    Hugging Face hardMaster

    Quantization-Aware Healing (QAH) recovers structurally compressed, 4-bit LLMs by distilling directly from the original pre-compression model via KL divergence on logits, rather than from the recovered bfloat16 checkpoint or with a task loss as in QAT. Applied to GPT-OSS 120B pruned to 60B and quantized to MXFP4, the 4-bit model beats its own bfloat16 checkpoint on 7 of 9 benchmarks, with the largest gains on AA-LCR (+7.4) and AIME 2025 (+5.6). In a matched comparison on a 9B model, QAH reaches a peak similar to QAT about 7x faster (100 vs 700 steps) and stays stable, while QAT drops nearly 19 points with continued training. A commenter notes the headline comparison lacks a control that gives the bf16 model the same extra distillation pass, and that the teacher itself is MXFP4.

  • Mastering Long Contexts in LLMs with KVPress

    Hugging Face mediumAdept

    KV cache memory grows linearly with context length: Llama 3-70B at 1M tokens in bfloat16 needs about 330GB of KV cache, roughly 70% of total memory. NVIDIA's KVPress is a Python toolkit of "presses" that prune low-importance KV pairs during prefill via forward hooks on attention layers. Examples include KnormPress, SnapKVPress and ExpectedAttentionPress, each tuned with a compression_ratio and usable through a custom transformers pipeline. On Llama 3.1 8B at 128k context, 50% compression cuts peak memory from 45GB to 37GB and raises decoding from 11 to 17 tokens/s on an A100, while RULER benchmarks show accuracy dropping as compression rises.

  • Making LLMs even more accessible with bitsandbytes, 4-bit quantization and QLoRA

    Hugging Face mediumAdept

    bitsandbytes now integrates 4-bit quantization into Hugging Face transformers, letting most accelerate-loadable models (text, vision, multimodal) run in 4-bit and be fine-tuned via QLoRA, which backpropagates through a frozen 4-bit base model into LoRA adapters. QLoRA stores weights in NF4 and dequantizes to bfloat16 for compute, adds double quantization (saving ~0.4 bits per parameter) and paged optimizers, and matches 16-bit fine-tuning while fitting a 33B model on a 24GB GPU or 65B on a 48GB GPU. The post explains FP8/FP4 bit layouts and shows BitsAndBytesConfig usage. Recommended defaults are NF4 for precision, double quant for memory pressure, and a 16-bit compute dtype for speed.

The quest for software engineering knowledge.

Look:
Layout: