FP8 attention that keeps FlashAttention-3 throughput at BF16-level accuracy
On this page14 sections
Difficulty 40, highest of the attention kernels: it needs numerics research (outlier-robust scaling of Q and K on real activations) on top of kernel work, comparable to the parked FP8 accumulator-width question (35.5). Application value 48: would make FP8 attention usable where BF16 accuracy is required. Leverage 27: shapes FP8 inference stacks without gating other results.
The problem
Can attention run in 8-bit numbers at full speed without losing accuracy on real model data?
- 18-bit attention is fast but less accurate
- 2Real models have outlier channels
- 3Rotate and scale before rounding
- 4Test on captured real activations
- 5Near-8-bit speed, near-16-bit accuracy
What is asked. Running attention in FP8 (8-bit floating point) roughly doubles the matrix-multiply rate on an H100 compared with 16-bit BF16, but each number keeps only about one significant decimal digit. FlashAttention-3 already has an FP8 forward kernel. The problem asks for an FP8 attention kernel that keeps at least 95% of FlashAttention-3's FP8 speed (head dimension 128, 8192 tokens). Its error, measured against a 32-bit reference, must be no more than twice that of FlashAttention-3 in BF16. The test inputs are not random numbers but query, key and value tensors captured from named open-weights language models.
Why real data is the barrier. Before rounding to FP8, a block of numbers is multiplied by a scale factor so that its largest value lands near the top of the format's range (448 for E4M3): . If a block contains one outlier, say a value of 300 among values near 1, the scale is set by the 300. The ordinary values are then squeezed into the bottom few representable steps and lose most of their precision. A ruler marked only every 10 cm measures a 3 m plank fine but a 2 cm screw badly. Real language models are known to have such outlier channels. The analogy breaks because the kernel can change the data before measuring it. FlashAttention-3 multiplies and by a random orthogonal matrix (a rotation, which preserves dot products: ). The rotation spreads an outlier's size across many entries, which a ruler cannot do to a plank.
State of the art. FlashAttention-3's paper reports FP8 forward close to 1.2 PFLOP/s, and 2.6 times lower error than a baseline FP8 attention, using block-wise scales and this rotation trick ("incoherent processing"). Its error is still larger than BF16 attention. That comparison used random Gaussian-like inputs plus a test with injected outliers, not activations captured from production models, so how FP8 attention behaves on real activations is an open measurement question. The FP8 backward pass is not covered.
What a solution looks like. A public kernel, the captured test tensors (or a script to capture them) and an error report. A second party reruns them and confirms both bounds: at least 95% of FlashAttention-3 FP8 speed, and at most twice its BF16 error.
Go deeper
The full technical text.
Design an FP8 attention forward kernel for H100 whose throughput is at least 95% of FlashAttention-3's FP8 forward for head dimension 128 and sequence 8192, and whose output error against an FP32 reference is no larger than that of FlashAttention-3 BF16 multiplied by 2, on activations with realistic outlier structure (the test tensors are captured from named open-weights models, listed in the spec).
Words on this page (9)
- FP8
- An 8-bit floating-point format; E4M3 keeps more precision, E5M2 more range.
- attention
- The transformer operation in which each token takes a weighted average of other tokens, with weights from a softmax of similarity scores.
- FlashAttention
- A family of attention kernels that compute exact attention tile by tile without storing the full score matrix.
- scale factor
- A multiplier applied before rounding to a narrow format so values fit its range, divided out afterwards.
- outlier
- A value far larger in size than most others in the same set.
- rounding error
- The difference between a true value and the nearest number the format can store.
- minifloat
- A floating-point number with very few bits (16, 8, 6 or 4), trading precision and range for speed.
- Hopper (H100)
- NVIDIA's 2022 data-centre GPU generation; the H100 is its main chip.
- kernel (GPU)
- A function that runs on the GPU, executed by thousands of threads in parallel.
New to this? Read first (3)
- FlashAttention-2 (Stanford CRFM blog)Plain-language account of why attention is memory-bound and how tiling helps.
- Floating-point arithmetic (Wikipedia)Background on how computers store non-whole numbers.
- Minifloat (Wikipedia)What 8-bit and smaller floating-point formats look like.
Path to understanding
foundations → problemThe research entries this problem rests on, in the order to read them. Each links to its explainer.
- Start with
- Step 2
- Step 3
- FlashAttention: IO-aware exact attentionAlgorithm · host
- Then
- FP8 attention that keeps FlashAttention-3 throughput at BF16-level accuracyThe problem
State of the art
FlashAttention-3's abstract reports FP8 forward close to 1.2 PFLOP/s and 2.6x lower numerical error than a baseline FP8 attention, using block quantisation and incoherent processing (random orthogonal transforms to spread outliers). The error remains larger than BF16 attention, and that statement is about random Gaussian-like inputs plus an outlier-injected test; behaviour on activations captured from specific production models is an open measurement question. FP8 backward attention is not covered by the FlashAttention-3 FP8 results.
Realistic applications
FP8 attention would roughly double attention tensor-core throughput on Hopper and relieve KV-cache bandwidth when K and V are stored in FP8.
What counts as solved
A public kernel and error report from captured activations of the listed models that meets both bounds, rerun by a second party.
How it gets verified
To verify: GPU benchmarkA kernel run and timed on stated hardware against a baseline.
Hardware: one H100 SXM 80 GB. Dtypes: Q, K, V in E4M3, FP32 softmax statistics, BF16 output. Shapes: head dim 128, sequence 8192, causal and non-causal, 32 heads, total tokens near 16384. Inputs: Q, K, V activations from layer 0, 15 and last layer of two named open-weights LLMs on a fixed 8k-token text sample, plus the synthetic outlier test of the FlashAttention-3 paper. Baselines: FlashAttention-3 FP8 and BF16 forward at a pinned commit. Metric: TFLOP/s median over at least 100 iterations; RMSE and max error versus an FP32 reference. Correctness bound as in the statement. Harness: public script and captured tensors (or capture script) at a pinned commit.
Claims
No claimed results on this problem.
Where the work is
A mix of numerics design and kernel work, with an empirical component from capturing activations of real models.
Connected problems
- This problem is related to FP8 GEMM with FP32-accumulation accuracy at long K without a throughput penaltyBoth trade FP8 throughput against accumulation and scaling error.