arXiv(opens in a new tab)cs.CLNov 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2611.01426

FlyWheel: Attention Kernels Built for the TPU

Zishuo Bao, Zeshen Zhang, Linkun Chen, Yucheng Lu

Abstract

Attention kernels on Tensor Processing Units (TPUs) often underutilize their matrix units (MXUs) because of repeated matrix operand loads, vector-intensive computation, and dependencies that leave MXUs idle. We present FlyWheel, a set of fast TPU kernels for both softmax and linear attention. FlyWheel reformulates softmax and triangular inversion to reduce vector work, while coordinating data layouts to improve matrix operand reuse. It then overlaps independent computation to hide execution latency. We apply these techniques to both softmax attention and Gated DeltaNet on TPU v6e and v7x. FlyWheel speeds up softmax attention by up to 4.14×4.14\times over the state-of-the-art RPA kernel and 1.80×1.80\times over Splash Attention, reaching 81% of peak BF16 throughput on v6e. It also speeds up Gated DeltaNet prefill by up to 3.61×3.61\times. Integrated into vLLM serving Qwen3.8-27B, FlyWheel improves prefill throughput by up to 1.56×1.56\times while maintaining comparable accuracy.

1 Introduction

Attention kernels are core to modern foundation models, and have been extensively optimized on GPUs. For instance, FlashAttention [3, 4, 24, 38] and FlashInfer [37] accelerate softmax attention, while FLA [34] provides efficient implementations of linear attention such as Gated DeltaNet (GDN) [36]. These attention mechanisms are widely used in models such as Qwen [22] and Kimi Linear [29], supporting applications from document reasoning to video understanding [6, 9, 15]. Much of this progress comes from designing algorithms around GPU hardware: reducing memory traffic, organizing work across threads, and overlapping matrix multiplication with other operations.

Tensor Processing Units (TPUs) offer another platform for serving these models, with recent benchmarks reporting competitive serving costs [10]. On GPUs, architecture-aware optimization has enabled FlashAttention-3 to reach 75% of H100's peak FP16 throughput [24]. Yet even state-of-the-art TPU attention kernels leave substantial performance unused. In our causal prefill benchmarks on TPU v6e, Ragged Paged Attention v3 (RPA-v3) [11] and Google's Splash-Attention kernel in Tokamax [20] achieve only 18–53% and 35–73% of roofline throughput, respectively ( §4.2§4.2). This gap raises a central question:

what limits attention performance on TPUs, and how can kernel designs better exploit their architecture?

GPU attention optimizations do not transfer directly to TPUs because the architectures differ in three key respects. First, TPU layout constraints and weight-stationary matrix units (MXUs) make data placement and operand reuse central to matrix efficiency. Layout choices determine tile utilization, while repeated operand loads can limit throughput even when data is already on chip. Second, TPUs provide limited vector throughput relative to matrix compute, making softmax reductions, rescaling, and other elementwise operations potential bottlenecks. Reducing this work also requires managing register pressure: in our v6e experiments, the additional state required by FlashAttention-4's conditional rescaling [38] offsets its savings in vector work ( §5.1§5.1). Third, a TPU TensorCore exposes a single-threaded programming model with compiler-managed overlap across execution units, rather than GPU-style warp scheduling. FlashAttention-3 [24] combines asynchronous matrix operations with inter- and intra-warpgroup pipelining. On TPUs, kernels must instead expose independent work in a form that the compiler can schedule across the matrix and vector units.

To address these gaps, we present FlyWheel: a suite of TPU-native kernels for softmax attention and Gated DeltaNet, written in Pallas [30]. FlyWheel coordinates layouts across operator boundaries so that projections produce and consume the attention kernel's layout directly, and handles ragged sequence boundaries on chip. It amortizes MXU operand loads by increasing reuse and combining matrix products that share an operand. To reduce pressure on the vector units, FlyWheel removes repeated softmax rescaling with a checked static anchor and computes the GDN triangular inverse with eight BF16 matrix multiplications. Finally, it interleaves independent work across attention fragments and GDN chunks to hide latency and overlap matrix and vector computation. Together, these designs reduce the overhead surrounding matrix multiplication and keep the MXUs busy (§3).

We evaluate FlyWheel on TPU v6e and v7x (§4). FlyWheel accelerates softmax attention by up to 4.14× over RPA-v3 and 1.80× over Splash-Attention, reaching 81% of peak BF16 throughput on v6e. It accelerates GDN prefill by up to 3.61× over the state-of-the-art GDN-v3 kernel. These kernel improvements translate into application-level gains: in vLLM serving Qwen3.8-27B at 512K tokens, FlyWheel improves prefill throughput by 1.53× on RULER and 1.56× on BABILong on v6e, and by up to 1.35× on v7x. On Video-MME, it accelerates language model prefill by up to 1.29× and 1.24× on the two generations, respectively, while maintaining comparable benchmark accuracy (§4.4).

Our contributions in this paper can be summarized as follows:

  • We identify shared architectural bottlenecks in TPU softmax and linear attention and show why established GPU optimizations do not directly address them.

  • We develop FlyWheel, a suite of TPU-native attention kernels that combines coordinated layouts, matrix operand reuse, reduced vector work, and explicit pipelining.

  • We demonstrate kernel speedups on TPU v6e and v7x and translate them into application-level gains in vLLM: up to 1.53× and 1.56× higher prefill throughput on RULER and BABILong, respectively, and 1.29× faster language model prefill on Video-MME, while maintaining comparable accuracy.

References (32)