ThriftAttention: Selective Mixed Precision for Long-Context FP4 Attention

Joe Sharratt
5/21/2026
4 citations
cs.LG

Official code: joesharratt1229/ThriftAttention (22 stars, Cuda, Apache-2.0, last commit 2026-09-24).

Abstract

Efficient attention algorithms are critical to mitigate the quadratic cost of attention in long-context workloads. Prior work utilises block-scaled quantisation techniques on Blackwell GPUs to move attention computation to 4-bit precision to accelerate inference.

Show full abstract

However, these techniques result in significant quality degradation in long-context settings. We show that the output impact of quantisation error is highly non-uniform and increases with the importance of each query-key interaction, concentrating functionally relevant error in a small number of attention blocks that contain the most important tokens. We propose ThriftAttention, a low-bit attention variant that delivers near-FP16 long-context quality at FP4 inference efficiency. This approach proceeds in two stages. First, a heuristic rapidly selects a small number of important query-key block pairs for FP16 precision. Second, the selected blocks are computed in FP16 and the remaining blocks in FP4, with both paths merged via online softmax into a single output. We demonstrate across long-context benchmarks and model families that by computing only 5% of query-key blocks in FP16, ThriftAttention recovers on average 89.1% of the FP4-to-FP16 performance gap. We show ThriftAttention's advantage grows with sequence length, mitigating the systematic FP4 quality degradation observed at longer contexts. The code is available at https://github.com/joesharratt1229/ThriftAttention.

View on arXivView PDF

Code Implementations(1)

Apache-2.0
228Cuda, PythonMay 11, 20262 months agoApache-2.0

Similar Papers

Cite this paper

@article{sharratt2026thriftattention,
  title  = {ThriftAttention: Selective Mixed Precision for Long-Context FP4 Attention},
  author = {Joe Sharratt},
  year   = {2026},
  eprint = {2605.23081},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2605.23081v1}
}

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

Discussion