Manuscript Offprint
arXiv:2611.01426FlyWheel: Attention Kernels Built for the TPU
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 over the state-of-the-art RPA kernel and over Splash Attention, reaching 81% of peak BF16 throughput on v6e. It also speeds up Gated DeltaNet prefill by up to . Integrated into vLLM serving Qwen3.8-27B, FlyWheel improves prefill throughput by up to 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 ( ). 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 ( ). 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.
2.1 Softmax Attention
Given queries, keys, and values , where is the sequence length and is the head dimension, softmax attention [31] computes
where and . Softmax is applied row-wise. We omit the scaling factor and attention mask for simplicity. The computation is applied independently to each query head; grouped-query attention shares keys and values across query heads [1].
Blockwise computation. FlashAttention [4] avoids materializing in HBM by processing keys and values in blocks. For each query row, online softmax [18] maintains a scalar running maximum , a scalar normalization sum , and an output accumulator . For a block of keys, let be the scores and the values. The update is
\begin{aligned}m' &= \max_j(m, \max_s_j), \quad \mathbf{p} = e^{s-m'}, \\l &\leftarrow rl + \sum_j p_j, \\o &\leftarrow ro + pV_b,\end{aligned} \tag{2}where rescales the previous accumulators. The algorithm then sets and returns after the final block.
Each block contains two matrix multiplications separated by vector operations: maximum reduction, exponentiation, sum reduction, and accumulator rescaling. The running maximum stabilizes the exponentials but also introduces rescaling dependencies across blocks. These vector operations and dependencies can limit matrix throughput. Appendix A provides the online-softmax reference in Algorithm 5.
¹We defer the discussion of decode kernels to Appendix D.
2.2 Linear Attention
Unlike softmax attention, which attends explicitly to previous keys and values, linear attention [14] summarizes the token history in a fixed-size state matrix. We focus on Gated DeltaNet (GDN) [36], which updates this state using the delta rule [23]. Let and denote the query, key, and value rows for token , where and are the query/key and value dimensions, respectively. The state and output satisfy
where the scalar controls the update magnitude. The residual corrects the state's prediction of the current value. For clarity, we omit GDN's decay gate, which scales the previous state before the update.
Chunked computation. In GDN, prefill kernels often group tokens into chunks to express the recurrence as matrix products [35, 36]. Within a chunk of tokens, we use local indices and stack the query, key, and value rows , and into and , respectively. Let collect their update coefficients. Define
both of shape , where and retain the lower triangle without and with the diagonal, respectively. Given the state entering the chunk, the computation is
where is the identity matrix, contains the value updates, and stacks the output rows . As above, decay factors are omitted; they introduce additional scaling without changing the matrix dimensions [36].
The matrices , and depend only on chunk-local inputs and can be computed independently across chunks. In contrast, , , and the state update depend on the incoming state and must respect the recurrence. The computation also exposes operand reuse: constructing and uses the same , while the intra-chunk output and state increment share . Appendix A gives a reference algorithm using forward substitution.
Additional layer operations. The query, key, and value vectors entering the recurrence are obtained through depthwise causal convolution and SiLU, with additional per-head L2 normalization for queries and keys. GDN prefill thus combines these preprocessing operations with small matrix products and triangular inversion, motivating joint optimization of the full computation.
2.3 TPU Architecture and Attention Bottlenecks
A TPU v6e chip contains one TensorCore, while a v7x chip contains two [13]. Each TensorCore uses a VLIW instruction stream to coordinate matrix, vector, and specialized execution units [12], with DMA engines transferring data between HBM and on-chip vector memory (VMEM). These units can execute concurrently when dependencies permit. Layout overhead, non-matrix computation, and execution stalls also affect GPU attention; the challenge is to address them under the TPU's data organization and execution model.
Data layout and matrix operand reuse. TPU vector registers contain 32-bit words, organized as sublanes and lanes; packing two BF16 elements per word accommodates a tile. Layout choices therefore affect padding, register utilization, and the shapes available to matrix operations. The MXUs use weight-stationary systolic arrays [13]: for , the stationary operand is loaded into the array and reused as rows of stream through it. This loading cost must be amortized even when operands already reside on chip.
For softmax attention, the layout determines how many query rows fit in a tile and reuse each key or value load. Tiling tokens also introduces alignment constraints at ragged sequence boundaries. For GDN, small chunk matrices offer less reuse per load, although several products share the same right operand (Eq. 4). Its input layout must also support both convolution and per-head matrix computation. Efficient layouts must therefore support operand reuse without introducing costly conversions between operators.
Non-matrix work on the critical path. TPUs provide much higher throughput for matrix multiplication than for vector operations [12]. Softmax attention places reductions, exponentials, and accumulator rescaling between its two matrix products. In GDN, forward substitution introduces dependent row updates, while convolution and normalization add vector arithmetic and data rearrangement. Consequently, reducing matrix execution time alone may leave overall kernel latency largely unchanged. This imbalance also motivates GPU optimizations such as FlashAttention-4 [38], but their benefit on TPUs depends on the resulting instruction mix, register requirements, and dependencies.
Exposing work for compiler scheduling. FlashAttention-3 [24] exploits asynchronous matrix operations and inter- and intra-warpgroup pipelining. A TPU TensorCore instead relies on compiler scheduling within a single instruction stream. Concurrent execution is supported, but sufficient independent work must be visible to the compiler.
In softmax attention, each fragment contains a score-to-softmax-to-output dependency chain, and online rescaling couples successive fragments through their accumulators. In GDN, triangular inversion contains dependent operations, while the recurrent state links successive chunks. However, other softmax fragments and GDN's state-independent chunk computations provide work that can overlap these chains. Kernel structure and loop boundaries determine whether the compiler can exploit this independence.
These observations guide the two kernel designs in §3. For softmax attention, FlyWheel combines larger per-head tiles with a checked static anchor and fragment pipelining (§3.1). For GDN, it combines shared-operand products with matrix-based inversion and cross-chunk pipelining (§3.2).
3 FlyWheel
FlyWheel addresses the bottlenecks in §2.3 by connecting data layout, computational reformulation, and scheduling. In softmax attention, per-head tiles increase operand reuse, while a checked static anchor simplifies the dependencies between fragments. In GDN, shared-operand products and hierarchical inversion move more work onto the MXU, and cross-chunk scheduling hides the resulting matrix dependencies.
3.1 Softmax Attention
Layout and operand reuse. Attention inputs have logical shapes and , where is the token count, and are the query and key/value head counts, and is the head dimension. Mapping these axes to registers determines how much computation can reuse each loaded key or value tile. In RPA-v3 [11], a query tile spans all heads, so its accumulator storage grows with the head count and restricts the number of query rows. Under MHA, packing heads on sublanes also leaves half of each BF16 register as padding (Figure 1a).
FlyWheel instead uses a head-major layout, packing two tokens from the same head into each sublane. This removes the MHA padding and decouples query tile size from head count: a tile holds 256 query rows, allowing each stationary key or value load to serve 256 rows. GQA uses the same organization, with each query head accessing its shared key/value head.
Token tiling introduces a second problem: ragged sequences need not start at DMA-aligned rows. Figure 1b shows a sequence starting at row 13 whose DMA window begins at row 8. FlyWheel preserves rows 8–12 by copying their previously computed outputs from the preceding VMEM buffer before writing the aligned window. Together with projections that directly produce and consume the kernel's layout, this allows larger per-head tiles without separate HBM layout conversions or output gathers.
Reducing vector work with a checked static anchor. The layout improves matrix reuse, but each online-softmax step still inserts a maximum reduction and accumulator rescaling between matrix products. FlyWheel removes this repeated work by using a fixed reference for the exponential weights. Following Eq. 2, it sets a scalar anchor to the maximum score in each query row's first key/value tile and accumulates
The shapes are unchanged from the Background: , , and , with scalar . The final division
(a)
RPA v3: heads on sublanes
MHA: head h and a padding row

FlyWheel: tokens on sublanes
two tokens of head h

