RACE Attention
A Transformer language model whose attention layers use RACE Attention, which costs linear time in sequence length.
Language · 136 operations Checked
Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.
At a glance
- Task
- Language
- Parameters
- 13.3M
- Operations
- 136
- Framework
- PyTorch
- Recurrent
- No
- Published
- ICLR 2026
- Paper
- RACE Attention: A Strictly Linear-Time Attention Layer for Training on Outrageously Large Contexts
- Cited by
- 0 (as of 28 October 2026)
- Authors
- Sahil Joshi, Agniva Chowdhury, Amar Kanakamedala and others
- License
- MIT
- Checked
- Passed: the trace was replayed operation by operation and matched the model's own output for this input.
Files
The file opened in a new tab. Use your browser's Save command there to keep it.
The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.
Details
- Stable ID
- m19589
- Graph hash
- f1c4e1b6471a3ed15f24e54b46cbfdf511518f13097cd70ee794dcbdbcf16e65
- Skeleton hash
- aa872c155f209b3c79d5b17bfe5b6440e5eba891617464f362e7392a3ff3c642
- Architecture hash
- 30d0be5ff4b1e9f147e738ceaecbee7ed854a7bddba9bbe595cb7e5b08779360
- Diagram SHA-256
- 52cd7d8b3e7802859c4f494dd17ac758db64ee4a7f8a75bc3bbb1841998d1aff
- TorchLens version
- 2.36.0
- Renderer
- graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
- Check
- Forward pass replayed in PyTorch
What it is
RACE Attention is an attention layer whose cost grows linearly with sequence length, proposed as a replacement for the softmax attention used in Transformers. The motivation is the quadratic cost of standard attention: the paper notes that FlashAttention-2/3 cannot complete a single forward-backward pass of one attention layer once the context exceeds about 4 million tokens on an NVIDIA GH200 (96 GB).
In place of the exponential kernel, RACE Attention scores each query-key pair with a sharpened angular similarity. It never builds the full attention matrix: with Gaussian random projections and soft locality-sensitive hashing, each query mixes with a fixed bank of bucket summaries rather than with every key. Hard hashing is replaced by smooth soft assignments over hypercube corners, so the sketch is differentiable and can be trained end to end. A second algorithm covers the causal case that autoregressive language models need.
The authors evaluate the layer inside Transformers on causal language modeling, masked language modeling, and text and image classification. In a scaling study of a single attention layer, the paper reports processing up to 12 million tokens on an NVIDIA GH200 GPU and 75 million tokens on an Intel Xeon Gold 5220R CPU in one forward-backward pass. The code repository lists the paper as accepted at ICLR 2026.
Key idea. RACE Attention replaces softmax attention with a sharpened angular kernel estimated through random projections and soft locality-sensitive hashing, giving attention that is strictly linear in sequence length.
- RACE Attention
- Repeated Arrays-of-Count Estimators Attention
- linear-time attention
- long-context training
- locality-sensitive hashing attention
- angular kernel attention
- language modeling
- softmax attention alternative
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
Cite the paper
@misc{joshi2026raceattentionstrictlylineartime,
title={RACE Attention: A Strictly Linear-Time Attention Layer for Training on Outrageously Large Contexts},
author={Sahil Joshi and Agniva Chowdhury and Amar Kanakamedala and Ekam Singh and Evan Tu and Anshumali Shrivastava},
year={2026},
eprint={2510.04008},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2510.04008},
}