Transformer Based Linear Attention with Optimized GPU Kernel Implementation

Armin Gerami, Ramani Duraiswami
10/24/2025
cs.LGcs.CL

No confident code implementation found for this paper. 8 possible matches can be shown below.

Abstract

The original softmax-based attention mechanism (regular attention) in the extremely successful Transformer architecture computes attention between $N$ tokens, each embedded in a $D$-dimensional head, with a time complexity of $O(N^2D)$. Given the success of Transformers, improving their runtime during both training and inference is a popular research area. One such approach is the introduction of the linear attention (LA) mechanisms, which offers a linear time complexity of $O(ND^2)$ and have demonstrated comparable accuracy to regular attention. However, LA in practice lags behind its theoretical efficiency. We propose a novel method for LA's forward and backward passes, along with a highly-optimized CUDA implementation. Our approach outperforms the state-of-the-art by 3.3 times in speed and reduces memory consumption by 3.6 times. We validate these improvements in both single-layer and end-to-end settings by training a 1.4 billion parameter language model, which demonstrates similar expressivity to regular attention on major reasoning benchmarks.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. 8 weaker matches are hidden by default — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{gerami2025transformer,
  title  = {Transformer Based Linear Attention with Optimized GPU Kernel Implementation},
  author = {Armin Gerami and Ramani Duraiswami},
  year   = {2025},
  eprint = {2510.21956},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2510.21956v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2510.21956.svg)](https://codeofpaper.com/paper/2510.21956)

Discussion