(b) Block k-1 stage
rows 0–15, VMEM
Block k stage
rows 8–23, VMEM
Output
rows 0–23, HBM

Figure 1: Per-head tiling with ragged boundaries. (a) Under MHA, RPA-v3 pads each query head and holds 8 tokens per BF16 register; FlyWheel holds 16 tokens of one head without padding. (b) A sequence starting at row 13 is written through a window aligned at row 8; FlyWheel first restores rows 8–12 from the previous VMEM buffer.
o/l cancels the common factor in exact arithmetic.
The anchor need not remain the maximum, but the accumulated values must remain within numerical range. Since the weights are nonnegative, their sum bounds every weight. FlyWheel checks after each key/value block. The comparison also fails on NaN and , and elementwise, so needs no separate check. If any row fails, FlyWheel replays that block with guarded anchor updates in the same launch (Algorithm 2). Unlike FlashAttention-4 [38], which checks each fragment's maximum, FlyWheel checks the already-accumulated , saving the per-fragment reduction, the rescaling branch, and their vector registers.
Exposing overlap across fragments. A fragment pairs one query tile with one key/value tile. Its QK matmul and softmax do not depend on the preceding fragment's PV matmul; only the output accumulation is sequential. This independence also holds under online softmax with a running max, and FlashAttention-3 uses it to overlap softmax with GEMMs on GPUs [24]. FlyWheel software-pipelines fragments at distance one. It defers each fragment's PV matmul and issues it after the next fragment's QK matmul and exponentials. It also keeps these fragments in one compiler basic block, so the scheduler can overlap one fragment's MXU work with the next fragment's vector work. Figure 2a contrasts this schedule with the gaps left by RPA-v3 when only one key/value head is available per device. The overlapped work comes from consecutive fragments of the same head, so FlyWheel keeps the MXU busy even within a single head. The pipeline also continues across head boundaries: the first QK matmul of one head overlaps the last PV matmul of the previous head. The fixed anchor still makes each pipelined step cheaper. No fragment rescales the output accumulator, and each fragment's exponentials depend only on its own scores.
Algorithm 1 summarizes this schedule for one head. It batches the row-wise notation: , , and , with row-wise broadcasting. The preceding weights are retained until their output product completes, and the last product drains the pipeline.
Guarded replay. Algorithm 2 specifies the fallback used by Algorithm 1. It recomputes only the key/value block that failed the check. The kernel keeps the anchor and accumulators on entry to each block in a second buffer, so the replay starts from them rather than from the first key tile; the first block enters with the anchor from and zero accumulators. The entry state of a block holds the contributions of all fragments before it: the preceding block's last output product is
(a) KV head g KV head g+1 MXU idle
RPA v3, one KV head per chip: no overlap

(b) chunk 1 chunk 2 MXU idle
Back to back

MXU issue order; each second row continues the first
Figure 2: Filling dependency-induced execution gaps. (a) RPA-v3 leaves the MXU idle during exponentiation; FlyWheel overlaps each fragment's scores and exponentials with the previous fragment's PV product. (b) Gaps between the dependent inverse products 1–8 of one GDN chunk are filled with the other chunk's stacked product (A) and state-dependent work. Lengths are schematic.
issued in the block's first step, before the block's check. The replay checks each fragment before exponentiation. It also issues the block's last output product, so Algorithm 1 clears the pending weights after the replay. The anchor is updated independently for each row only when the fragment maximum exceeds the row's anchor by more than a score margin . All exponentials are written in natural units, consistently with Eq. 5; the implementation converts the margin to base-two units when using exp2.
Anchor updates. The shapes and broadcasting conventions are the same as in Algorithm 1. The selection in where is row-wise, and r scales each row of o. For a row whose anchor is unchanged, the rescaling factor is 1 and its rescaling can be omitted. If the anchor changes from a to , multiplying both accumulators by expresses all previous contributions relative to the new anchor. Thus, in exact arithmetic, their ratio remains the softmax output. As in the main algorithm, the first key tile must contain a valid key for every query row; fully masked later fragments contribute zero.
Choosing the range margin. Let bound the absolute entries of V, and let F be a conservative upper limit supported by both the exponential operands and the FP32 accumulators. One sufficient range condition, before accounting for rounding, is
Here the sequence length bounds the number of keys of each query row. After every guarded update, each score is at most above its row's anchor, so each weight is at most , , and ; Eq. 6 keeps both bounds below . The margin reserves headroom below for rounding. For the static-anchor pass, a conservative acceptance bound is , since for each row. The comparison in Algorithm 1 is false for NaN and , so a nonfinite sum also triggers a replay of the failing block. Since elementwise, an accepted also keeps within range, and needs no separate check. The concrete threshold and numerical headroom must also account for the implementation's operand casts and reductions.
3.2 Gated DeltaNet
Layout and operand reuse. GDN organizes computation into small recurrent chunks, limiting the rows available to reuse each operand. FlyWheel therefore reuses operands across products within each chunk. It consumes the projection's BF16 output directly, avoiding the GDN-v3 wrapper's HBM upcast and retiling, and stacks the products in Eq. 4 that share
Algorithm 1 FlyWheel softmax attention
Require: ; range threshold
Ensure:
1: for each query tile do 2: Partition keys and values into , grouped into blocks 3: 4: 5: ; ; 6: for do 7: Interleave: 8: 9: 10: 11: 12: 13: if ends a block and not ( for all rows) then 14: ; 15: end if 16: end for 17: 18: 19: end for 20: return
Algorithm 2 GUARDEDREPLAY: checked softmax recomputation
Require: Query tile ; block of key/value tiles ; margin
Ensure: Anchor and accumulators after
1: anchor and accumulators on entry to 2: for each in order do 3: 4: 5: 6: 7: ; 8: 9: 10: 11: end for 12: return
a right operand:
The first product loads once to construct both and after triangular masking. The second reuses for the state increment and intra-chunk output. Thus, four separate matrix products become two larger products with shared operand loads.
Reducing vector work with hierarchical inversion. Operand reuse does not remove the triangular solve on GDN's critical path. FlyWheel replaces its dependent forward-substitution updates with a matrix-based inverse of . A polynomial inverse applied to the entire chunk can produce large intermediate powers and cancellation [26]. Following the hierarchical approach of prior work, which merges pairs of blocks using FP32 products [26], FlyWheel instead inverts blocks and merges four at a time using BF16 operands with FP32 accumulation. Figure 3a shows this progression: each stage reuses the diagonal blocks already inverted in blue and processes the blocks shown in orange.
Algorithm 3 FlyWheel Gated DeltaNet
Require: , ; coefficients ; state
Ensure: and updated
1: Partition inputs into of rows
2:
3: for do
4: Interleave (let ; skip chunks outside 1..N):
5:
6:
7:
8:
9:
10:
11:
12: end for
13: return
(a) inverted at a lower level solved at this level not yet reached

