Undergraduate Honors Research Thesis, The Ohio State University, 2026
FlashStieltjes: Fast and Memory-Efficient Flash-Style Attention with Algebraic Normalization
TL;DR
FlashStieltjes is my honors thesis at Ohio State. It is a GPU kernel for Stieltjes attention, which weighs keys with a power law where softmax uses an exponential. It is written in Triton in the style of FlashAttention and never builds the N×N attention matrix. On an A100 its forward pass ran 3.37× faster (geometric mean over the benchmarked shapes) than a PyTorch reference implementation of the same attention.
Why touch softmax
Nearly every Transformer turns attention scores into weights with softmax. But softmax is only one of many functions that take a list of scores and return positive numbers that add up to 1. It does so with an exponential: every step down in score shrinks the weight by the same factor.
Stieltjes attention uses a different rule:
Here is the score of key , the order controls how sharp the attention is, and (the “pole”) sits above the best score. Every key is weighed by how far its score is from the pole, and the pole is placed so that all the weights add up to exactly 1. The weights now fall off like a power law. In this example the top two keys get more weight than under softmax, and so does the far tail: the lowest key gets about 380 times more.
Data table
| Score gap | Softmax | Stieltjes, q = 4 |
|---|---|---|
| 0 | 0.221 | 0.457 |
| 1 | 0.081 | 0.041 |
| 2 | 0.030 | 0.009 |
| 4 | 0.004 | 0.001 |
| 8 | 7.4 × 10⁻⁵ | 1.4 × 10⁻⁴ |
| 12 | 1.4 × 10⁻⁶ | 3.3 × 10⁻⁵ |
| 15.75 | 3.2 × 10⁻⁸ | 1.2 × 10⁻⁵ |
The challenge
Softmax can be computed in a single pass over the keys: keep a running maximum and a running sum of exponentials, and divide at the end. This is the online softmax of Milakov and Gimelshein, and FlashAttention is built on it. Stieltjes attention has no such decomposition. The pole depends on every score in the row at once, so it has to be found by solving an equation for each row.
I solve it with Newton-Raphson. After subtracting each row’s largest score, every row starts from the same guess of 1.1. On synthetic scores it reaches single-precision accuracy in 2-3 steps for , and the kernel runs three steps by default.
The kernel
The reference way to compute attention builds a table of all N×N scores, and at long sequences that table takes up most of the memory. A flash-style kernel keeps one block of queries in the GPU’s on-chip memory and streams the keys past it in tiles instead. Since Stieltjes attention cannot finish in one pass, FlashStieltjes streams them five times:
Memory now grows with the sequence length and not with its square.
Results
To see what swapping softmax out does to accuracy, I trained six-layer nanoGPT models (about 23M parameters) on four algorithmic tasks: binary search, finding the maximum, BFS, and sorting. In my runs with set to 2 or 4, Stieltjes attention scored within 0.005 of softmax on every task.
See more
FlashStieltjes is one piece of a larger ongoing project on Stieltjes attention with Jack Taylor, Tarun Kathuria, and my advisor Sachin Kumar.