arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2605.22884cs.LGcs.AI
收藏

Tensor Cache: 基于驱逐条件的Transformer联想记忆

Tensor Cache: Eviction-conditioned Associative Memory for Transformers

Massachusetts Institute of Technology, Cambridge, MA, USA(麻省理工学院);IBM Research, Cambridge, MA, USA(IBM研究院);University of Toronto, Toronto, Canada(多伦多大学)

Kabir Swain, Sijie Han, Daniel Karl I. Weidele, Mauro Martino, Antonio Torralba

AI总结:

提出Tensor Cache,一种双层缓存结构,将滑动窗口注意力作为L1缓存,将窗口驱逐的KV对压缩为外积快速权重记忆作为L2缓存,通过门控融合和端到端训练,在有限状态基线中提升记忆-质量边界。

摘要:

自回归Transformer的KV缓存随上下文长度线性增长;滑动窗口缓存限制了内存但完全丢弃被驱逐的token,使得窗口外的相关证据变得不可访问。我们引入了\emph{Tensor Cache},一种双层缓存,将滑动窗口softmax注意力作为第一级缓存(L1),与一个固定大小的外积快速权重记忆作为第二级缓存(L2)配对,L2由从窗口中驱逐的KV对提供。最近的token保留在精确的局部注意力中;被驱逐的对被压缩成一个每层矩阵$A$,并通过单个矩阵乘法被未来的查询读取,利用了线性注意力恒等式$q_t(k_i \otimes v_i)=\langle q_t,k_i angle v_i$。一个可学习的标量门融合L1和L2的输出,并且每头的衰减和写入率参数是端到端训练的。外积记忆和读取恒等式是众所周知的;我们的贡献是将其用作仅由滑动窗口驱逐提供的L2缓存,加上识别出常见的分块均值训练捷径$A\!\leftarrow\!λA\!+\!η(ar k\!\otimes\!ar v)$在每个块中静默地引入了$C^2{-}C$个虚假的跨token外积,并通过一个并行的加权和扫描(等价于在float32 epsilon内的每token写入)来弥补这一差距。跨系统规模、受控联想回忆、长上下文语言建模和记忆容量诊断,Tensor Cache在有限状态基线上改善了记忆-质量边界。

英文摘要:

Autoregressive Transformer KV caches grow linearly with context length; sliding-window caching bounds memory but discards evicted tokens entirely, so relevant evidence outside the window becomes inaccessible. We introduce \emph{Tensor Cache}, a two-level cache that pairs sliding-window softmax attention as a first-level cache (L1) with a fixed-size outer-product fast-weight memory as a second-level cache (L2) fed by KV pairs evicted from the window. Recent tokens remain in exact local attention; evicted pairs are compressed into a per-layer matrix $A$ and read by future queries through a single matrix multiplication, exploiting the linear-attention identity $q_t(k_i \otimes v_i)=\langle q_t,k_i\rangle v_i$. A learned scalar gate fuses the L1 and L2 outputs, and per-head decay and write-rate parameters are trained end-to-end. The outer-product memory and the read identity are well-known; our contribution is their use as an L2 cache fed exclusively by sliding-window evictions, plus identifying that the common chunked-mean training shortcut $A\!\leftarrow\!λA\!+\!η(\bar k\!\otimes\!\bar v)$ silently introduces $C^2{-}C$ spurious cross-token outer products per chunk, and closing the gap with a parallel weighted-sum scan equivalent to per-token writes within float32 epsilon. Across systems scaling, controlled associative recall, long-context language modeling, and memory-capacity diagnostics, Tensor Cache improves the memory--quality frontier over bounded-state baselines.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