(b)
Figure 3: Replacing vector operations with matrix products. (a) Hierarchical triangular inversion merges blocks into and then blocks. (b) A four-tap causal convolution (C = 8) as one product Y = 5W, where W stacks the tap-scaled inputs and halo rows, and the constant selector S ( in the text) sums the required rows.
At each merge, write , where contains the four diagonal blocks and the strictly lower off-diagonal blocks. The preceding level supplies . Defining gives and
Because and share the right operand N, one stacked product forms both. Each merge therefore takes three products: , the stacked product, and the product with .
The hierarchy limits the polynomial to a four-block system at each level, rather than forming high powers of the full-chunk matrix. For C = 64, two merge levels complete the inverse.
Algorithm 4 gives the complete INVERSE4 routine used by Algorithm 3. Its input is . It first inverts the independent diagonal blocks: for a block with strictly lower-triangular , and , which takes two products: and . Each merge level then processes consecutive index blocks of rows, and denotes the diagonal block of on . Its four diagonal subblocks form , and collects their inverses from the preceding level, so in exact arithmetic. The matrix is strictly lower triangular with respect to four blocks, hence . Since , its inverse is , recovering Eq. 8. Stacking over forms and in one product, and the last product multiplies by . With two merge levels, the inverse takes eight products in total. The pseudocode specifies the algebraic dependencies; head packing, masked-product implementation, and instruction scheduling are omitted. Matrix products use BF16 operands with FP32 accumulation, so the returned matrix is an approximate inverse in floating-point arithmetic; §4.4 evaluates application accuracy.
Algorithm 4 INVERSE4: hierarchical triangular inversion
Require: Unit lower-triangular Ensure: Approximate inverse
1: 2: for each consecutive index block of size 4 do 3: 4: 5: 6: end for 7: for do 8: for each consecutive index block of size do 9: Split into four equal subblocks 10: 11: 12: 13: 14: 15: 16: end for 17: end for 18: return
Convolution presents a similar opportunity to replace vector work with matrix computation. In Figure 3b, each tap contributes a scaled copy of the input, and a constant selector gathers the appropriate token rows and sums their contributions:
For and taps, contains the tap-scaled inputs and preceding-chunk halo, while performs selection and summation. This trades additional MXU arithmetic for fewer vector shifts and accumulations. The figure's selector is distinct from the recurrent state.
Exposing overlap across chunks. Matrix-based inversion removes dependent vector updates but leaves dependent matrix products. Executing chunks back to back would expose the latency gaps shown in the upper schedule of Figure 2b. The key opportunity is that the inverse depends only on the current chunk's inputs, not its incoming recurrent state. FlyWheel therefore overlaps the first chunk's inverse with the second chunk's stacked product, then overlaps the second inverse with the first chunk's state-dependent computation. Splitting this work across head groups fills gaps between inverse steps, as shown in the lower schedule, while preserving the order of recurrent state updates.
Algorithm 3 presents the computation in dependency order, with chunk index added to the notation of Eq. 4. Inputs follow convolution, SiLU, and query/key normalization; decay is omitted as in the Background. The unmasked products precede triangular masking; and denote the state increment and intra-chunk output. Both value updates and outputs use the incoming before the state update. Figure 2b shows how independent operations from adjacent chunks are interleaved.
4 Evaluation
We evaluate FlyWheel on TPU v6e and v7x, comparing softmax and GDN prefill kernels against TPU baselines and measuring application performance and accuracy on RULER, BABILong, and Video-MME. We isolate the contributions of individual designs through ablations in §5.
4.1 Setup
Hardware and software. We run the kernel benchmarks on one TPU v6e (Trillium) chip and on one TensorCore of a TPU v7x (Ironwood) chip, which JAX exposes as one device (Table 1). The end-to-end runs use a v6e-8 slice with 8-way tensor parallelism (TP) up to 256K tokens, and a v6e-16 slice with TP 8 and 2-way prefill context parallelism (CP) at 512K tokens. On v7x they use one host of four chips, eight TensorCores, with TP 8 at every length, so each rank runs on one TensorCore. All runs use JAX [2] 0.11.0 and libtpu 0.0.44.
Table 1: Hardware of the kernel benchmarks. A v7x chip has two TensorCores; the row lists one of them.
| BF16 peak(TFLOP/s) | VMEM(MiB) | HBM(GiB) | HBM BW(TB/s) | |
|---|---|---|---|---|
| v6e chip | 918 | 128 | 32 | 1.6 |
| v7x TensorCore | 1153 | 64 | 96 | 3.7 |
Baselines. For softmax attention, we compare with RPA-v3 (Ragged Paged Attention v3) from tpu-inference [32], the TPU backend of vLLM [16] (commit 4420cae), and Google's Splash-Attention from Tokamax [20] (commit 84e5f36). For linear attention, we use GDN-v3, the fused causal conv1d and chunked GDN kernel from the same tpu-inference commit.
Kernel workloads. Softmax attention uses causal prefill with head dimension 256, 32 query heads, and 32 (MHA) or 4 (GQA) KV heads, for 1K to 128K tokens in powers of two. FlyWheel and Splash-Attention use [H, T, D] inputs, while RPA-v3 uses [T, H, D] and a paged KV cache (following their original setup). To account for layout overhead, we measure both the kernel alone and the full attention block, including QKV and output projections and all intervening layout conversions (Appendix B).
Linear attention runs the fused causal conv1d (kernel size 4) and GDN prefill with 16 query/key heads, , and value heads; Qwen3.8-4B has and Qwen3.8-27B has . Each call prefills tokens, packed into 1 or 8 sequences of equal length. Activations are BF16 and the recurrent state is FP32. GDN-v3 runs its default 64-token tile; FlyWheel runs 128-row tiles of two 64-token chunks.
End-to-end workloads. We serve Qwen3.8-27B [22], a hybrid vision-language model with 64 language model layers: 48 GDN layers (16 query/key heads, 48 value heads, head dimension 128) and 16 softmax attention layers (24 query heads, 4 KV heads, head dimension 256). We use vLLM (commit 51da0ca) with tpu-inference (commit 4420cae). FlyWheel replaces the baseline's RPA-v3, GDN-v3, and vision encoder Pallas flash attention kernels. An environment switch selects the kernels within the same build; the model, scheduler, and other operators remain unchanged.
We also evaluate with three long-context benchmarks. RULER [9], through lm-evaluation-harness [7], runs its needle-in-a-haystack tasks at 4K, 32K, 128K, 256K, and 512K tokens. BABILong [15] runs tasks qa1–qa5 at 128K, 256K, and 512K tokens. Video-MME [6], through lmms-eval [39], runs the 674 reasoning and synopsis questions on the long videos at 1024 and 2048 frames, about 113K and 225K visual tokens. At 512K tokens, and on v7x also at 256K, we extend RoPE with YaRN [21] at factor 2.
Metrics. Kernel benchmarks report the median time per call over 5 rounds of back-to-back calls. Softmax kernel throughput is FLOPs, halved for causal masks, divided by device time from a profiler trace. The roofline uses an idealized traffic model that reads , , and once and writes once, giving operational intensity FLOP/B for query heads and KV heads. We measure full attention blocks in wall-clock time. GDN throughput is tokens per second for the complete call, including the wrapper's XLA operations.
For RULER and BABILong we report prefill throughput, the number of prompt tokens divided by the wall-clock time of generation. For Video-MME we report the mean time of the language model prefill per question. For accuracy we report each benchmark's own score.

TPU v7x TensorCore, MHA (32:32)
TPU v7x TensorCore, GQA (32:4)

Figure 4: Kernel-only throughput of softmax attention, causal prefill with head dimension 256, B = 1, and 32 query heads. Rows are one v6e chip and one v7x TensorCore; columns are MHA (32:32) and GQA (32:4). The numbers under each length are the speedups of FlyWheel over each baseline.

Figure 5: The throughput of Figure 4 on the roofline of one TPU v6e chip and one v7x TensorCore, for 1K to 128K tokens in powers of two. Solid lines with circles are MHA (32:32) and dashed lines with triangles are GQA (32:4). The number at the end of each line is its throughput at 128K tokens.
4.2 Softmax Attention
Figure 4 shows the throughput and FlyWheel's speedup at every shape. From 2K to 128K tokens, FlyWheel is 3.11–3.49× faster than RPA-v3 under MHA and 1.50–1.73× under GQA on v6e, and 3.57–4.14× and 1.57–1.66× on v7x. Over the same range it is 1.10–1.56× faster than Splash-Attention on v6e and 1.18–1.80× on v7x.
Roofline. Figure 5 compares throughput against the roofline under the idealized traffic model of §4.1. The ridge points are 574 FLOP/B on v6e and 312 FLOP/B on v7x. MHA at 1K and 2K and GQA at 1K on v6e, and MHA at 1K on v7x, lie on the bandwidth-limited branch; for example, the roof is 410 TFLOP/s for MHA at 1K on v6e. FlyWheel reaches up to 81% of the roofline on v6e and 70% on v7x (744 and 802 TFLOP/s), compared with 73% and 59% for Splash-Attention and 53% and 43% for RPA-v3. From 4K onward, all tested shapes lie on the compute-limited branch of this idealized model.

