Born注意力是线性的:基于量子测量的精确亚二次注意力与常量状态推理
Born Attention is Linear: Exact Sub-Quadratic Attention and Constant-State Inference from Quantum Measurement
AI总结:
该研究提出基于量子测量的Born注意力,实现亚二次复杂度与常量状态推理,在PG-19数据集上128k上下文下比Softmax更优,且速度优于FlashAttention-2。
摘要:
Softmax注意力因指数核无有限特征图,在序列长度上的计算成本为O(T²),因此线性时间变体对其进行近似。我们发现,Born规则注意力是一种精确的有限核,其权重为量子测量概率|<Q_k,K_j>|²(针对复数查询与键),具有秩一密度矩阵特征图ρₓ = x x†,因为|<Q_k,K_j>|² = tr(ρ_Q ρ_K)。作为多项式核线性注意力的复数二次情况,它允许精确的O(T d²)因果循环和与T无关的常量状态解码,且能精确保留旋转位置。在A100上,常量状态解码每层使用6.4 MB内存,在任意长度下每token耗时0.12 ms,而FlashAttention-2在1M token时每token耗时2.26 ms,缓存为3.2 GB;融合预填充在16k至32k token之间超过FlashAttention-2(在128k token时快4倍)。该算子是否匹配Softmax是一个独立的建模问题,本文在小规模上给出了答案:将其接入实值GPT时,在1k上下文下比Softmax差0.12 nat,在16k上下文下差0.77 nat(注意力稀释,可通过衰减精确保留在状态中修复),而在全复数残差流中,其在1k上下文下与Softmax匹配;门控线性注意力优于两者。在PG-19的128k上下文下,带固定衰减的Born比Softmax好0.32 nat,且与门控线性注意力相差0.04,而门控线性注意力快1.8倍。在PG-19测试集上以5M字节窗口进行常量状态流式处理时,4M复数参数的字节模型得分分别为1.66(带衰减的Born)和1.70(门控)比特每字节,而专为该窗口构建的350M参数分层模型得分为2.45。
英文摘要:
Softmax attention costs O(T^2) in sequence length because the exponential kernel has no finite feature map, so linear-time variants approximate it. We observe that Born-rule attention, whose weights are quantum-measurement probabilities |<Q_k,K_j>|^2 over complex queries and keys, is an exact finite kernel with the rank-one density-matrix feature map rho_x = x x^dagger, since |<Q_k,K_j>|^2 = tr(rho_Q rho_K). As the complex degree-two case of polynomial-kernel linear attention, it admits an exact O(T d^2) causal recurrence and constant-state decoding, independent of T, and keeps rotary positions exactly. On an A100, constant-state decoding uses 6.4 MB per layer at 0.12 ms per token at any length, against a 3.2 GB FlashAttention-2 cache at 2.26 ms per token at 1M tokens; a fused prefill overtakes FlashAttention-2 between 16k and 32k tokens (4x at 128k). Whether the operator matches softmax is a separate modeling question, answered here at small scale: bolted into a real-valued GPT it trails softmax by 0.12 nats at 1k context and 0.77 at 16k (attention dilution, which a decay kept exactly in the state repairs), while inside a fully complex residual stream it matches softmax at 1k; gated linear attention beats both. At 128k context on PG-19, Born with a fixed decay is 0.32 nats ahead of softmax and within 0.04 of gated linear attention, which is 1.8x faster. Streamed in constant state over the PG-19 test set in 5M-byte windows, 4M-complex-parameter byte models score 1.66 (Born with decay) and 1.70 (gated) bits per byte, where a 350M-parameter hierarchical model built for that window reports 2.45.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。