RACE Attention: A Strictly Linear-Time Attention Layer for Training on Outrageously Large Contexts

Fuente: arXiv
Guardado en:
Detalles Bibliográficos
Autores principales: Joshi, Sahil, Chowdhury, Agniva, Kanakamedala, Amar, Singh, Ekam, Tu, Evan, Shrivastava, Anshumali
Formato: Preprint
Publicado: 2025
Materias:
Acceso en línea:
Etiquetas: Agregar Etiqueta
Sin Etiquetas, Sea el primero en etiquetar este registro!
_version_ 1866914484260438016
author Joshi, Sahil
Chowdhury, Agniva
Kanakamedala, Amar
Singh, Ekam
Tu, Evan
Shrivastava, Anshumali
author_facet Joshi, Sahil
Chowdhury, Agniva
Kanakamedala, Amar
Singh, Ekam
Tu, Evan
Shrivastava, Anshumali
contents Softmax Attention has a quadratic time complexity in sequence length, which becomes prohibitive to run at long contexts, even with highly optimized GPU kernels. For example, FlashAttention-2/3 (exact, GPU-optimized implementations of Softmax Attention) cannot complete a single forward-backward pass of a single attention layer once the context exceeds ~4 million tokens on an NVIDIA GH200 (96 GB). We introduce Repeated Arrays-of-Count Estimators (RACE) Attention, a kernel-inspired alternative to Softmax Attention that is strictly linear in sequence length and embedding size. RACE Attention replaces the exponential kernel with a sharpened angular similarity, and approximates attention outputs via Gaussian random projections and soft Locality-Sensitive Hashing (LSH), avoiding construction of the full attention matrix. Across language modeling, masked language modeling, and text/image classification, RACE Attention matches or outperforms strong baselines up to 64K seqeuence length while reducing wall-clock time and memory usage. In addition, we conduct a controlled scaling study on a single attention layer and demonstrate processing of up to 12 million tokens on an NVIDIA GH200 GPU and 75 million tokens on an Intel Xeon Gold 5220R CPU in a single forward-backward pass, which is well beyond the capabilities of current state-of-the-art attention implementations. RACE Attention thus offers a practical and theoretically grounded mechanism for long-context training on today's hardware. We release our code at https://github.com/sahiljoshi515/RACE_Attention.
format Preprint
id arxiv_https___arxiv_org_abs_2510_04008
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle RACE Attention: A Strictly Linear-Time Attention Layer for Training on Outrageously Large Contexts
Joshi, Sahil
Chowdhury, Agniva
Kanakamedala, Amar
Singh, Ekam
Tu, Evan
Shrivastava, Anshumali
Machine Learning
Artificial Intelligence
Softmax Attention has a quadratic time complexity in sequence length, which becomes prohibitive to run at long contexts, even with highly optimized GPU kernels. For example, FlashAttention-2/3 (exact, GPU-optimized implementations of Softmax Attention) cannot complete a single forward-backward pass of a single attention layer once the context exceeds ~4 million tokens on an NVIDIA GH200 (96 GB). We introduce Repeated Arrays-of-Count Estimators (RACE) Attention, a kernel-inspired alternative to Softmax Attention that is strictly linear in sequence length and embedding size. RACE Attention replaces the exponential kernel with a sharpened angular similarity, and approximates attention outputs via Gaussian random projections and soft Locality-Sensitive Hashing (LSH), avoiding construction of the full attention matrix. Across language modeling, masked language modeling, and text/image classification, RACE Attention matches or outperforms strong baselines up to 64K seqeuence length while reducing wall-clock time and memory usage. In addition, we conduct a controlled scaling study on a single attention layer and demonstrate processing of up to 12 million tokens on an NVIDIA GH200 GPU and 75 million tokens on an Intel Xeon Gold 5220R CPU in a single forward-backward pass, which is well beyond the capabilities of current state-of-the-art attention implementations. RACE Attention thus offers a practical and theoretically grounded mechanism for long-context training on today's hardware. We release our code at https://github.com/sahiljoshi515/RACE_Attention.
title RACE Attention: A Strictly Linear-Time Attention Layer for Training on Outrageously Large Contexts
topic Machine Learning
Artificial Intelligence
url https://arxiv.org/abs/2510.04008