(a) One sequence of T tokens per call.
(b) T tokens packed into 8 sequences of equal length per call.
Figure 6: Throughput of the fused causal conv1d and GDN prefill call, with 16 query/key heads and . Numbers under each length are FlyWheel's speedups over GDN-v3 on the same device. On v7x at , 64-row tiles fit in VMEM but can accommodate only a single chunk, preventing cross-chunk pipelining and resulting in a slight performance drop.
Independence from the KV head count. From 8K onward, FlyWheel's MHA and GQA throughputs differ by at most 1.2%, whereas RPA-v3's MHA throughput is less than half its GQA throughput. This is consistent with the layout constraints in §3.1: RPA-v3 pads the query-head group to a multiple of two, wasting half the rows under MHA (G = 1), and its all-head tiles shrink as the head count grows. FlyWheel's per-head token tiles avoid both constraints.
Splash-Attention also maps tokens to sublanes and reaches 668 TFLOP/s under both MHA and GQA at 128K on v6e. FlyWheel further improves throughput through computation and scheduling changes; §5.1 quantifies the contributions of the static anchor and fragment pipeline.
Attention block. The gains extend to the full attention block, including projections and layout conversions: under MHA on v6e, FlyWheel is faster than RPA-v3 at 1K and at 128K (Appendix B).
Other shapes. A sweep over batch sizes, head counts, and head dimensions (Appendix C) shows FlyWheel faster than both baselines in 785 of 792 cells, with throughput set by the total token count rather than the batch size.
4.3 Linear Attention
Figure 6 shows the GDN prefill throughput. On v6e, FlyWheel is 1.84–2.25× faster than GDN-v3 at 1K tokens, 2.45–3.10× at 4K, and 2.88–3.61× from 8K on. At , the shape of Qwen3.8-27B, it prefills 9.9M tokens/s at 16K against 3.0M for GDN-v3. On one v7x TensorCore it is 1.56–2.62× faster.
Layout work outside the kernel. GDN-v3 requires FP32 inputs in [T, 1, dim] layout, adding wrapper operations for upcasting, retiling, and output reshaping. FlyWheel directly uses the projection layouts (§3.2). At 8K on v6e, this change provides 1.52–1.68× speedup, with a further 2.04–2.10× from the three in-kernel designs (Table 3; §5.2).
The speedup grows with the sequence length. Both kernels scale approximately linearly with . On v6e at with one sequence, GDN-v3 costs 163 s per 1K tokens versus 45 s for FlyWheel; across , FlyWheel's per-token cost is 3.4–3.8 lower. Fixed overhead accounts for 7% of FlyWheel's time at 16K, explaining why speedup increases with sequence length. Packing 8 sequences adds tens of microseconds to both kernels, with FlyWheel retaining a 1.84–3.47 speedup on v6e (Figure 6b).
Comparison across TPU generations. For one sequence of 16K tokens, FlyWheel on a v6e chip is 2.3–2.6× faster than


(d) v7x: RULER prefill throughput
(e) v7x: BABILong prefill throughput

(f) v7x: Video-MME LLM prefill

