attend op• 数据种类:tokens × tokens × tokens → tokens
• 调用: import fullseye as fs; fs.ledger.attention_linear(query, key, value, causal: 'bool' = False) -> 'np.ndarray'(要直接调用实现,import llmcore; llmcore.attention_linear(query, key, value, causal: 'bool' = False) -> 'np.ndarray';从台账取用则 opsllmcore.get("attention_linear"))
去掉 softmax 的注意力 → tokens。(QKᵀ)V == Q(KᵀV)——正是结合律本身。
Katharopoulos 等 2020。去掉 softmax 后可以使用矩阵乘法的结合律,不构造 (T, T), 只需 (d, dv) 的状态即可。是同一个数的另一种加括号方式,所以答案一致(相对差 7.1e-16), 计算量从 O(T²d) 变为 O(Td²) —— 交叉点在 T == d(实测: T=d=64 时比为 0.9, T=1024 时为 14.6 倍)。★即使 T 取 2048,比也在 14.4 饱和。达不到公式所说的 32 倍 —— 因为二次的一侧进入了带宽瓶颈。
Args:
query: (T, d) float。
key: (S, d) float。
value: (S, dv) float。causal=True 时 S == T。
causal: 为 True 时用累积状态只加"自己之前的部分"(顺序 1 遍,线性时间)。
Returns:
tokens (T, dv) float: 没有经过 softmax,所以不是行和为 1 的凸组合。
不是 attention_softmax 的替代,而是另一种注意力。
• 示例数据目录(下载 URL / 许可证) —— 2-D 用 skimage.data(BSD/公有领域)加合成图,3-D 给出真实数据源(Stanford/PDS 等)的下载 URL。
• 算子来历与参考文献 —— 该算子族所依据的研究/方法出处。
• 算法的正典(作者、年份)与用途见上面的族使用指南。
• poc_attention_identities — py -3.11 examples/poc_attention_identities.py
tokens 作为输入)rms_norm · rope_rotate · attention_scores · attention_apply · attention_softmax · attention_tiled · attention_grouped · kv_cache_decode
attend)attention_softmax · attention_tiled · attention_grouped
*Provenance: llmcore.py — LLMCORE 算子登记表。本条目由 tools/opdocs.py md 自动生成(请勿手工编辑)。*
© 2026 Kazufumi Furuse — Fullseye operator documentation. Licensed under Apache-2.0.