Manuscript Offprint

arXiv:2611.03344

FLAMIA: FLAsh MIcroscaling Attention for Fast and Causally Safe Training on Blackwell

Fedor Velikonivtsev, Mikhail Koltakov, Denis Kuznedelev

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Attention remains a substantial computational cost in Transformer training, particularly at long context lengths. NVIDIA Blackwell GPUs provide high-throughput low-precision matrix multiplication, but exploiting it in attention requires addressing quantization overhead, causal information leakage through shared scales, and numerical inconsistencies between the forward and backward passes. We present FLAMIA, a family of attention kernels for Blackwell with MXFP8 and mixed NVFP4/FP8 training paths. Our design combines token-block scaling that reuses quantized operands across matrix orientations, targeted safeguards against scale-induced leakage, and consistent forward and backward computations. Fused quantization and architecture-specific kernel optimizations reduce overhead, while document-local scaling and workload-aware scheduling support variable-length documents directly in packed layouts without repacking. Across various causal packed-document workloads, the MXFP8 path accelerates the combined forward and backward attention call, including quantization, by factors of 1.10–1.40× on B200 and 1.06–1.42× on B300 relative to the fastest evaluated baseline for each workload. We validate training stability and quality preservation on pretraining Llama-style models. These results show how jointly designing quantization, training numerics, and document scheduling translates low-bit hardware throughput into practical attention acceleration.

1. Introduction

Softmax attention [1] remains a substantial cost in Transformer training and inference, particularly at long context lengths. FlashAttention [2] reduces memory traffic through tiled computation and online softmax. FlashAttention-4 [3] further optimizes attention for NVIDIA Blackwell GPUs, but its BF16 implementation leaves higher low-precision throughput unexploited: Blackwell tensor cores support FP8 and FP4 matrix multiplication at twice and four times the BF16 rate, respectively [4]. Realizing these gains requires addressing quantization overhead and training numerics, while supporting the variable-length documents packed together during pretraining.

Recent 4-bit extensions of FlashAttention-4 [5, 6] motivate examining these requirements beyond single-step accuracy. Three constraints are central. First, hardware block scaling follows the contraction axis, whereas attention training uses operands along different contraction axes, potentially requiring separately quantized representations. Second, scales shared across positions can let future tokens affect earlier outputs despite a causal mask. Third, the backward pass must consistently reconstruct the forward's quantized intermediates: mismatches in quantization, tiling, or exponential evaluation can destabilize training despite high single-step cosine similarity. Packed inputs additionally require document-local scaling and load balancing. Among the evaluated implementations, some provide only a forward path for packed inputs [7], use tensor-wide FP8 scaling [8], or lack causal-mask support [9].

We present FLAMIA (FLAsh Microscaling Attention), low-precision attention kernels for Blackwell with MXFP8 and mixed NVFP4/FP8 training paths. The mixed path uses NVFP4 for QKᵀ and its recomputation, and 8-bit operands for the remaining matrix multiplications. Token-block scaling enables reuse of 8-bit representations across orientations. FLAMIA combines targeted leakage mitigations with consistent forward and backward computations and processes packed documents without repacking. Default scaling retains within-block dependencies and a sequence-wide backward accumulator dependency. Exact options remove them in supported batched causal calls. Our contributions are:

  • Two training paths using token-block scaling to reduce quantized representation duplication across matrix orientations.

  • An analysis of scale-induced leakage and forward–backward inconsistencies, with targeted mitigations and training experiments showing that single-step accuracy proves neither causal correctness nor training stability.

  • Kernels combining fused quantization, coordinated softmax and matrix-multiplication scheduling, a low-precision two-CTA backward pass, and GPU-based scheduling for packed documents, plus two bit-level exponential approximations for inference.

  • An evaluation against FlashAttention-4, cuDNN, FlashInfer, Low Precision FA4 [9], and the Hardware-Aware FP4 FlashAttention-4 (HW-FP4 FA4) of Hu [5]. Across all evaluated causal packed-document workloads, MXFP8 achieves the lowest combined forward and backward attention latency, including quantization: 1.10–1.40× speedups on B200 and 1.06–1.42× on B300 over the fastest evaluated baseline per workload. In 1B-model pretraining on 100B tokens, MXFP8 and mixed NVFP4/FP8 lead only to marginal increase of training loss and change of downstream metrics.

The code is available at https://github.com/yandex-research/flamia-blackwell-attention.

References (31)