Figure 7: Qwen3.8-27B in vLLM on v6e (top) and v7x (bottom). Numbers under each group are FlyWheel's speedups over the baseline. The v7x runs use 20 samples per RULER and BABILong task and 8 Video-MME questions.
GDN-v3 on a v7x TensorCore across , despite the latter's HBM bandwidth and peak FLOP/s (Table 1). At 16K and , FlyWheel uses 0.35 TB/s on v6e, about a fifth of its bandwidth. These results complement the ablations of layout and in-kernel overheads (Table 3). At , FlyWheel uses one 64-token chunk per tile to fit the 64 MiB VMEM of a v7x TensorCore and remains faster than GDN-v3 on the same device.
4.4 End-to-End Application
Figure 7 shows that the kernel improvements translate into application-level gains on both TPU generations, with larger speedups at longer contexts.
Text workloads on v6e. On RULER, FlyWheel's speedup increases from at 4K to at 128K and at 512K. BABILong improves by from 128K to 512K. This trend is consistent with softmax attention's growing share of prefill computation. From 32K to 256K on the v6e-8, baseline throughput falls by 21% (24.3K to 19.1K tokens/s), while FlyWheel retains 93% of its throughput (27.0K to 25.1K).
Video-MME. On v6e, FlyWheel reduces language model prefill time from 4.80 to 3.87 s at 1024 frames (1.24×) and from 11.60 to 9.00 s at 2048 frames (1.29×; Figure 7c). These prompts contain about 113K and 225K visual tokens, respectively; the gains are comparable to RULER's 1.23× and 1.31× speedups at 128K and 256K (Figure 7a).
Accuracy. On v6e, both runs achieve 100% accuracy on all evaluated RULER tasks and lengths and identical BABILong scores. On Video-MME, both score 70.62 at 2048 frames; at 1024 frames, they differ by one of the 674 questions (71.66 versus 71.51).
TPU v7x. On v7x, RULER speedup increases from at 4K to at 128K, at 256K, and at 512K, where throughput is 23.96K versus 17.70K tokens/s. BABILong improves by , , and at the same lengths. Video-MME prefill improves by at 1024 frames and at 2048 (4.07 to 3.53 s and 9.77 to 7.88 s). On the evaluated samples, both runs give identical Video-MME answers, mean RULER scores differ by at most 0.8 points, and BABILong scores match at 128K and 256K and differ by one point at 512K.
Table 2: Softmax attention ablations on v6e: causal prefill at 32K tokens, , and 32 query and KV heads. Time is kernel device time. All configurations use the same data layout; the ablations vary softmax computation and fragment scheduling.
| Configuration | Time (ms) | TFLOP/s |
|---|---|---|
| Static anchor, pipeline (FlyWheel) | 24.43 | 720 |
| Online softmax, pipeline | 30.21 | 582 |
| FA4 rescale, pipeline | 30.86 | 570 |
| Static anchor, no pipeline | 33.79 | 521 |
| Online softmax, no pipeline | 49.79 | 353 |
| with the LP LLO scheduler | 54.96 | 320 |
| FA4 rescale, no pipeline | 50.54 | 348 |
5 Ablation Study
We examine how FlyWheel’s designs address the three bottlenecks identified in §2.3: data layout and matrix operand reuse, vector work, and execution dependencies. The softmax ablations isolate computation and scheduling, while the GDN ablations evaluate all three aspects.
5.1 Softmax Attention
Table 2 compares the static-anchor softmax and fragment pipeline from §3.1. We replace the static anchor with either online softmax or FlashAttention-4’s conditional rescaling [38], which updates the running maximum only when the increase would scale the weights by more than . Without pipelining, each fragment executes , softmax, and consecutively.
Reducing vector work. With pipelining enabled, replacing online softmax with the static anchor increases throughput from 582 to 720 TFLOP/s. Conditional rescaling reaches 570 TFLOP/s with the pipeline and 348 TFLOP/s without it, compared with 582 and 353 TFLOP/s for online softmax. It retains the per-fragment maximum reduction and rescale-factor computation, while its branch adds register pressure. The static anchor removes these recurring operations and is 26% and 50% faster than conditional rescaling with and without pipelining, respectively.
Exposing independent work. The fragment pipeline increases static-anchor throughput from 521 to 720 TFLOP/s and online-softmax throughput from 353 to 582 TFLOP/s. Enabling Mosaic’s LP LLO scheduler, used by Splash-Attention by default, does not recover this overlap in the unpipelined online-softmax implementation: throughput decreases to 320 TFLOP/s. This result supports explicitly interleaving independent fragments rather than relying on compiler scheduling of the original dependent loop.
Together, reduced vector work and fragment pipelining increase throughput from 353 to 720 TFLOP/s. Both are necessary to reach the full kernel’s performance, which exceeds Splash-Attention’s 608 TFLOP/s by 18% on this shape (Figure 4).
5.2 Linear Attention
Table 3 incrementally adds FlyWheel’s designs to GDN-v3, yielding a total speedup of 3.19–3.53×. These measurements include wrapper operations and report each design’s additional benefit in the listed order, rather than its standalone contribution.
Coordinating layouts and reusing operands. Coordinated layouts provide 1.52–1.68× speedup by eliminating the wrapper’s HBM upcasting and retiling and producing output directly in the projection layout. Matrix operand reuse adds 1.06–1.22× by reducing repeated stationary-operand loads. These changes address both the surrounding data preparation and the efficiency of matrix execution.
Reducing vector work. Reformulating the triangular inverse and convolution as MXU computations adds 1.51–1.58× speedup, together with implementations of SiLU and normalization that each use one EUP operation. Along with coordinated layouts, this is one of the two largest incremental gains, exceeding 1.5× at every tested value-head count.
Overlapping independent computation. Explicit pipelining adds 1.13–1.25×, with the largest benefit at . Packing
Table 3: Incremental GDN ablations on v6e: fused causal conv1d and GDN prefill of 8K tokens in one sequence, with 16 query/key heads and . Each design row reports speedup over the preceding configuration; their product gives the total speedup, up to rounding. All designs are described in §3.2.
| Configuration / added design | |||
|---|---|---|---|
| 16 | 32 | 48 | |
| GDN-v3 time (ms) | 1.31 | 2.15 | 2.75 |
| Coordinated layouts | 1.52 | 1.68 | 1.59 |
| Matrix operand reuse | 1.06 | 1.22 | 1.16 |
| Reduced vector work | 1.58 | 1.51 | 1.56 |
| Explicit pipelining | 1.25 | 1.14 | 1.13 |
| Total speedup | 3.19 | 3.53 | 3.25 |
| FlyWheel time (ms) | 0.412 | 0.610 | 0.847 |
two heads per matrix operand load produces independent inverse chains: 8 chains at , and 16 and 24 chains at and 48. With fewer chains, more inverse latency remains exposed, so pipelining gains 25%, while operand reuse gains 6%. At larger head counts, the additional chains provide more independent work: pipelining gains 13–14%, while operand reuse gains 16–22%. The two incremental factors together contribute 1.31–1.39×, showing how operand reuse and scheduling address different limits as the available parallelism changes.
6 Related Work
Attention kernels on GPUs and other accelerators. FlashAttention [4] computes attention in one tiled kernel with online softmax [18]. Its successors split the work across warps [3], overlap the softmax of one warpgroup with the matmuls of another [24], and co-design the softmax and the pipeline for Blackwell [38]. Flash-Decoding [5] and FlashDecoding++ [8] split the KV sequence of a decode step, and FlashInfer [37] stores paged and ragged KV caches as block-sparse matrices. FuseMax [19] and MAS-Attention [25] overlap the matmuls and the softmax on a spatial accelerator and an edge NPU, whose matrix and vector engines run concurrently, as the warpgroups of a GPU do. A TensorCore issues both from one instruction stream (§2.3), so FlyWheel writes the overlap into the program order (§3).
Attention kernels on TPU. RPA-v3 [11], the softmax attention kernel of tpu-inference, serves prefill, decode, and mixed ragged batches. It puts heads on sublanes so that a sequence can start at any token, reads K and V from a paged cache that interleaves their heads, fuses the KV cache update into its DMA pipeline, and overlaps the and softmax of one KV head with the of the previous one; §3.1 discusses what this layout and this pipeline cost. Splash-Attention [20] puts tokens on sublanes like FlyWheel and runs online softmax over the K/V fragments; FlyWheel's gain over it comes from that loop (§5.1).
Softmax without the rescale. Several kernels replace the running maximum with a fixed value. FlashDecoding++ [8] takes one value per model from offline statistics of the scores, checks each score against a window around it, and recomputes the row with synchronized softmax when a score falls outside. VFA [28] sets each row's maximum from key-block summaries and the exact maxima of the first and the local block, then freezes it without a check. Splash-Attention accepts a constant maximum from the caller, also without a check. Concurrently with this work, Stashuk et al. [27] anchor each row of a causal training kernel on Blackwell at the maximum of its first key block, check each 128-row group, and recompute the failing tiles in a second launch. FlyWheel anchors each row on a score the row attains, so it needs no profile, key summary, or value from the caller. Its check tests no score: the FP32 sum that the kernel already keeps bounds every weight of the row, so one comparison per row certifies the row (§3.1), and a failing block is replayed within the same launch.
Chunked kernels for linear attention. Chunked prefill kernels for DeltaNet and GDN [35, 36] differ in how they invert the unit lower-triangular matrix of each chunk. FLA [34] inverts diagonal blocks by forward substitution and merges them with tensor-core matmuls, and GDN-v3 runs forward substitution on the VPU. Sobczyk et al. [26] invert with matmuls alone: a truncated Neumann series on diagonal blocks of 16 or 32 rows, merged by radix-2 doubling with FP32 products, with a proof of stability and kernels for Ascend NPUs. The Kimi Delta Attention (KDA) [29] kernel of Tokamax applies a Neumann series to diagonal blocks and again to the block-nilpotent remainder, on the TPU MXU with FP32 operands. FlyWheel's inverse is a radix-4 member of this family that replaces FP32-operand products with BF16 matmuls. Starting from 4 × 4 diagonal blocks, it avoids forming high powers of the full matrix and computes the inverse of a 64-token chunk using eight BF16 matmuls with FP32 accumulation. This design maintains comparable accuracy to the baseline on RULER and BABILong with Qwen3.8-27B (§4.4).
7 Conclusion
We present FlyWheel, TPU-native kernels for softmax and linear attention. FlyWheel combines operand reuse, reduced vector work, and explicit pipelining, with a checked static-anchor softmax and a BF16 triangular inverse as key computational designs. Evaluations on TPU v6e and v7x demonstrate kernel and application-level speedups while maintaining comparable model accuracy.
Acknowledgments
This work was supported by a 2026 Google TPU Research Award and the TPU Builders Program. The authors thank Josh Gordon, Lauren Jensen, Edgar Chen, Satha Kumar, Tasha Allen, Aditi Joshi, and the entire TPU Builders Support Team for their help with TPU onboarding.
References
[1] Joshua Ainslie, James Lee-Thorp, Michiel De Jong, Yury Zemlyanskiy, Federico Lebrón, and Sumit Sanghai. Gqa: Training generalized multi-query transformer models from multi-head checkpoints. In Proceedings of the 2023 conference on empirical methods in natural language processing, pages 4895–4901, 2023.
[2] James Bradbury, Roy Frostig, Peter Hawkins, Matthew James Johnson, Yash Katariya, Chris Leary, Dougal Maclaurin, George Necula, Adam Paszke, Jake VanderPlas, Skye Wanderman-Milne, and Qiao Zhang. JAX: composable transformations of Python+NumPy programs, 2018. URL http://github.com/jax-ml/jax.
[3] Tri Dao. Flashattention-2: Faster attention with better parallelism and work partitioning. In International Conference on Learning Representations, volume 2024, pages 35549–35562, 2024.
[4] Tri Dao, Dan Fu, Stefano Ermon, Atri Rudra, and Christopher Ré. Flashattention: Fast and memory-efficient exact attention with io-awareness. Advances in neural information processing systems, 35:16344–16359, 2022.
[5] Tri Dao, Daniel Haziza, Francisco Massa, and Grigory Sizov. Flash-decoding for long-context inference. https://crfm.stanford.edu/2023/10/12/flashdecoding.html, 2023.
[6] Chaoyou Fu, Yuhan Dai, Yongdong Luo, Lei Li, Shuhuai Ren, Renrui Zhang, Zihan Wang, Chenyu Zhou, Yunhang Shen, Mengdan Zhang, et al. Video-mme: The first-ever comprehensive evaluation benchmark of multi-modal llms in video analysis. In 2025 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 24108–24118. IEEE, 2025.
[7] Leo Gao, Jonathan Tow, Baber Abbasi, Stella Biderman, Sid Black, Anthony DiPofi, Charles Foster, Laurence Golding, Jeffrey Hsu, Alain Le Noac'h, Haonan Li, Kyle McDonell, Niklas Muennighoff, Chris Ociepa, Jason Phang, Laria Reynolds, Hailey Schoelkopf, Aviya Skowron, Lintang Sutawika, Eric Tang, Anish Thite, Ben Wang, Kevin Wang, and Andy Zou. The language model evaluation harness, 07 2024. URL https://zenodo.org/records/12608602.
[8] Ke Hong, Guohao Dai, Jiaming Xu, Qiuli Mao, Xiuhong Li, Jun Liu, Kangdi Chen, Yuhan Dong, and Yu Wang. Flashdecoding++: Faster large language model inference with asynchronization, flat gemm optimization, and heuristics. Proceedings of Machine Learning and Systems, 6:148–161, 2024.
[9] Cheng-Ping Hsieh, Simeng Sun, Samuel Kriman, Shantanu Acharya, Dima Rekesh, Fei Jia, Yang Zhang, and Boris Ginsburg. Ruler: What's the real context size of your long-context language models? arXiv preprint arXiv:2404.06654, 2024.
[10] Alec Ibarra, Cam Quilici, Bryan Shan, et al. TPU inference externalization full steam ahead: InferenceX. SemiAnalysis, https://newsletter.semianalysis.com/p/tpu-inferencex-full-steam, 2026.
[11] Jevin Jiang, Ying Chen, Blake A Hechtman, Fenghui Zhang, and Yarong Mu. Ragged paged attention: A high-performance and flexible llm inference kernel for tpu. arXiv preprint arXiv:2604.15464, 2026.
[12] Norman P Jouppi, Doe Hyun Yoon, George Kurian, Sheng Li, Nishant Patil, James Laudon, Cliff Young, and David Patterson. A domain-specific supercomputer for training deep neural networks. Communications of the ACM, 63(7): 67–78, 2020.
[13] Norman P Jouppi, Sridhar Lakshmanamurthy, Cliff Young, and David Patterson. Google’s training supercomputers from tpuv2 to ironwood: Architectural stability, scale, resilience, power efficiency, and sustainability across five generations. IEEE Micro, 2026.
[14] Angelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas, and François Fleuret. Transformers are rnns: Fast autoregressive transformers with linear attention. In International conference on machine learning, pages 5156–5165. PMLR, 2020.
[15] Yuri Kuratov, Aydar Bulatov, Petr Anokhin, Ivan Rodkin, Dmitry Sorokin, Artyom Sorokin, and Mikhail Burtsev. Babilong: Testing the limits of llms with long context reasoning-in-a-haystack. Advances in Neural Information Processing Systems, 37:106519–106554, 2024.
[16] Woosuk Kwon, Zhuohan Li, Siyuan Zhuang, Ying Sheng, Lianmin Zheng, Cody Hao Yu, Joseph Gonzalez, Hao Zhang, and Ion Stoica. Efficient memory management for large language model serving with pagedattention. In Proceedings of the 29th symposium on operating systems principles, pages 611–626, 2023.
[17] Ze-Wei Liou, Harris Nover, Amey Naik, Andrii Skliar, Igor Shovkun, Ido Shahaf, and Tri Dao. Replayssm: Cache ssm inputs, not state, 2026. URL https://arxiv.org/abs/2610.13778.
[18] Maxim Milakov and Natalia Gimelshein. Online normalizer calculation for softmax. arXiv preprint arXiv:1805.02867, 2018.
[19] Nandeeka Nayak, Xinrui Wu, Toluwanimi O Odemuyiwa, Michael Pellauer, Joel S Emer, and Christopher W Fletcher. Fusemax: Leveraging extended einsums to optimize attention accelerator design. In 2024 57th IEEE/ACM International Symposium on Microarchitecture (MICRO), pages 1458–1473. IEEE, 2024.
[20] OpenXLA. Tokamax: a library of custom accelerator kernels. https://github.com/openxla/tokamax, 2026.
[21] Bowen Peng, Jeffrey Quesnelle, Honglu Fan, and Enrico Shippole. Yarn: Efficient context window extension of large language models. In International Conference on Learning Representations, volume 2024, pages 31932–31951, 2024.
[22] Qwen Team. Qwen3.8-Max: A new bar for coding and cowork, August 2026. URL https://qwen.ai/blog?id=qwen3.8.
[23] Imanol Schlag, Kazuki Irie, and Jürgen Schmidhuber. Linear transformers are secretly fast weight programmers. In International conference on machine learning, pages 9355–9366. PMLR, 2021.
[24] Jay Shah, Ganesh Bikshandi, Ying Zhang, Vijay Thakkar, Pradeep Ramani, and Tri Dao. Flashattention-3: Fast and accurate attention with asynchrony and low-precision. Advances in Neural Information Processing Systems, 37: 68658–68685, 2024.
[25] Mohammadali Shakerdargah, Shan Lu, Chao Gao, and Di Niu. Mas-attention: Memory-aware stream processing for attention acceleration on resource-constrained edge devices. Proceedings of Machine Learning and Systems, 7, 2025.
[26] Aleksandros Sobczyk, Gioele Gottardo, Christos K Matzoros, Mirko De Vita, Filip Skogh, Anastasios Zouzias, and Jiawei Zhuang. Fast and stable triangular inversion for delta-rule linear transformers. arXiv preprint arXiv:2605.21325, 2026.
[27] Oleksandr Stashuk, Hongtao Yu, and Jay Shah. Efficient flashattention on blackwell via fixed-shift softmax and persistent scheduling. arXiv preprint arXiv:2610.02229, 2026.
[28] Yupeng Sun, Yanzhao Li, Zhiqiang Zou, Bai Du, Zhiyuan Zhang, Hui Dong, Gaoyige Fan, and Hui Wang. Vfa: Relieving vector operations in flash attention with global maximum pre-computation. arXiv preprint arXiv:2604.12798, 2026.
[29] Kimi Team, Yu Zhang, Zongyu Lin, Xingcheng Yao, Jiaxi Hu, Fanqing Meng, Chengyin Liu, Xin Men, Songlin Yang, Zhiyuan Li, et al. Kimi linear: An expressive, efficient attention architecture. arXiv preprint arXiv:2510.26692, 2025.
[30] The JAX Authors. Pallas: a JAX kernel language. https://docs.jax.dev/en/latest/pallas/index.html, 2026.
[31] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. Advances in neural information processing systems, 30, 2017.
[32] vLLM Project. tpu-inference: TPU backend for vLLM. https://github.com/vllm-project/tpu-inference, 2026.
[33] vLLM Project. vLLM TorchTPU. https://github.com/vllm-project/vllm-torchtpu, 2026.
[34] Songlin Yang and Yu Zhang. Fla: A triton-based library for hardware-efficient implementations of linear attention mechanism, January 2024. URL https://github.com/fla-org/flash-linear-attention.
[35] Songlin Yang, Bailin Wang, Yu Zhang, Yikang Shen, and Yoon Kim. Parallelizing linear transformers with the delta rule over sequence length. Advances in neural information processing systems, 37:115491–115522, 2024.
[36] Songlin Yang, Jan Kautz, and Ali Hatamizadeh. Gated delta networks: Improving mamba2 with delta rule. In International Conference on Learning Representations, volume 2025, pages 29687–29707, 2025.
[37] Zihao Ye, Lequn Chen, Ruihang Lai, Wuwei Lin, Yineng Zhang, Stephanie Wang, Tianqi Chen, Baris Kasikci, Vinod Grover, Arvind Krishnamurthy, et al. Flashinfer: Efficient and customizable attention engine for llm inference serving. Proceedings of Machine Learning and Systems, 7, 2025.
[38] Ted Zadouri, Markus Hoehnerbach, Jay Shah, Vijay Thakkar, and Tri Dao. Flashattention-4: Algorithm and kernel pipelining co-design for asymmetric hardware scaling. Proceedings of Machine Learning and Systems, 8:912–926, 2026.
[39] Kaichen Zhang, Bo Li, Peiyuan Zhang, Fanyi Pu, Joshua Adrian Cahyono, Kairui Hu, Shuai Liu, Yuanhan Zhang, Jingkang Yang, Chunyuan Li, et al. Lmms-eval: Reality check on the evaluation of large multimodal models. In Findings of the Association for Computational Linguistics: NAACL 2025, pages 881–916, 2025.
A Reference Attention Algorithms
Algorithms 5 and 6 provide mathematical reference formulations for the two attention computations in §2. They expose the online rescaling and triangular substitution replaced by FlyWheel; they do not reproduce the full scheduling or implementation details of a particular library. Both algorithms show one head, omit the attention scaling and GDN decay factors as in the main text, and assume complete tiles for clarity. SCORES includes causal masking, with at least one valid key per query row in the first key tile. Row-wise vectors are broadcast across columns where required.
Algorithm 5 FlashAttention reference: blockwise online softmax
Require: Ensure:
1: for each query tile do 2: Partition keys and values into 3: 4: ; 5: ; 6: for do 7: 8: 9: ; 10: 11: 12: 13: end for 14: 15: end for 16: return
Relation to FlyWheel softmax. Algorithm 5 follows the blockwise online-softmax computation used by FlashAttention [4, 18]. For a query tile with rows and key tile with rows, , , and . Each fragment updates the maximum and rescales the previous accumulators. Algorithm 1 replaces these repeated updates with a checked fixed anchor and pipelines independent fragment computation; Algorithm 2 supplies its fallback.
Algorithm 6 Chunked GDN reference with forward substitution
Require: , ; coefficients ; state Ensure: and updated state
1: Partition inputs into chunks of tokens 2: for each chunk do 3: 4: 5: 6: 7: for do 8: 9: end for 10: 11: 12: 13: end for 14: return
Relation to FlyWheel GDN. Algorithm 6 implements the chunked recurrence of Eq. 4 [35, 36], with inputs after convolution, SiLU, and query/key normalization. Forward substitution constructs one row at a time; is a scalar matrix entry. Algorithm 3 instead combines products sharing an operand and uses the matrix-based inverse in Algorithm 4. Its implementation additionally overlaps chunk-local work with state-dependent updates, as described in §3.2.
B Softmax Attention Block Time

