cs.CLNov 1, 2026

FlyWheel: Attention Kernels Built for the TPU

Authors: Zishuo Bao, Zeshen Zhang, Linkun Chen, Yucheng Lu

Organizations: New York University · New York University Shanghai · Google

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.

Figures & tables

Appendix figures & tables7 assets

Supplementary material from the paper’s appendix.

Appendix

Explore similar work

Nov 4, 2026

Systolic Linear Attention: Co-Designing Tile-Grouped Gated Delta Attention for TPUs

Gated-delta linear attention layers such as Gated DeltaNet (GDN), Kimi Delta Attention (KDA), and GDN-2 are tuned for GPUs, where small tensor-core tiles and fast vector registers make per-channel decay rescaling and sequential in-block solves cheap. On Google TPUs, which concentrate compute in wide 256×256256 \times 256 systolic matrix units backed by a slower vector unit, porting these layers directly leaves half of each matrix tile empty and bottlenecks on vector operations. We present Systolic Linear Attention (SLA), which reshapes gated delta attention around the matrix unit by widening keys to 256256 with grouped value heads, grouping decay gates into four 6464-channel tiles, and computing the chunk solve entirely with block matrix products in a single fused kernel. On TPU v7x, a full SLA-R4 layer runs 1.6×1.6\times--2.5×2.5\times faster than the open-source Tokamax KDA kernel (1.4×1.4\times--2.4×2.4\times with exact chunk inversion), driven primarily by head sharing and kernel fusion. Across a 2,0482{,}048-chip TPU v7x pre-training study of sparse Mixture-of-Experts (MoE) models from 6.5B6.5\text{B} to 63.1B63.1\text{B} parameters, SLA trains 11%11\%--24%24\% faster than KDA at similar perplexity, and reaches slightly lower perplexity than KDA in smaller matched-seed runs.
Apr 16, 2026

Ragged Paged Attention: A High-Performance and Flexible LLM Inference Kernel for TPU

Large Language Model (LLM) deployment is increasingly shifting to cost-efficient accelerators like Google's Tensor Processing Units (TPUs), prioritizing both performance and total cost of ownership (TCO). However, existing LLM inference kernels and serving systems remain largely GPU-centric, and there is no well-established approach for efficiently mapping LLM workloads onto TPU architectures--particularly under the dynamic and ragged execution patterns common in modern serving. In this paper, we present Ragged Paged Attention (RPA), a high-performance and flexible attention kernel for TPUs, implemented using Pallas and Mosaic. RPA addresses these challenges through three key techniques: (1) fine-grained tiling to enable efficient dynamic slicing over ragged memory, (2) a custom software pipeline that fuses KV cache updates with attention computation, and (3) a distribution-aware compilation strategy that generates specialized kernels for decode, prefill, and mixed workloads. Evaluated on Llama 3 8B on TPU7x, RPA achieves up to 86% memory bandwidth utilization (MBU) in decode and 73% model FLOPs utilization (MFU) in prefill. Integrated as the primary TPU backend in vLLM and SGLang, RPA provides a production-grade foundation for efficient TPU inference and offers practical insights into kernel design.
Apr 26, 2026

ELSA: Exact Linear-Scan Attention for Fast and Memory-Light Vision Transformers

Existing attention accelerators often trade exact softmax semantics, depend on fused Tensor Core kernels, or incur sequential depth that limits FP32 throughput on long sequences. We present ELSA, an algorithmic reformulation of online softmax attention that (i)~preserves exact softmax semantics in real arithmetic with a provable O(ulog⁡n)\mathcal{O}(u\log n) FP32 relative error bound; (ii)~casts the online softmax update as a prefix scan over an associative monoid (m,S,W)(m,S,W), yielding O(n)O(n) extra memory and O(log⁡n)O(\log n) parallel depth; and (iii)~is Tensor-Core independent, implemented in Triton and CUDA C++, and deployable as a drop-in replacement requiring no retraining or weight modification. Unlike FlashAttention-2/3, which rely on HMMA/GMMA Tensor Core instructions and provide no compatible FP32 path, ELSA operates identically on A100s and resource-constrained edge devices such as Jetson TX2 -- making it the only hardware-agnostic exact-attention kernel that reduces parallel depth to O(log⁡n)O(\log n) at full precision. On A100 FP32 benchmarks (1K--16K tokens), ELSA delivers 1.31.3--3.5×3.5\times speedup over memory-efficient SDPA and 1.971.97--2.27×2.27\times on BERT; on Jetson TX2, ELSA achieves 1.51.5--1.6×1.6\times over Math (64--900 tokens), with 17.817.8--20.2%20.2\% throughput gains under LLaMA-13B offloading at ≥\ge32K. In FP16, ELSA approaches hardware-fused baselines at long sequences while retaining full FP32 capability, offering a unified kernel for high-precision inference across platforms. Our code and implementation are available at https://github.com/ming053l/ELSA.