Direct access attention: associative recall at a fraction of the compute of softmax, linear attention and state-space models
Abstract
Direct access attention replaces context search with a learned integer lookup. Each token is projected to a -dimensional code whose signs select one of memory cells. Its value is written to that cell; a query with matching signs retrieves it in operations per head, independent of context length . Softmax attention compares each query with every context key, costing operations per head and separating pairs. Linear attention superposes pairs in a fixed-width matrix, costing operations, independent of , but separating only pairs per head. Direct access replaces the product of key and value widths with their sum and provides cells, at the cost of storing values per head. An efficient differentiable training algorithm factorises address learning into independent bit probabilities. This lets gradients adjust addresses; at inference, each bit becomes a definite binary choice, enabling integer lookup. Training and inference agree when these probabilities approach zero or one. Because cross-entropy alone does not reliably produce such certainty, we add an address-entropy penalty after the model has learned to match queries to the correct keys. On in-context associative recall, one-layer models with matched parameter counts achieve perfect accuracy at every tested task size, from 8 to 512 stored pairs, using either direct access or softmax attention. At 512 pairs, linear attention achieves 0.340 accuracy; a selective state-space model with the same state size performs at chance beyond 32 pairs. Direct access preserves softmax's accuracy while reducing attention-route decoding cost by three orders of magnitude.
Create a lesson
Metadata
- Comments
- 21 pages
Related papers
Joint KV-Cache and Recurrent-State Quantization in Hybrid Linear-Attention LLMs
Shared title terminologycs.LGMinseok Shin
Append-Observational Geometry and Nonlinear Widths of Softmax Attention States
Shared title terminologycs.LGJun He, Deying Yu
Linear Attention Has Superlinear Capacity
Shared title terminologycs.LGHao Guo, Sudhaunshu Hardikar, Simon Dennis et al.
Multi-Signal Internal-State Online Quality Monitoring for LLM Serving
Shared title terminologycs.LGYibo Zhao, Nengneng Yu, Sixian Xiong et al.
TorchTangents: An Accessible Bridge for Architecture-Preconditioned Optimizers
Shared title terminologycs.LGJoshua DeOliveira, Elke Rundensteiner
MLP Cache: A Post-Hoc Memory-Compute Trade-off for Transformer Inference
Shared title terminologycs.LGHuzheng Yang, Yiqiao Huang, Qingqiao Hu et al.