Fast Gradient Computation for RoPE Attention in Almost Linear Time

Yifang Chen, Jiayan Huo, Xiaoyu Li, Yingyu Liang, Zhenmei Shi +1 more
12/23/2024
cs.LGcs.AIcs.CC

No confident code implementation found for this paper.

Abstract

The Rotary Position Embedding (RoPE) mechanism has become a powerful enhancement to the Transformer architecture, which enables models to capture token relationships when encoding positional information. However, the RoPE mechanisms make the computations of attention mechanisms more complicated, which makes efficient algorithms challenging. Earlier research introduced almost linear time, i.e., $n^{1+o(1)}$ where $n$ is the number of input tokens, algorithms for the forward computation under specific parameter settings. However, achieving a subquadratic time algorithm for other parameter regimes remains impossible unless the widely accepted Strong Exponential Time Hypothesis (SETH) is disproven. In this work, we develop the first almost linear time algorithm for backward computations in the RoPE-based attention under bounded entries. Our approach builds on recent advancements in fast RoPE attention computations, utilizing a novel combination of the polynomial method and the Fast Fourier Transform. Furthermore, we show that with lower bounds derived from the SETH, the bounded entry condition is necessary for subquadratic performance.

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. Any repos shown below are weak matches — 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{chen2024fast,
  title  = {Fast Gradient Computation for RoPE Attention in Almost Linear Time},
  author = {Yifang Chen and Jiayan Huo and Xiaoyu Li and Yingyu Liang and Zhenmei Shi and Zhao Song},
  year   = {2024},
  eprint = {2412.17316},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2412.17316v2}
}

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/2412.17316.svg)](https://codeofpaper.com/paper/2412.17316)

Discussion