r/MachineLearning · · 1 min read

Is KV Cache in a high dimensional vector space? [D]

Mirrored from r/MachineLearning for archival readability. Support the source by reading on the original site.

I've been doing some research on this question:

At inference time a large part of a model's working memory lives in the KV cache, plus whatever external memory the harness bolts on. I've been poking at the storage-and-retrieval side of this, treating that cache as an index, and what stands out is that it isn't a flat list. It's a structured set of vectors with a navigable geometry, since the keys carry the model's learned sense of what relates to what.

Because that geometry is navigable, attention over it is really a similarity search: the query scores against the stored keys and blends the matching values. Full attention just runs that search exhaustively, scanning everything on every step.

  • Full attention effectively searches that geometry exhaustively. Every query scores broadly against the available keys and retrieves from the corresponding values.
  • Once you stop treating the KV cache as a flat array and start treating it as a search space, indexing becomes possible.
  • That means you can organize old KV into regions, route a query toward likely regions, and only run local attention over a subset.
  • The interesting part is that relevance is not uniformly distributed. Queries tend to concentrate on relatively small neighborhoods of old context.
  • So the engineering question becomes less “how do I store all of this?” and more “how do I navigate to the right part cheaply?”

I'm new here and don't want to break rules around self promotion or span so not posting any links atm. Would be cool to get other peoples thoughts on this.

submitted by /u/Electrical_Offer5667
[link] [comments]

Discussion (0)

Sign in to join the discussion. Free account, 30 seconds — email code or GitHub.

Sign in →

No comments yet. Sign in and be the first to say something.

More from r/MachineLearning