Figure 8: Softmax attention block time on one v6e chip, from hidden states to hidden states (), causal prefill with head dimension 256, , and 32 query heads, split by segment and normalized to the slowest block of each group. Panels are MHA (32:32) and GQA (32:4). R, S, and F are RPA-v3, Splash-Attention, and FlyWheel; the numbers under each length are the wall-clock speedups of FlyWheel's block over each baseline.
Figure 8 splits the time of the attention block on v6e (§4.1) into the QKV projection, the layout work, the kernel, and the output projection. FlyWheel and Splash-Attention need no layout work: the projections write and the output projection reads it (§3.1). RPA-v3 reads K and V from a paged cache that interleaves heads, so its block concatenates and transposes them before the kernel, which costs 0.25 ms at 1K and 33.7 ms at 128K under MHA. FlyWheel's block is 1.48× faster than RPA-v3's at 1K and 2.95× at 128K under MHA (466 against 1371 ms), and 1.41–1.76× under GQA. The speedup grows with the length because the projections are linear in and attention is quadratic: attention is 3% of the block's FLOPs at 1K and 80% at 128K, and FlyWheel's kernel takes 8% of its MHA block time at 1K and 80% at 128K. The layout work therefore sets 65% of the MHA gap at 1K, and the kernel sets 96% of it at 128K. On v7x the block speedups over RPA-v3 are 1.50–3.62× under MHA and 1.29–1.55× under GQA. Splash-Attention does no layout work either, so FlyWheel's block speedup over it is smaller: 1.01–1.15× from 2K on. At 1K, where the projections take about 90% of either block, Splash-Attention's block is 4% faster.
C The Full Workload Grid
The kernel measurements of §4.2 fix , , , and . To check that the comparison does not depend on that choice, we sweep the Cartesian product of , , every from down to 1 in powers of two, , and , keeping the cells with : 2376 measurements over 22 head configurations (batch, length) cells implementations, on one v6e chip, causal, BF16. Throughput follows §4.1 – the kernel figures divide the analytic FLOPs by the Pallas call's device time in a profiler trace, the block figures divide the block's FLOPs, projections included, by its wall clock.
Across the grid. The advantage of §4.2 does not depend on the shape it was measured at. FlyWheel's kernel is faster than both baselines in 785 of the 792 cells, by a median of 1.30×, and in all 330 cells from 8K tokens on, by a median of 1.24× and never by less than 1.12×. The seven exceptions are all at with , where FlyWheel stays within 9% of Splash-Attention. Neither the KV head count nor the batch size changes the picture: in Figure 9 the panels are blue throughout.
Utilization. Figure 10 gives the absolute level behind those ratios. At and , FlyWheel holds 70–83% of the BF16 peak, with a median of 77%, against 51–72% for Splash-Attention and 22–54% for RPA-v3.² At every kernel drops by roughly half, to 38–44%, 29–39%, and 12–30%: halving the head dimension halves the arithmetic intensity of the matrix products but not the softmax between them. The ordering is unchanged.
Independence from the batch size. Comparing each cell's kernel throughput with the same head configuration and length at gives 616 ratios with a median deviation of 1.0% and a 90th percentile of 3.4%. Only 27 exceed 5%, and 24 of
²The grid was measured at a different time from Figure 4, so cells shared by both differ slightly because of run-to-run variation.

