Simple linear attention language models balance the recall-throughput tradeoff
Simran AroraSabri EyubogluMichael ZhangAman TimalsinaSilas AlbertiJames ZouAtri RudraChristopher Ré
Simran AroraSabri EyubogluMichael ZhangAman TimalsinaSilas AlbertiJames ZouAtri RudraChristopher Ré
BASED is a hybrid language-model sequence mixer designed to combine long-range memory with precise local token interactions. Its core combines globally applied softmax-approximating Taylor linear attention with causal exact softmax attention restricted to a small sliding window. The models used in the main experiments additionally replace some mixer layers with gated short convolutions: approximately 20% Taylor linear-attention layers, 20% sliding-window-attention layers, and 60% gated-convolution layers. The gated convolutions use filter width 3, SiLU activation, and a projection expansion factor of 4. The main BASED models use no input-dependent decay when trained on 30B or 50B tokens. Varying the Taylor feature dimension and sliding-window width changes the recurrent-state size, allowing BASED to interpolate between low-memory models and high-recall models.
The paper establishes that recall quality is fundamentally constrained by the amount of recurrent state retained during generation. Empirically, on multi-query associative recall, increasing the recurrent state almost always improves accuracy within a given architecture class, while different architectures make substantially different use of the same state budget. Exact softmax attention attains perfect recall but stores a key–value cache whose size grows linearly with sequence length; fixed-state alternatives such as Mamba and H3 use much less memory but have limited recall capacity. In addition, any causal recurrent model with bounded-precision state entries that solves the associative-recall problem on an input of length requires a recurrent state containing at least bits. Thus, the observed memory–recall tradeoff is not merely an artifact of a particular architecture.
For causal inputs, Taylor linear attention replaces the softmax kernel with a feature-map inner product. Let be projected query and key vectors, be a value vector, and be a feature map. The output at position is
The numerator and denominator can be maintained recurrently using a value-weighted state and a key state :
For BASED, the feature map is the second-order Taylor approximation to the exponential kernel. With scaling absorbed into and , it satisfies
which can be implemented as the concatenation of a constant term, first-order coordinates, and second-order pairwise products. If the projected query and key dimension is , the recurrent state size is proportional to , rather than growing with sequence length. The second-order feature map has naive time and space cost when the head dimension and feature dimension are comparable, so BASED uses smaller projected dimensions to control the state size.
BASED uses causal sliding-window attention to provide exact local comparisons and token shifts. For a window width , query attends only to keys , giving time and space for sequence length and head dimension , and a -token key–value cache during generation. Unlike large-window models using widths such as 4096, BASED chooses small widths that are multiples of 16 and generally no larger than 128. GPU tensor cores operate on tiles, but the measured latency of and matrix multiplications is similar because the smaller operation underutilizes the tensor cores; latency begins increasing substantially beyond width 128. The resulting tensor-core-aware window provides fast exact local attention, while the global Taylor linear-attention component supplies long-range interactions. In the reported recall experiment, small-window exact attention recovered 90.8% of full softmax attention's recall accuracy at approximately of its latency.
BASED introduces fused GPU kernels for Taylor linear attention during both prompt processing and recurrent generation. The prefill kernel takes projected tensors for batch size , heads, sequence length , head dimension , and expanded feature dimension . It uses tiles, eight warps per batch–head block, double-buffered query/key/value tiles in SRAM, and running zeroth-, first-, and second-order Taylor states. For each sequence tile, the kernel computes the causal within-tile term through a masked quadratic attention calculation and the preceding-prefix term through multiplication by the accumulated linear-attention state. The first-order state is accumulated across warps in SRAM; the larger second-order state is partitioned across warp registers and combined before writing the output. The kernel optionally writes the final Taylor states for later generation.
During next-token generation, the recurrent kernel loads the current projected query, key, value, and previous state, updates the state with the outer product , and computes the output by multiplying the query by the updated numerator and denominator states. BASED uses eight warps per block and pads the expanded feature dimension to a hardware-friendly multiple; for projected feature dimension 16 and head dimension 64, it uses rather than the unpadded . The state update requires arithmetic and moves bytes from HBM to SRAM per step. The corresponding sliding-window generation kernel uses four warps, fuses query–key multiplication, softmax normalization, and value multiplication in registers, and uses a 64-token window with head dimension 64 in the reported kernel benchmarks.
Relative to the baseline implementation, the fused prefill kernel avoids bytes of HBM-to-SRAM movement for materialized feature maps and avoids bytes of SRAM-to-register movement for repeatedly updating the Taylor state. These reductions come from computing feature maps and causal products inside one kernel and retaining active state fragments in registers.
The paper analyzes BaseConv, a canonical data-independent gated-convolution layer of the form
where is a length- sequence with model dimension , is a learned projection, is a convolution across sequence positions, is elementwise multiplication, and are biases. BaseConv can represent a broad class of architectures built from gating and convolution.
For a vocabulary of size encoded as -bit binary tokens, any data-independent BaseConv model that exactly solves multi-query associative recall requires at least layers. For inputs with vocabulary size and encoding dimension satisfying , where , a data-independent BaseConv model with parameters represented using bits requires layers even for ordinary associative recall. For -hot encodings, the lower bound becomes at least layers when . These bounds are complemented by an -layer BaseConv construction for certain one-hot associative-recall settings. The paper also shows that linear attention with feature dimension can be simulated by BaseConv with layers, an inner dimension scaling as , and width scaling as .
The synthetic evaluation uses Multi-Query Associative Recall (MQAR). An input contains key–value pairs followed by queries; for each query, the model must retrieve the value associated with an earlier matching key. For example, a sequence of pairs such as , , followed by queries , requires the model to output the corresponding values.
Models are trained on sequences of length 256 containing 4–64 key–value pairs and evaluated on sequences of length 1,024 containing 4–256 pairs. The comparison includes softmax attention, sliding-window attention, Mamba, H3, Hyena, and BASED. For every architecture, hyperparameters controlling generation-state size are varied, including model dimension, window width, state dimension, and Taylor feature dimension. State size is measured in bytes during generation; for BASED with model dimension and Taylor feature dimension , the reported state-size expression is
with the additional denominator state accounted for by the term. The language-model experiments pretrain 360M- and 1.3B-parameter models from scratch on the Pile using the GPT-2 BPE tokenizer, identical token order, and 10B–50B training tokens. Evaluation covers overall Pile perplexity, associative-recall and non-recall Pile slices, SWDE and FDA information extraction, SQuAD question answering, common-sense LM-Eval tasks, few-shot SuperGLUE, and DNA modeling.
The main Pile experiments show that BASED matches strong sub-quadratic baselines in perplexity while substantially improving recall-intensive tasks over Mamba. The following selected rows reproduce the reported 1.3B-parameter results; throughput is in tokens/ms, perplexities are lower-is-better, and accuracies or F1 scores are higher-is-better.
| Model and training tokens | Prefill | Generate | Pile all PPL | AR PPL | Other PPL | SWDE Acc. | FDA Acc. | SQuAD F1 | LM-Eval avg. Acc. |
|---|---|---|---|---|---|---|---|---|---|
| Transformer++ 1.33B/10B | 103.50 | 0.99 | 7.26 | 1.74 | 8.10 | 71.92 | 73.23 | 36.19 | 47.64 |
| BASED 1.35B/10B | 161.71 | 24.28 | 7.43 | 1.87 | 8.26 | 48.06 | 24.41 | 30.46 | 46.68 |
| Mamba 1.32B/10B | 112.22 | 25.69 | 7.48 | 1.96 | 8.29 | 34.74 | 12.89 | 28.20 | 46.84 |
| Transformer++ 1.33B/50B | 103.50 | 0.99 | 6.28 | 1.65 | 6.82 | 76.50 | 80.47 | 43.47 | 53.33 |
| BASED 1.35B/50B | 161.71 | 24.28 | 6.30 | 1.71 | 6.82 | 64.45 | 30.40 | 41.62 | 53.81 |
| Mamba 1.32B/50B | 112.22 | 25.69 | 6.28 | 1.74 | 6.78 | 52.75 | 18.51 | 35.92 | 53.50 |
At 1.3B parameters and 50B training tokens, BASED exceeds Mamba by 11.70 SWDE accuracy points, 11.89 FDA accuracy points, and 5.70 SQuAD F1 points, while its LM-Eval average is similar. Averaged over the reported recall-intensive tasks, the paper summarizes the BASED advantage over Mamba as 10.36 accuracy points. BASED remains close to Transformer++ on the associative-recall Pile slice and on SQuAD, although Transformer++ is stronger on the information-extraction tasks.
On a single NVIDIA H100 GPU, with timings averaged over 20 repetitions, the IO-aware BASED implementation improves both prompt processing and recurrent generation. At 1.3B parameters and a 4,096-token prefill, BASED is 56% faster than FlashAttention-2 and 44% faster than Mamba. At 360M parameters, it is 28% faster than FlashAttention-2 and 76% faster than Mamba for the same prefill benchmark.
For recurrent generation of 1,024 tokens at batch size 128, the 1.3B-parameter BASED implementation achieves up to 24 times the throughput of FlashAttention-2 and reaches 95% of Mamba's throughput. At 360M parameters, BASED provides 98% higher throughput than FlashAttention-2 and 118% higher throughput than Mamba. The generation benchmarks use CUDA graphs and exclude architectures that lack a recurrent generation implementation. These gains are attributed to fused feature-map computation, register-resident Taylor states, and fused local-window attention rather than to reducing the mathematical content of the attention computation.
The ablations show that the quality of BASED depends on both the Taylor feature-map capacity and the local mixer components. In 362M-parameter models trained for 10B Pile tokens, increasing the Taylor feature dimension from 16 to 32 changes overall Pile perplexity from 8.65 to 8.56 and associative-recall perplexity from 2.07 to 2.00; the corresponding SWDE, FDA, and SQuAD scores change from to . Replacing the Taylor map with a 16-dimensional Performer produces substantially worse associative-recall perplexity of 8.53, while a larger 128-effective-dimension CosFormer reaches 2.18 associative-recall perplexity. Removing sliding-window attention or short convolutions worsens associative-recall perplexity to 2.11 or 2.09, compared with 2.07 for the full configuration; removing both yields 2.29. Increasing the window from 64 to 128 improves some recall-intensive scores but gives only marginal overall gains. Input-dependent decay provides a small improvement at 10B tokens but is not required for the main trends.
BASED also transfers beyond natural-language modeling. On HG38 DNA modeling, BASED obtains perplexities of 2.51, 2.50, and 2.49 at sequence lengths 1,024, 4,096, and 8,192, respectively. On five GenomicBenchmarks classification datasets, its top-1 accuracies are 74.6, 89.5, 89.5, 96.8, and 79.0 percent. Its DNA results are competitive with Transformer++ and Mamba, indicating that the hybrid recall–throughput design is not restricted to English-language tokenization.
Coverage note — Detailed proof derivations, the full BaseConv construction implementing the one-hot upper bound, exhaustive baseline training configurations, and implementation listings for auxiliary kernels were omitted because they support the stated theorems or results rather than constituting separate load-bearing contributions.
@misc{https://doi.org/10.48550/arxiv.2402.18668,
doi = {10.48550/ARXIV.2402.18668},
url = {https://arxiv.org/abs/2402.18668},
author = {Arora, Simran and Eyuboglu, Sabri and Zhang, Michael and Timalsina, Aman and Alberti, Silas and Zinsley, Dylan and Zou, James and Rudra, Atri and Ré, Christopher},
keywords = {Computation and Language (cs.CL), Machine Learning (cs.LG), FOS: Computer and information sciences, FOS: Computer and information sciences},
title = {Simple linear attention language models balance the recall-throughput tradeoff},
publisher = {arXiv},
year = {2024},
copyright = {Creative Commons Zero v1.0 Universal}
}This paper is available from its original source. Click below to access the PDF.
Open PDF