I first came across TurboQuant during an Artificial Intelligence class. The professor mentioned the recent decline in memory pricing and how compression techniques are becoming more important. That led me to look into how quantization is actually implemented in modern systems.

ref: https://research.google/blog/turboquant-redefining-ai-efficiency-with-extreme-compression/
Vector Quantization
Vector quantization is a classical compression method that maps continuous vectors into a finite set of centroids. This serves two main purposes:
- It improves vector search by enabling faster similarity lookup
- It reduces the size of the key-value cache, which is a major bottleneck in large language models
However, traditional vector quantization introduces a limitation.
It requires storing quantization constants for each block of data, which creates additional memory overhead. To better understand this, I first implemented a simple version of vector quantization.
TurboQuant
TurboQuant is a compression algorithm designed to reduce memory usage while preserving accuracy.
It addresses the memory overhead issue in traditional quantization. It combines two key components:
- PolarQuant for primary compression
- QJL for residual error correction
How TurboQuant works
TurboQuant operates in two stages.
- High-quality compression (PolarQuant)
The input vectors are randomly rotated. This simplifies the geometry of the data and allows efficient quantization.
PolarQuant converts vectors from Cartesian coordinates into polar form, separating magnitude and direction.
Because the data is concentrated in stable angular patterns, it avoids repeated normalization and reduces overhead. - Residual error correction (QJL)
After the first stage, there is a small remaining error between the original and compressed vectors.
TurboQuant applies QJL to this residual.
QJL uses the Johnson-Lindenstrauss Transform and stores only the sign of projected values using 1-bit representation.
This allows the model to correct bias while adding almost no memory cost. In summary, TurboQuant compresses vectors while preserving dot product accuracy.
Experimental Setup
To understand the difference between traditional vector quantization and TurboQuant, I conducted a simple experiment. The goal was not reconstruction quality, but similarity preservation. Key metrics:
- Reconstruction Error
- Inner Product Error
- Recall@K
Code
import torch
# simulate KV cache vectors
d = 128
n = 1000
vectors = torch.randn(n, d)
# random query
query = torch.randn(1, d)
# ground truth attention
true_scores = query @ vectors.T
Traditional Vector Quantization
# simple VQ (nearest centroid)
k = 256
codebook = torch.randn(k, d)
distances = (
(vectors**2).sum(dim=1, keepdim=True)
+ (codebook**2).sum(dim=1)
- 2 * vectors @ codebook.T
)
indices = torch.argmin(distances, dim=1)
vq_vectors = codebook[indices]
vq_scores = query @ vq_vectors.T
TurboQuant (https://github.com/tonbistudio/turboquant-pytorch)
from turboquant import TurboQuantProd
tq = TurboQuantProd(bits=3, dim=d)
compressed = tq.compress(vectors)
tq_scores = tq.inner_product(query, compressed)
Results
- Recall
Recall@10 / @50<br/>
Traditional VQ: 0% / 4%<br/>
TurboQuant: 40% / 36%
Traditional vector quantization fails to retrieve relevant vectors. TurboQuant preserves a significant portion of top-ranked results.
- Inner Product Error
IP error (avg)<br/>
VQ: 10.41<br/>
TurboQuant: 9.86
Both methods introduce distortion. TurboQuant preserves similarity better, resulting in more accurate attention scores.
- Reconstruction Error
Reconstruction error<br/>
VQ: 13.62<br/>
TurboQuant: 10.21<br/>
Although TurboQuant shows lower error in this experiment, reconstruction is not its primary objective.
Traditional methods aim to reconstruct vectors. TurboQuant focuses on preserving inner products.
Traditional VQ vs TurboQuant
Traditional Vector Quantization
Goal: reconstruct vectors
z ≈ z_q
- Optimizes value accuracy
- Does not guarantee correct ranking
TurboQuant
Goal: preserve inner product
q · k ≈ q · k_quantized
- Optimizes attention accuracy
- Preserves ranking of important vectors
=> In transformer models: Attention = softmax(Q · K)
The model depends on relative similarity, not exact vector values. This explains why TurboQuant works well even with aggressive compression.
Bit-width Trade-off
| bits | IP error | Recall@10 |
|---|---|---|
| 1 | 10.29 | 30% |
| 3 | 9.86 | 40% |
| 8 | 8.06 | 50% |
Increasing bit-width improves similarity preservation and retrieval quality.
TurboQuant Experiment Results (in Paper)
- long-context benchmarks TurboQuant performs strongly across LongBench, Needle-in-a-Haystack, ZeroSCROLLS, RULER, and L-Eval.
- ultra-low-bit compression with minimal loss It compresses KV cache down to 3 bits while maintaining near-lossless accuracy and reducing memory by over 6×.
- attention computation speedup 4-bit TurboQuant achieves up to 8× speedup compared to 32-bit baselines.
- high-dimensional vector search performance It outperforms methods such as Product Quantization and RabbiQ in recall without requiring large codebooks or tuning.
TurboQuant does not aim to reconstruct vectors. It preserves what matters for the model: similarity.
Traditional vector quantization preserves values. TurboQuant preserves meaning.