Figure 9: FlyWheel's kernel throughput over the faster of RPA-v3 and Splash-Attention on one v6e chip, at every cell of the grid: 22 combinations of query heads , KV heads , and head dimension , each swept over 8 batch sizes and 8 sequence lengths with . Blue is FlyWheel ahead, red behind. Columns share a KV head count, so the slots are empty for ; the pale corner of each panel is the part of the rectangle the token budget excludes.

Figure 10: Kernel utilization of the v6e BF16 peak over the same grid. Each line is the median across all KV head counts and batch sizes at that length, and the band is their full range. RPA-v3's band is wide because its throughput depends on the KV head count (§4.2); FlyWheel's and Splash-Attention's are narrow.
those are at , where one sequence does not fill the kernel's 2048-row query block (Appendix E). Throughput is thus a function of the total token count, not of its division into sequences, which is why in §4.2 represents the rest of the grid.
D Decode
FlyWheel serves decode over a paged KV cache with the same kernel design as prefill: each row accumulates against the checked static anchor of §3.1, and the fragments of a staged KV block are software-pipelined, so one fragment's overlaps the next fragment's and exponentials. A decode step has one query row per head, so the cache read, not the matrix work, bounds it. As in RPA-v3 [11], FlyWheel pads each staged token to an odd number of 32-bit word rows, so the eight sublanes of a strided load fall in different VMEM banks, and scores several KV heads through one 8-row query tile, so the softmax state of a head group fills whole registers instead of one row each. Beyond RPA-v3, FlyWheel implements ReplaySSM [17] decode for GDN and KDA on the TPU, and supports FP8 KV caches. On v7x, FlyWheel's decode is up to 1.14× faster than RPA-v3 and its speculative verify up to 1.62× faster than Batched-RPA; on v6e, ReplaySSM speeds up GDN decode by up to 2.32× and 4-token verify by up to 3.72×.
BF16 decode. On a v7x TensorCore, FlyWheel reads the cache at 3.20–3.36 TB/s, 86–91% of the 3.7 TB/s HBM peak, against 2.95–3.23 TB/s for RPA-v3, and is up to 1.14× faster (Table 4). The gain is largest under MHA, where each KV head has a single query row and the shared query tile matters most: per 512-token block, FlyWheel's loop compiles to 5223 bundles, against more than 6600 for RPA-v3's. On v6e, whose 1.6 TB/s of HBM bandwidth is less than half of v7x's (Table 1), the cache read bounds the step for both kernels, and they are equally fast.
Table 4: BF16 decode against RPA-v3 on one v7x TensorCore: 32 query heads, , 128-token pages, 15K cached tokens per sequence followed by 1024 decode steps. Time is ms per step.
| Sequences | RPA-v3 | FlyWheel | Speedup | |
|---|---|---|---|---|
| 32:4 | 256 | 5.148 | 5.023 | 1.02× |
| 32:4 | 128 | 2.574 | 2.519 | 1.02× |
| 32:4 | 32 | 0.660 | 0.649 | 1.02× |
| 32:32 | 128 | 22.426 | 19.875 | 1.13× |
| 32:32 | 32 | 5.645 | 4.950 | 1.14× |
Speculative verify. Speculative decoding verifies the draft tokens of each request in one call. FlyWheel runs a verify window of up to 16 tokens on the decode kernel and folds the window into the query heads: window token of query head becomes one more query row of 's KV head, with a bottom-right causal bound. Every window token reuses the same staged K/V block, so the cache read, which bounds the step, does not grow with the window: on v6e, from to FlyWheel's step grows by 0–6%, against 11–33% for Batched-RPA. vLLM TorchTPU [33] verifies with Batched-RPA, which runs a window of tokens as a decode query of rows. RPA-v3 instead sends a window to its mixed prefill path, which pads it to a full query block and takes 3.8–4.4× the time of Batched-RPA at , so we compare with Batched-RPA (Table 5). At , FlyWheel is 1.10–1.28× faster than Batched-RPA on v6e and 1.17–1.62× on v7x, and on v7x it leads already at , by 1.12–1.47×.
FP8 KV cache. An FP8 cache stores K and V in float8_e4m3fn or float8_e5m2 with one descale per tensor, as in FlashAttention-3 [24]. A 32-bit word holds the (K, K, V, V) bytes of a head pair, so the cache keeps the BF16 interleave at head-pair granularity. The MXU multiplies the BF16 query by the FP8 keys and values directly; the K descale folds into the query's scale and the V descale into the softmax normalization. Both descales are runtime values, so layers with different scales share one compiled kernel. On v6e, FP8 halves the step of FlyWheel's BF16 decode, 1.98× and 1.97× faster at batch 32 and 128 (0.979 to 0.495 ms and 3.900 to 1.979 ms), and matches RPA-v3's FP8 decode (Table 6).
Linear attention decode with ReplaySSM. ReplaySSM [17] keeps each sequence's recurrent state as a checkpoint plus the inputs of up to W recent tokens. A decode step computes its output from the checkpoint and the buffered inputs without materializing the state, and writes the checkpoint only when the buffer overflows; a verify step commits the accepted tokens by advancing the buffer length. FlyWheel fuses this step with the causal conv1d. It folds the buffers of a tile's overflowing sequences into new checkpoints with one FP32 matmul issued halfway through the tile, so the checkpoint DMAs overlap the other sequences' compute. It stores the FP32 checkpoint as two 16-bit planes: a decode step
Table 5: Speculative verify against Batched-RPA: 32 query and 8 KV heads, , 128-token pages, a window of tokens per request. Time is ms per verify step, with JAX 0.11.0 and libtpu 0.0.44.
| Cached | Batch | v6e chip | v7x TensorCore | |||||
|---|---|---|---|---|---|---|---|---|
| FlyWheel | Batched-RPA | Speedup | FlyWheel | Batched-RPA | Speedup | |||
| 2048 | 32 | 1 | 0.245 | 0.249 | 1.02× | 0.103 | 0.151 | 1.47× |
| 4 | 0.249 | 0.260 | 1.04× | 0.153 | 0.150 | 0.98× | ||
| 16 | 0.259 | 0.332 | 1.28× | 0.200 | 0.240 | 1.20× | ||
| 2048 | 128 | 1 | 0.982 | 0.991 | 1.01× | 0.381 | 0.442 | 1.16× |
| 4 | 0.997 | 1.020 | 1.02× | 0.567 | 0.457 | 0.81× | ||
| 16 | 1.032 | 1.154 | 1.12× | 0.693 | 0.812 | 1.17× | ||
| 8192 | 32 | 1 | 0.979 | 0.980 | 1.00× | 0.368 | 0.438 | 1.19× |
| 4 | 0.981 | 1.006 | 1.03× | 0.384 | 0.457 | 1.19× | ||
| 16 | 0.989 | 1.096 | 1.11× | 0.483 | 0.784 | 1.62× | ||
| 8192 | 128 | 1 | 3.900 | 3.872 | 0.99× | 1.429 | 1.594 | 1.12× |
| 4 | 3.865 | 3.934 | 1.02× | 1.481 | 1.693 | 1.14× | ||
| 16 | 3.904 | 4.302 | 1.10× | 1.858 | 2.999 | 1.61× | ||
Table 6: FP8 decode against RPA-v3 on one v6e chip: 32 query and 8 KV heads, , 8K cached tokens per sequence. Time is ms per call.
| Batch | FlyWheel e4m3fn | FlyWheel e5m2 | RPA-v3 e4m3fn |
|---|---|---|---|
| 32 | 0.495 | 0.494 | 0.489 |
| 128 | 1.979 | 1.973 | 1.954 |
reads only the high plane, the BF16 value its matmul consumes, and a flush rebuilds the FP32 value bit for bit. Table 7 compares with FlyWheel's conventional decode kernel, which reads and writes the full state at every step and runs at the speed of GDN-v3. ReplaySSM is 1.77–2.32× faster on decode and 3.26–3.72× on 4-token verify for GDN, and 1.89–2.17× and 2.91–3.43× for KDA. The gain is largest on verify: a conventional kernel writes a recurrent state for every window position, whereas ReplaySSM commits the window by advancing the buffer length.
Table 7: ReplaySSM decode on one v6e chip: 16 query/key heads, 32 value heads, , , BF16 buffered inputs. Conv. is FlyWheel's conventional decode kernel. Time is ms per call; verify-4 checks 4 tokens per sequence.
| Step | Batch | GDN | KDA | ||||
|---|---|---|---|---|---|---|---|
| Conv. | ReplaySSM | Speedup | Conv. | ReplaySSM | Speedup | ||
| Decode | 16 | 0.101 | 0.057 | 1.77× | 0.105 | 0.055 | 1.91× |
| 64 | 0.264 | 0.114 | 2.32× | 0.267 | 0.123 | 2.17× | |
| 128 | 0.478 | 0.207 | 2.31× | 0.478 | 0.249 | 1.92× | |
| 256 | 0.940 | 0.447 | 2.10× | 0.944 | 0.500 | 1.89× | |
| Verify-4 | 16 | 0.189 | 0.058 | 3.26× | 0.205 | 0.065 | 3.15× |
| 64 | 0.667 | 0.181 | 3.69× | 0.670 | 0.230 | 2.91× | |
| 128 | 1.324 | 0.357 | 3.71× | 1.326 | 0.387 | 3.43× | |
| 256 | 2.657 | 0.715 | 3.72× | 2.675 | 0.779 | 3.43× | |
E Additional Implementation Details
Softmax fragments. The implementation uses exp2, folding and the attention scaling factor into before the fragment loop. A block contains 32 fragments of 256 query rows and 512 key rows. The loop is unrolled into one compiler basic block; when a block contains multiple heads, the final fragment of one head overlaps the first of the next. The previous fragment's weights remain live until its output product completes, and the final output product drains the pipeline.
GDN matrix execution. The kernel transposes once on the XLU and reuses the result in both stacked products. The hierarchical inverse uses two products for the base blocks and three per merge. On a repeated-key test at , its maximum absolute error relative to FP64 is . Convolution and normalization complete before the cross-chunk pipeline, whose independent work is exposed within one compiler basic block.
Convolution and vector operations. Unused trailing rows of the tap-scaled copies in hold the preceding chunk's halo. For and , the convolution's contraction dimension is 256. The selector is labeled in Figure 3b and is distinct from the recurrent state. The remaining vector operations use
Here . Table 3 measures their combined benefit with the inverse and convolution reformulations.
Kimi Delta Attention. For KDA's per-channel decay, FlyWheel factors decay across intermediate block boundaries and incorporates it into masked matrix products. The resulting inverse uses ten matrix multiplications and follows the same principle of overlapping chunk-local computation with state-dependent work from another chunk.