缺失的记忆层次:为LLM上下文窗口的需求分页
The Missing Memory Hierarchy: Demand Paging for LLM Context Windows
AI总结:
Pichay通过需求分页技术减少LLM上下文消耗,提升内存使用效率。
摘要:
大型语言模型的上下文窗口并不是内存。它其实是L1缓存:一种小、快、贵的资源,该领域将其视为整个内存系统。没有L2,没有虚拟内存,没有分页。每一个工具定义、每一个系统提示、每一个过时的工具结果都会占用上下文,直到会话结束。结果是可以衡量的:在857个生产会话和445万个有效输入令牌中,21.8%是结构性浪费。\n我们提出了Pichay,一个为LLM上下文窗口的需求分页系统。它作为客户端和推理API之间的透明代理实现,拦截消息流以驱逐过时内容,检测当模型重新请求驱逐材料时的页面故障,并固定由故障历史确定的工作集页面。在140万个模拟驱逐的离线回放中,故障率是0.0254%。在681次活生产部署中,该系统将上下文消耗减少了高达93%(5038KB到339KB);在极端持续压力下,系统仍能运行,但会表现出预期的thrashing病理,即反复驱逐内容的页面故障。\n关键观察是,该领域面临的问题,如上下文限制、注意力退化、成本扩展、会话间丢失状态等,都是虚拟内存问题披上了不同的外衣。解决方案存在:工作集理论(Denning,1968)、需求分页、故障驱动的替换策略、以及具有多级驱逐管理的内存层次结构。我们描述了为LLM系统设计的完整内存层次结构(L1到持久存储),报告了已在生产中部署的前三个层次(L1驱逐、L2故障驱动的固定、L3模型驱动的对话压缩),并识别出跨会话内存是剩余的前沿。
英文摘要:
The context window of a large language model is not memory. It is L1 cache: a small, fast, expensive resource that the field treats as the entire memory system. There is no L2, no virtual memory, no paging. Every tool definition, every system prompt, and every stale tool result occupies context for the lifetime of the session. The result is measurable: across 857 production sessions and 4.45 million effective input tokens, 21.8% is structural waste. We present Pichay, a demand paging system for LLM context windows. Implemented as a transparent proxy between client and inference API, Pichay interposes on the message stream to evict stale content, detect page faults when the model re-requests evicted material, and pin working-set pages identified by fault history. In offline replay across 1.4 million simulated evictions, the fault rate is 0.0254%. In live production deployment over 681turns, the system reduces context consumption by up to 93% (5,038KB to 339KB); under extreme sustained pressure, the system remains operational but exhibits the expected thrashing pathology, with repeated fault-in of evicted content. The key observation is that the problems the field faces, such as context limits, attention degradation, cost scaling, lost state across sessions, are virtual memory problems wearing different clothes. The solutions exist: working set theory (Denning, 1968), demand paging, fault-driven replacement policies, and memory hierarchies with multiple eviction-managed levels. We describe the architecture of a full memory hierarchy for LLM systems (L1 through persistent storage), report on the first three levels deployed in production use (L1 eviction, L2 fault-driven pinning, L3 model-initiated conversation compaction), and identify cross-session memory as the remaining frontier.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。