Reproduce “KVMem: Virtualizing Million-Token Agent Workspaces on a Consumer GPU” on OpenResearch

Run Claude Code, Codex or any coding agent as a research agent: literature, hypotheses and experiments on your laptop, cluster or cloud GPUs.

Universal app for Apple silicon and Intel. Requires macOS 11 or later.

About this paper

Di Chai, Leye Wang, Zeshen Su, Zhiguo Xia, Zhihang Yu

KVMEM virtualizes agent workspaces for large language models, managing Key-Value (KV) state across GPU, host memory, and NVMe storage to enable access to million-token histories on consumer-grade GPUs. This method achieved up to 12.5 times larger addressable workspaces and reduced pre-answer latency by 11.4–53.8× compared to text-based retrieval approaches.

Key insights

  • Agent activity and attention patterns primarily shift at step boundaries, making step-level scheduling an effective strategy for updating the active KV working set.
  • Position-independent Mean-K representations of KV blocks enable scalable, model-native retrieval of relevant history from vast workspaces without scanning full KV tensors.
  • Virtualizing KV context across memory tiers, akin to virtual memory, allows for high-fidelity access to millions of tokens of history without the repeated prefilling overhead or information loss of text-centric methods.

Summary by alphaXiv.

Tip: change arxiv.org to autoarxiv.org in any arXiv abstract link to open the paper here.