← Latest papers
💻 computer science

Tamarin (HSQ): Reversible Hierarchical KV-Cache Compression for LLM Inference

Tamarin (HSQ) introduces a reversible, three-tier hierarchical KV-cache compression scheme that routes tokens into a focal tier, learned summary vectors, and a CPU-based archive to achieve 12–28× GPU memory reduction for long-context LLM inference while maintaining near-baseline perplexity and retrieval accuracy.

Original authors: Alikhan Bazakov, Kirill Kiselev

Published 2026-07-10
📖 5 min read🧠 Deep dive

Original authors: Alikhan Bazakov, Kirill Kiselev

Original paper licensed under CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you are trying to read a massive, 32,000-page book on a tiny tablet. The problem isn't the book's text; it's that your tablet's memory fills up instantly just by holding the pages you've already read. In the world of AI, this "memory" is called the KV cache, and for big models, it eats up all your computer's power, forcing you to throw away old pages to make room for new ones.

Most current solutions are like a librarian who, when the shelf gets full, decides to toss out the books they think you won't need. They might keep the first few pages and the last few, but if you suddenly ask a question about a detail in the middle of the book, that page is gone forever. The paper calls this "eviction," and it argues that this is a fatal flaw because you can't predict what a user will ask next.

The Big Idea: The Magic Index, Not the Trash Can

The authors of this paper, from Siamang Labs, propose a different approach called Tamarin (technically known as HSQ). Instead of throwing pages away, they treat the memory like a giant, searchable index.

Here is how their three-tier system works, using a library analogy:

  1. The "VIP" Shelf (L1): A small, high-speed section on your tablet (GPU) holds the most important pages and the very latest ones. These are kept in full detail, just shrunk down a bit (4-bit precision).
  2. The "Clue Cards" (L2): For the rest of the book, the system creates tiny, 3-bit "clue cards" for every group of 8 to 16 pages. These cards don't contain the story; they just contain a summary of what the pages are about. They live on your tablet too.
  3. The "Deep Archive" (L3): The full, original text of every single page is stored in a massive warehouse across the street (CPU RAM), also shrunk down to 4-bit precision.

How It Works in Real Time

When the AI is reading and suddenly needs to answer a question, it doesn't guess. It looks at the Clue Cards (L2) first. A smart, tiny "reader" AI scores these cards to see which groups of pages are relevant to the current question.

If a card looks promising, the system instantly runs to the Deep Archive (L3), grabs the original pages, and brings them back to the tablet just before the AI makes its decision.

The paper proves that this "indexing" approach is the key. In a test where they disabled the "fetch from archive" step, the system's ability to find hidden information (called "needle-in-a-haystack" retrieval) dropped to 0%. This confirms that the clue cards are just for routing; the real content lives in the archive.

The Results: Massive Savings with Almost No Cost

The paper measured this on several models (specifically the Qwen3 family, ranging from 0.6 billion to 14 billion parameters). Here is what they found:

  • Memory Savings: At a context length of 32,000 tokens, Tamarin shrinks the GPU memory usage by 12 to 28 times. For example, a model that usually needs 4.5 GiB of memory for the cache at 32K tokens only needs about 172 MiB on the GPU. The rest lives in the CPU RAM.
  • Quality: For larger models (4B and 8B parameters), the quality is almost identical to the uncompressed version. The "perplexity" (a measure of how confused the AI gets) only goes up by 0.1% to 0.4%. The AI agrees with the original version on 96% to 97% of the words it chooses.
  • Retrieval: In tests with 500 attempts to find a hidden code at different depths in the text, the 8B model found the code 500 out of 500 times, statistically matching the uncompressed baseline.

What the Paper Rules Out and Where It Fails

The authors are very clear about what this is not and where it struggles:

  • It is not a speed boost: The paper explicitly states that Tamarin does not make the AI faster. In fact, because it has to fetch data from the CPU archive, the speed at 32K tokens drops to about 17–18% of the normal speed. The trade-off is capacity (fitting more text) for speed.
  • It doesn't work perfectly on tiny models: For the smallest model tested (0.6B parameters), the quality cost is higher. The paper notes a 6–10% increase in perplexity when using 4-bit weights, which is considered a failure for that specific size.
  • It's not a magic fix for all AI families: The method works great on Qwen3 models, but when they tried it on a different family (Mistral-7B), the results were messy, with a 20 percentage point drop in accuracy at certain depths. The authors suspect this is because Mistral lacks a specific "normalization" step that Qwen has, making the "clue cards" harder to read.
  • One specific "fragile" checkpoint: Even on the 14B model, there were two specific spots in the text where the system struggled to find the hidden needle, dropping to 80.4% accuracy. The paper attributes this to a specific flaw in that model's training, not the method itself.

The Bottom Line

The paper suggests that for large models (4B and up), Tamarin is a proven way to fit massive amounts of text into limited memory without permanently deleting information. It turns the problem of "running out of space" into a problem of "managing an index." While it slows things down and requires careful tuning for different types of AI, it successfully solves the memory bottleneck for long-context tasks where keeping every single piece of information is critical.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →