betaFeedback

WorksComputer Science

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

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.101.10–1.40×1.40\times on B200 and 1.061.06–1.42×1.42\times 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.

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 QKTQK^{\mathsf{T}} 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.

Background and Related Work

FlashAttention Let Q,K,V∈RL×d\mathbf{Q}, \mathbf{K}, \mathbf{V} \in\mathbb{R}^{L \times d} be the query, key, and value tensors corresponding to a single head, with sequence length LL and head dimension dd. The attention output is computed as follows:

S=QKT/d∈RL×L,P=softmax⁡(S)∈RL×L,O=PV∈RL×d.\begin{aligned} \mathbf{S} &= \mathbf{Q}\mathbf{K}^{\mathsf{T}}/\sqrt{d} \in\mathbb{R}^{L \times L},\\ \mathbf{P} &= \operatorname{softmax}(\mathbf{S}) \in\mathbb{R}^{L \times L},\\ \mathbf{O} &= \mathbf{P}\mathbf{V} \in\mathbb{R}^{L \times d}. \end{aligned}

The backward pass recomputes P\mathbf{P} and forms

dV=PTdO,dP=dOVT,dS=P∘(dP−D),dQ=dSK,dK=dSTQ,\begin{aligned} \mathrm{d}\mathbf{V} &= \mathbf{P}^{\mathsf{T}}\mathrm{d}\mathbf{O}, \qquad\mathrm{d}\mathbf{P} = \mathrm{d}\mathbf{O}\mathbf{V}^{\mathsf{T}}, \qquad\mathrm{d}\mathbf{S} = \mathbf{P} \circ(\mathrm{d}\mathbf{P} - D),\\ \mathrm{d}\mathbf{Q} &= \mathrm{d}\mathbf{S}\mathbf{K}, \qquad\mathrm{d}\mathbf{K} = \mathrm{d}\mathbf{S}^{\mathsf{T}}\mathbf{Q}, \end{aligned}

with the row sums Di=∑jPij dPijD_i = \sum_j P_{ij}\,\mathrm{d}P_{ij}, so every operand takes part in two products, contracted along different axes. A naive implementation materializes P\mathbf{P} and S\mathbf{S} in global device memory, resulting in a large memory footprint and substantial I/O traffic. FlashAttention [2] combines tiled computation with online softmax to keep intermediate tiles in fast on-chip memory. FlashAttention-2 [10] reduces non-matmul operations and improves work partitioning, while FlashAttention-3 [11] and FlashAttention-4 [3] introduce optimizations tailored to NVIDIA Hopper and Blackwell GPUs, respectively. In our work, we focus on further improving attention performance on Blackwell, using BF16 FlashAttention-4 as a starting point.

Microscaling floating-point formats Microscaling formats [12] employ fine-grained quantization in which the elements of a block share a common scaling factor: each element is stored as a low-bit code, and its value is the code times the block’s scaling factor. We call a scaling factor a scale for short. NVIDIA Blackwell provides native hardware support for these formats [4]. MXFP formats (MXFP4, MXFP6, and MXFP8) use blocks of 32 elements with UE8M0 scaling factors, whereas NVFP4 uses blocks of 16 elements with E4M3 scaling factors and an additional FP32 tensor-level scaling factor [13]. Blackwell’s block-scaled matrix multiply (MMA) takes such operands directly and applies their scales as it accumulates. Throughout the paper, we write X^\hat{X} for the quantized form of a tensor XX: its low-bit codes, 8-bit E4M3 or 4-bit E2M1, together with one scaling factor per block of codes. These formats have been applied to post-training quantization in FP-Quant [14] and to low-precision training [13, 15, 16, 17, 18]. These training methods primarily target GEMMs in linear layers. Full-Stack FP4 [19] also explores mixed-precision attention.

Low-precision attention The SageAttention series [20, 21, 22, 23] accelerates self-attention by quantizing matmul operands and mitigating quantization error to preserve model quality. SageAttention3 [23] targets microscaling FP4 for inference and separately explores 8-bit forward and backward passes for training. More recent work includes trainable INT8 attention in SageBwd [24], a mixed FP4/FP8 training path in HW-FP4 FA4 [5], and MXFP8 forward and backward kernels in Low Precision FA4 [9]. Attn-QAT [25] emphasizes matching backward score recomputation to the quantized forward pass and correcting precision assumptions in the gradient calculation. Complementarily, Qiu and Yao [26] analyze training instability caused by biased rounding errors and low-rank attention representations. In our work, we develop an optimized implementation of low-precision attention aimed at improving hardware utilization while addressing the numerical consistency and causal correctness issues discussed in the following section.

Hardware-Aware Design Around Low-Bit Attention Constraints

Blackwell tensor cores provide higher peak throughput for FP8 and FP4 than for BF16. Exploiting this throughput in attention requires coordinating three aspects of the design: scaling layouts compatible with the hardware, control of scale-induced dependencies across token positions, and numerical consistency between the forward and backward passes. We first describe these constraints and the resulting MXFP8 and mixed NVFP4/FP8 training paths, then present the kernel optimizations, packed-document support, and inference-only approximation

Token-Block Scaling

Block-scaled matrix multiply–accumulate (MMA) instructions require scaling groups along each operand’s contraction axis. The 4-bit instructions used here also require K-major layouts. Attention training complicates this requirement because each of its six logical operands participates in two products with different contraction axes. Q and K are contracted along the head dimension in S, but along queries and keys in dKdK and dQdQ, respectively. V and dO are contracted along the head dimension in dPdP, but along keys and queries in dVdV and dVdV. Likewise, PP is contracted along keys in PVPV and queries in dVdV, while dSdS is contracted along keys in dQdQ and queries in dKdK. Conventional one-dimensional block scaling therefore generally requires two quantized representations per operand, one per contraction axis. Each representation requires writing its codes and scales, and each separate quantization pass rereads the source tensor. Representations of QQ, KK, and VV needed for backward computation must remain in memory after the forward pass. Because quantization is memory-bound, this duplication across six operands can consume a substantial fraction of attention training time.

We reduce this overhead through selective NVFP4 computation and reusable E4M3 representations. In the mixed NVFP4/FP8 path, QQ and KK use NVFP4 with one scale per 16 consecutive head-dimension elements of each token. The same representations serve forward score computation and backward score recomputation, which share a contraction axis. The remaining products use E4M3 operands, including separate representations of QQ and KK for gradient computation. Our token-block scaling shares one power-of-two exponent across 32 consecutive tokens and the full head dimension. dSdS instead shares one exponent per 32×3232 \times32 block, as Section 3.3 discusses. Repeating these exponents across hardware scaling groups yields MXFP8-compatible representations. The common exponent within each 32×d32 \times d token block preserves the validity of its codes and scales under transposition. Square dSdS blocks give the same property for contractions along queries and along keys. Since 8-bit MMA supports both K-major and transposed (MN-major) layouts, each E4M3 payload serves both orientations without a separately quantized transposed copy.

Causally Safe Scales

Causal masking alone does not prevent information leakage through data-dependent quantization scales. If a future token increases the maximum of a shared scale group, the resulting scale change can alter the reconstructed values of earlier tokens. An earlier output can then depend on a masked future input through the quantizer.

Figure 1 shows where this happens. FlashAttention computes SS in tiles of BrB_r queries by BcB_c keys, with Br=Bc=128B_r = B_c = 128 in our kernels. Under a causal mask, the boundary between visible and masked keys runs through the diagonal tiles (left panel). In PVPV the contraction runs over keys, so a scale group of VV spans several keys. Inside a diagonal tile, such a group can hold keys on both sides of a query’s boundary (right panel). With a 4-bit VV, a larger group scale changes the codes of the visible keys.

Causal masking and key-local value scales

Figure 1. Left: under a causal mask, the boundary between visible and masked keys runs through the diagonal tiles. Right: the keys that query ii reads in the marked tile. A scale group of VV spans keys on both sides of the boundary, so the future key (red) can raise the group maximum, grow the shared scale ss and re-round the codes of the past keys. On diagonal tiles we give each key its own scale and keep the cheaper grouped scales elsewhere.

With an 8-bit VV, the same rescale is usually harmless. When the group scale doubles, each code keeps its mantissa and only its exponent drops by one, so the value it represents stays the same. This fails in two cases: an element that drops below the normal range of E4M3 loses mantissa bits, and an element that was clamped at the largest code is no longer clamped. The second case occurs in the reference microscaling conversion of Darvish Rouhani et al. [12]. It sets the shared exponent to ⌈log⁡2max⁡i∣vi∣⌉−emax⁡\lceil\log_2 \max_i \lvert v_i\rvert\rceil- e_{\max}, so the scaled group maximum can exceed 448, the largest E4M3 value, and is clamped. A later key that raises the maximum doubles the scale, the earlier element is no longer clamped, and its code changes. Whole-tensor statistics, such as a per-tensor maximum, are the extreme case: through them, a later token can change every earlier output.

Our scaling removes these leaks or confines them to one block. No operand scale covers more than 32 consecutive positions: token blocks share one exponent across 32 tokens, and QQ and KK use per-token NVFP4 scales, which cannot leak at all. A later token can therefore change earlier results only inside its own block of 32, through elements near the bottom of the normal range. We also round each scale’s exponent up, so the scaled maximum never exceeds the largest code and no element is clamped.

When VV is 4-bit, we give it a per-key power-of-two scale and fold this scale into P^\hat{P}. A per-key scale depends on a single key and cannot leak. Only diagonal tiles contain a group that straddles the causal boundary, so we use per-key scales on diagonal tiles and keep the cheaper grouped scales elsewhere. The backward has two more leaks on the key side: VV in dP\mathrm{d}P, and KK in dQ=dSK\mathrm{d}Q = \mathrm{d}S K. We close both the same way, by folding a per-key power-of-two scale into the other operand. We call the version for KK the K fold. Appendix A describes the small residue that remains inside a block and the exact options that, together with the causal dQ\mathrm{d}Q scale below, remove it.

The backward has one more leak, through the FP16 dQ\mathrm{d}Q accumulator. As § 3.5.3 explains, we reduce the dQ\mathrm{d}Q partials in FP16, whose five exponent bits leave little range, so we multiply the partials by a power of two that keeps them in range. By default this factor is sized from maxima over the whole sequence, so a later token can change how every earlier row of dQ\mathrm{d}Q rounds. We therefore also provide a causal dQ\mathrm{d}Q scale, which sizes the factor of each query row only from the keys that the row can see.

Validation loss measured through the training kernel alone is insufficient to detect leakage. In our controlled experiments, a model trained with a leaking kernel obtains lower loss when evaluated through that kernel but performs worse under exact causal attention. We therefore compare both evaluation modes in the leakage experiments of § 4.5.

Forward–Backward Numerical Consistency

FlashAttention recomputes attention probabilities during the backward pass from QQ, KK, and saved row statistics rather than storing the full probability matrix. It also computes Di=dOi⋅OiD_i = \mathrm{d}O_i \cdot O_i from the saved output. In exact arithmetic, this equals ∑jPij dPij\sum_j P_{ij}\,\mathrm{d}P_{ij} when O=PVO = PV and dP=dOVT\mathrm{d}P = \mathrm{d}O V^{\mathsf{T}}. Since the rows of PP sum to one, each row of the softmax gradient dS=P∘(dP−D)\mathrm{d}S = P \circ(\mathrm{d}P - D) then sums to zero. Quantization can introduce additional inconsistency if these computations use different reconstructed operands. Matching those operands removes one discrepancy but does not by itself restore the exact identities: quantized probabilities need not sum to one, and output rounding and accumulation introduce further error.

We therefore align the representations and numerical conventions used by the two passes. Score recomputation uses the same quantized QQ and KK representations as the forward pass for the selected precision path. The backward pass also reproduces the relevant tiling and diagonal decisions, exponential evaluation, and scaling relative to the row maximum. We compute DD using the same quantized dO\mathrm{d}O used in dP\mathrm{d}P, with an output formed from the corresponding E4M3 value representation. These choices reduce representation-induced discrepancies without eliminating ordinary rounding or normalization error.

Our experiments show that mismatched tiling or exponential evaluation can destabilize training even when single-step gradient similarity remains high. Such mismatches can introduce structured errors whose effects accumulate across training steps, as Barron et al. [27] also find when the forward and backward passes evaluate a softmax differently. A single-step comparison therefore cannot establish training stability. Building on the quantization consistency emphasized by Attn-QAT [25], we also examine these sources of mismatch in § 4.5.

Before computing dQ\mathbf{dQ} and dK\mathbf{dK}, we quantize dS\mathbf{dS} to E4M3. Its entries span a wide dynamic range, with many substantially smaller than nearby maxima. An excessively large scale increases the fraction of small entries rounded to zero, even when their contribution to the norm error is small. In our ablations, this fraction tracks training degradation more closely than the reported norm error, and the scale choice has the largest effect on loss among the numerical choices examined. We therefore derive a scale from the maximum absolute value in each 32×3232 \times32 block, using the tile already held by the kernel. The square scaling regions permit reuse of one quantized payload in both dQ\mathbf{dQ}, which contracts over keys, and dK\mathbf{dK}, which contracts over queries. Appendix § 7 describes the FP16 dQ\mathbf{dQ} accumulator and rounding choices.

MXFP8 and Mixed NVFP4/FP8 Paths

Although our library supports an all-4-bit training path, it is not the default: in our evaluation, it is slower than paths retaining most operands in 8 bits and reaches a slightly higher loss. The 4-bit MMA instructions used here have no MN-major form, and each orientation needs its own copy. The six quantized copies make quantization the largest part of this path’s backward time. A 4-bit V\mathbf{V} adds two costs. Its key-axis scale groups require per-key scaling on diagonal tiles (§ 3.2), increasing work in the forward pass. Moreover, PV\mathbf{PV} and dP\mathbf{dP} contract V\mathbf{V} along different axes, requiring separate 4-bit representations, while the computation of DD must remain consistent with the representation used in dP\mathbf{dP}. One E4M3 token-block representation can serve both products. Finally, the evaluated backward products are not tensor-core-bound, limiting the benefit of narrower operands. § 4.3 quantifies these costs.

Our default paths use MXFP8 or NVFP4 for score computation and recomputation. The mixed NVFP4/FP8 path quantizes Q\mathbf{Q} and K\mathbf{K} with one NVFP4 scale per 16 head-dimension elements of each token. The MXFP8 path uses E4M3 with token-block scales. Both paths use E4M3 token-block representations of V\mathbf{V}, dO\mathbf{dO}, and the Q\mathbf{Q} and K\mathbf{K} operands of the gradient products, E4M3 dS\mathbf{dS} with one scale per 32×3232 \times32 block, and E4M3 probability operands. Returned outputs and gradients are BF16, while dQ\mathbf{dQ} partials are accumulated in FP16. We describe the scaling of P^\hat{\mathbf{P}} and the kernels below.

Where enabled, a normalized Hadamard transform, as in the incoherence processing of QuIP [28] and QuIP# [29], mixes the head channels of both Q\mathbf{Q} and K\mathbf{K} before quantization. The shared orthogonal transform preserves their dot product in exact arithmetic while spreading channel outliers. Rounding and quantization can still change the resulting scores. It is enabled by default at head dimension 128 on the two default paths. Appendix § 7 reports its effects and remaining format choices.

For fixed-scale E4M3 probability quantization, a multiplier 2c2^c reduces underflow. Conditional rescaling retains the online-softmax row maximum until the new maximum exceeds it by τ\tau. In the base-2 representation, the unnormalized weights relative to the retained maximum can reach 2τ2^\tau, or 2c+τ2^{c+\tau} after scaling. Since the largest finite E4M3 value is 448, we enforce c+τ≤log⁡2448c+\tau\le\log_2 448. Violating this bound can saturate the weights and corrupt the output without a NaN or runtime error. Appendix § 8 gives the parameters and probability-quantization details.

Kernel Design

Our kernels extend the warp-specialized FlashAttention-4 design of Zadouri et al. [3]. A load warp, an MMA warp, two softmax warp groups, correction warps, and an epilogue warp exchange SS, P^\hat{P}, and OO through tensor memory (TMEM). § 4.3 evaluates these modifications.

Quantization and Token-Block Scales

Each attention invocation quantizes its current operands. For each input tensor, we fuse the required Hadamard rotation, block statistics, and generation of codes and scales for all required representations into one launch. The dO launch additionally computes DD and initializes the dQ accumulator. Fusion avoids input rereads during quantization preprocessing. Outputs and returned gradients remain in BF16 and require no output quantization scales, while dS scales are computed within the attention kernel. The required scales are therefore derived from current tensors without a separate output-calibration pass.

Token-block scales are constant along the head dimension and factor algebraically out of the score dot product. Writing qQq_Q, qKq_K for stored codes and eQe_Q, eKe_K for their shared exponents, the reconstructed score is S~ij=2eQ(i)+eK(j)∑kqQ,ikqK,jkd\widetilde{S}_{ij} = 2^{e_Q(i)+e_K(j)} \frac{\sum_k q_{Q,ik}q_{K,jk}}{\sqrt{d}}. The MXFP8 path therefore uses an unscaled E4M3 MMA, folds the row factor into the softmax scale, and applies the column factors separately. This preserves the scaling algebraically. Bitwise equality also depends on range and accumulation order.

Softmax Throughput and MMA Scheduling

Exponential evaluation is a major throughput bottleneck in the evaluated forward kernels. A 128×128128 \times128 tile requires 16384 exponentials, corresponding to 1024 cycles at B200’s MUFU throughput, so faster low-bit MMAs alone do not remove this bottleneck. We address it in three ways. First, as in FA4, FlashInfer, and Low Precision FA4, we evaluate a fraction of the exponentials using a clamped polynomial on the FMA pipeline, selecting the fraction per path and GPU. B300 doubles the exponential throughput of B200. There, polynomial emulation becomes overhead in the pure-E4M3 configuration, and we disable it. Second, the NVFP4 path quantizes probability operands in the log domain. Since max⁡j2xj=2max⁡jxj\max_j 2^{x_j} = 2^{\max_j x_j}, we compute each 32-key group’s maximum before exponentiation and subtract its scaling exponent from the exponential argument. This eliminates a per-entry division and a subsequent scaling pass, producing the largest individual NVFP4 forward improvement in § 4.3. Third, on B300, tcgen05.1d.red combines the row-maximum reduction with the TMEM score load. We use it on tiles known to be fully unmasked, including off-diagonal tiles in causal calls.

We overlap the remaining work with matrix multiplication. The MMA warp splits the next tile’s QKT\mathbf{Q}\mathbf{K}^{\mathsf{T}} into two 64-key operations, issued before and after the current tile’s PV\mathbf{P}\mathbf{V}, respectively. This keeps the tensor cores active while the softmax warps process the current tile. In the backward pass, a checkerboard assignment distributes emulated exponentials so that warps sharing an SM sub-partition use different execution pipelines.

Low-Bit 2-CTA Backward

FlashAttention-4’s two-CTA backward mode uses a cluster of two cooperative thread arrays (CTAs) to share MMA operands and cover 256 keys over a query range. The evaluated FA4 implementation provides this mode in BF16. In its accumulator configuration, all 512 TMEM columns are occupied when dP is issued, leaving no capacity for additional block-scale operands. Token-block scaling permits the compute warps to apply these factors outside the MMA, enabling a low-precision implementation without TMEM scale storage for dP.

Our implementation supports MHA and GQA on batched and packed inputs. On packed inputs, paired key tiles may belong to different documents, and each CTA masks positions outside its document. As in Shankar et al. [9], FP16 dQ partials are written through bulk reduce-add, halving reduction traffic relative to FP32. FP16’s five exponent bits limit its range: in our tests, the fixed scaling factor used by Low Precision FA4 overflowed for outlier K channels. We instead use a data-dependent power-of-two prescale, with the dependency qualifications in § 3.2. An empirical rule per shape and format selects the two-CTA mode.

Packed-Document Attention

Packed Layout

Pretraining packs documents contiguously into rows of TT tokens. Low-precision attention on these rows faces two challenges. First, shared scales can couple otherwise independent documents: a document with large activations can coarsen the representation of others sharing its scale. Second, document starts need not align with the fixed 128×4128 \times4 scale-factor atoms consumed by the block-scaled MMA. The evaluated cuDNN FP8 path uses tensor-wide scales, while its MXFP8 path requires a scale layout padded per document. Padding documents to aligned starts resolves alignment but copies Q, K, V, and gradients in each layer.

Our quantizers process Q, K, V, and dO directly in the packed layout, keeping operand token blocks and their statistics within document boundaries. They write dense scale metadata with one entry per token. This operand-local construction does not remove the default accumulator-scale dependency discussed in § 3.2. Tile boundaries depend on document lengths and offsets (Figure 2a), so the load warp assembles each tile’s 128×4128 \times4 scale-factor atom in shared memory from the per-token tables (panel b). On the all-4-bit path, two keys share a byte. For odd document offsets we keep a second copy of Vᵀ shifted by one key, which Appendix § 8 describes.

Documents packed contiguously

Figure 2. Documents packed contiguously. (a) A 128-row tile may start inside a document. (b) The load warp assembles the tile’s scale-factor atom in shared memory from dense per-token tables.

Keys outside the active document are masked, and invalid query rows receive an infinite log-sum-exp sentinel so that their probability and gradient contributions vanish. Epilogues write outputs and gradients directly to the packed buffers. The layout preserves the intended per-document computation. Bitwise equality of gradients also depends on accumulation order, because the default dQ reduction uses atomics. Buffer capacities depend on TT, allowing different document-length distributions to reuse storage and the same captured CUDA graph.

Load-Balanced Scheduling

Variable document lengths produce substantial differences in tile cost. In the evaluated FA4 schedule, tiles are ordered longest-first within each sequence, but sequences are visited in input order. A long document near the end can therefore delay completion. The evaluated FlashInfer path instead constructs a load-balancing plan on the CPU and transfers it to the GPU for each new workload.

We construct the schedule on the GPU once per microbatch without host synchronization. Each work item contains 256 consecutive queries from one document, corresponding to a CTA’s two 128-query tiles. Its estimated cost is the number of key blocks attended to, determined by document length and, for causal attention, query position. Items across the row are sorted by decreasing cost. A persistent grid assigns them to CTAs in alternating directions, distributing long and short items across the grid. Highly skewed workloads can leave CTAs idle under static assignment. Causal calls and non-causal calls whose longest document is at least four times the mean therefore use Cluster Launch Control (CLC) to acquire items dynamically, as FA4 does for causal calls. Requests follow the current item’s final K and V loads, avoiding premature work reservation.

In the backward pass, each CTA processes a key tile across query tiles. We similarly order key tiles by decreasing estimated work and group heads into sections for L2 locality, as FA4’s batched schedule does. Appendix § 8 describes list construction and the backward launch layout.

Bit-Level Exponentials for Inference

Since the exponential limits the forward, we also offer two cheaper approximations of it for inference. Both build 2x2^x directly in the bits of a float. The bit pattern of a positive float, read as an integer, grows almost linearly with log⁡2\log_2 of its value. Writing xx in fixed point into the exponent field therefore gives the piecewise-linear approximation of Mitchell [30],

2x≈2⌊x⌋(1+{x})2^x \approx2^{\lfloor x\rfloor}(1+\{x\})

A 4-bit P^\hat{P} tolerates an inexact exponential. E2M1 has only eight magnitudes, at least 33% apart, while Mitchell’s approximation is off by a few percent, so the approximate 2x2^x almost always falls into the same rounding interval as the exact value and gives the same code. Our Mitchell-P quantizer therefore computes 2x2^x with ordinary arithmetic instructions instead of the hardware exponential unit (MUFU) that limits the forward. A fused multiply-add writes xx in fixed point into the bits of a float, an integer shift moves these bits into the exponent and mantissa, and a hardware convert rounds the resulting approximation of 2x2^x to E2M1. A constant offset of xx centres the approximation error, and an integer clamp keeps the result valid for any score range. Like the Direct-P quantizer of HW-FP4 FA4 [5], it maps scores to codes without an exact exponential, but where Direct-P fits an affine classifier, Mitchell-P reproduces almost every code of exact rounding. The EFQ-Softmax of Han et al. [31] also produces codes without computing an exponential.

An 8-bit P^\hat{P} needs a more accurate value. Neighbouring E4M3 values lie only 7–12.5 % apart, close to the error of the approximation, so the error would change many codes and shift P^\hat{P} instead of vanishing in the rounding. For this format we use the variant of Schraudolph [32], which computes the same 2⌊x⌋(1+{x})2^{\lfloor x\rfloor}(1+\{x\}) in BF16 and offsets xx so that the error averages zero. A fused multiply-add adds to 27x2^{7}x a constant that fixes the FP32 exponent and adds the BF16 exponent bias. The low 16 bits then hold the BF16 pattern of the approximation, with the integer part of xx in its exponent and 7 fraction bits in its mantissa, and a 16-bit shift turns them into an FP32 value. We use it for five of every eight exponential pairs and keep the rest exact on MUFU.

We use neither approximation in training. As § 3.3 explains, the backward must rebuild the forward’s P^\hat{P} exactly, and a backward with the same approximation lost more time than the forward gained. § 4.4 measures both approximations, and Appendix § 9 derives them.

Experiments

We evaluate latency, accuracy, optimizations, inference approximations, and training behavior, benchmarking kernels on B200 and B300. Baselines include BF16 and FP8 FlashAttention-4 [3]; cuDNN BF16, FP8, and MXFP8 attention [8]; FlashInfer [7]; Low Precision FA4 [9]; HW-FP4 FA4 [5], with its Direct-P forward and its causal path; and PyTorch SDPA on nested tensors. FlashInfer configurations include FP8 CUTLASS and CuTe-DSL backends and NVFP4 KV-cache prefill. Baselines use their supported ragged APIs. Low Precision FA4 lacks causal masking, and neither it nor the evaluated nested-tensor SDPA path supports GQA. cuDNN MXFP8, FA4 FP8, FlashInfer, and HW-FP4 FA4 lack a supported packed-document backward path in this evaluation and appear only in forward comparisons. cuDNN MXFP8 and Low Precision FA4 use 1×321 \times32 scaling blocks; Low Precision FA4 retains both orientations. Appendix § 10 specifies hardware, software, and timing.

GPUDocumentsOurs MXFP8Ours NVFP4cuDNN FP8FA4 BF16cuDNN BF16SDPA BF16Speedup
B2004×40960.89 10790.92 10491.06 9121.08 8891.28 7516.30 1531.18×
16×40963.53 10903.64 10583.90 9864.24 9074.88 79013.4 2881.10×
16×10240.44 5420.49 4920.53 4560.50 4780.55 4405.94 411.14×
64×10241.66 5791.82 5301.85 5212.00 4822.25 4275.79 1661.11×
8192 + 32×2560.91 10950.94 10591.25 7931.10 8981.55 6395.36 1851.22×
8192 + 224×2561.80 6501.99 5893.03 3872.52 4666.71 1757.62 1541.40×
log-unif. 16k0.71 8850.75 8380.89 7060.85 7381.00 6316.31 1001.20×
log-unif. 16k, GQA0.71 8810.73 8600.99 6370.85 7401.02 618no GQA1.19×
log-unif. 64k3.61 10613.70 10344.15 9224.32 8865.12 74813.8 2771.15×
B3004×40960.79 12200.84 11410.90 10650.99 9681.15 8408.87 991.14×
16×40963.17 12123.28 11753.35 11473.99 9654.45 86513.4 2891.06×
16×10240.41 5880.45 5320.48 5070.47 5180.51 4699.41 261.14×
64×10241.52 6351.68 5731.67 5781.83 5272.08 4628.62 1121.10×
8192 + 32×2560.82 12100.87 11461.07 9261.04 9541.41 7038.04 1151.27×
8192 + 224×2561.67 7051.84 6362.81 4182.37 4956.47 1819.45 1241.42×
log-unif. 16k0.64 9850.69 9110.77 8140.78 8100.91 6968.62 731.21×
log-unif. 16k, GQA0.67 9430.68 9250.87 7280.78 8100.93 680no GQA1.16×
log-unif. 64k3.23 11863.35 11443.60 10634.11 9324.70 81614.2 2641.11×

Table 1. Training call on packed documents (forward and backward, quantization included), causal, 16 heads, d=128d = 128: time in ms (fastest in bold), TFLOP/s in small type; Speedup: the fastest baseline’s time over ours.

Performance on Packed Documents

Each workload packs documents into one token row with 16 query heads and head dimension d=128d = 128. MHA uses 16 key/value heads; GQA 16/4 uses four. Equal-length workloads contain 4×40964 \times4096, 16×409616 \times4096, 16×102416 \times1024, or 64×102464 \times1024 tokens. Skewed workloads combine one 8192-token document with 32 or 224 documents of 256 tokens. Log-uniform workloads draw document lengths between 128 and 8192: 11 documents in 16k tokens, with and without GQA, and 29 documents in 64k tokens. We evaluate causal and non-causal attention; non-causal results appear in Appendix H.

Attention training-call timing includes forward, backward, and quantization on packed inputs. Kernel-only measurements exclude quantization and use 128-aligned document starts for FLAMIA. Their layout difference prevents isolating quantization overhead by subtraction. For cuDNN FP8, input-scale computation is timed, whereas output scales are calibrated beforehand on the same data. Speedup denotes the fastest supported baseline’s latency divided by FLAMIA’s latency for the same workload.

MXFP8 achieves the lowest measured attention training-call latency on all nine causal workloads on both GPUs (Table 1), with speedups of 1.10–1.40×1.40\times on B200 and 1.06–1.42×1.42\times on B300. On non-causal workloads, MXFP8 leads on all nine B200 cases (1.041.04–1.30×1.30\times). B300 has five clear wins, two ties at displayed precision, and two small losses. Our non-causal backward leads on every workload, with speedups of 1.17–1.49×\times and 1.01–1.43×\times on B200 and B300, respectively; our forward leads on six and five of nine.

Kernel-only results show complementary strengths (Table 2 and Table 3 and Appendix § 15). NVFP4 achieves the lowest causal backward latency on every workload, with speedups of 1.22–2.01×\times on B200 and 1.17–2.00×\times on B300. MXFP8 leads the forward comparisons on all nine B200 workloads and eight of nine B300 workloads, with ranges of 1.07–1.72×\times and 0.98–1.69×\times. The NVFP4 forward is slower than MXFP8, consistent with its additional softmax work outweighing savings in QKTQK^{\mathsf{T}}.

GPUDocumentsOurs MXFP8Ours NVFP48-bit cuDNN FP88-bit cuDNN MXFP88-bit FA4 FP88-bit FlashInfer FP84-bit FlashInfer NVFP4BF16 FA4BF16 cuDNNBF16 FlashInferBF16 SDPASpeedup
B2004×40964 \times40960.17 16160.21 12930.24 11370.40 6820.27 10180.25 11040.24 11380.24 11530.42 6580.28 9931.99 1381.40×1.40\times
16×409616 \times40960.70 15690.82 13400.75 14681.50 7331.06 10380.91 12110.85 13000.98 11211.50 7331.15 9563.96 2781.07×1.07\times
16×102416 \times10240.07 10110.07 9160.11 6210.26 2640.12 5930.15 4550.10 7150.10 6520.22 3080.16 4331.92 361.41×1.41\times
64×102464 \times10240.24 11580.27 10350.34 8041.15 2400.45 6120.53 5150.34 8110.41 6651.05 2620.61 4482.06 1341.42×1.42\times
8192+32×2568192 + 32 \times2560.18 15980.22 12790.30 9570.42 6670.28 10230.37 7720.29 9780.24 11720.44 6440.42 6811.92 1471.37×1.37\times
8192+224×2568192 + 224 \times2560.28 12040.32 10450.48 6983.70 910.59 5640.67 5000.84 3970.55 6133.61 930.77 4382.51 1341.72×1.72\times
log-unif. 16k0.13 13600.16 11120.20 8900.35 5090.22 8310.23 7990.19 9690.18 7770.34 5370.24 7362.02 891.39×1.39\times
log-unif. 16k, GQA0.13 13570.16 11110.20 8860.34 5260.16 11470.32 5700.18 9760.16 10950.33 5460.38 469no GQA1.18×1.18\times
log-unif. 64k0.73 15050.86 12690.82 13411.68 6501.10 9951.01 10870.91 12041.03 10631.65 6651.22 8944.15 2631.12×1.12\times

Table 2. Forward kernel on packed documents, causal, 16 heads, d=128d = 128: time in ms (fastest in bold), TFLOP/s in small type; Speedup: the fastest baseline’s time over ours on B200 GPU. cuDNN MX: cuDNN MXFP8; FlashInfer: its fastest backend.

GPUDocumentsOurs MXFP8Ours NVFP4FP8 cuDNNBF16 FA4BF16 cuDNNBF16 SDPASpeedup
B2004×40964 \times40960.52 13120.51 13540.69 9930.73 9440.79 8672.56 2691.36×1.36\times
16×409616 \times40962.14 12862.08 13242.65 10393.09 8903.31 8319.20 2991.27×1.27\times
16×102416 \times10240.23 7480.23 7550.30 5720.37 4670.32 5432.56 671.32×1.32\times
64×102464 \times10240.88 7790.88 7851.07 6421.47 4681.24 5533.04 2261.22×1.22\times
8192+32×2568192 + 32 \times2560.53 13330.52 13770.83 8510.75 9441.09 6512.88 2461.46×1.46\times
8192+224×2568192 + 224 \times2560.98 8520.97 8602.12 3951.96 4273.11 2694.92 1702.01×2.01\times
log-unif. 16k0.41 10960.40 11320.57 7900.57 7880.60 7492.48 1821.43×1.43\times
log-unif. 16k, GQA0.47 9680.46 9860.70 6400.60 7490.64 708no GQA1.32×1.32\times
log-unif. 64k2.21 12412.13 12812.79 9803.14 8723.39 8089.48 2891.31×1.31\times

Table 3. B200. Backward kernels on packed documents, causal, 16 heads, d=128d = 128: time in ms (fastest in bold), TFLOP/s in small type; Speedup: the fastest baseline’s time over ours.

B300/B200 training-call latency ratios are 0.85–0.93 for cuDNN FP8, 0.92–0.95 for FA4 BF16, and 0.89–0.94 for MXFP8. Relative advantages vary by workload rather than narrowing uniformly. The largest gains occur on 8192 + 224 × 256: B300 training-call and backward speedups reach 1.42×\times and 2.00×\times. On this workload, cuDNN FP8 takes approximately 1.68×\times our MXFP8 training-call latency on both GPUs, FA4 BF16 takes 1.40–1.42×\times, and cuDNN BF16 takes 3.7–3.9×\times. Equal-length workloads yield 1.06–1.18×\times speedups. Skew (maximum/mean document length) is not isolated from other shape differences.

Multiplying one document’s activations by 10410^{4} gives a dK\mathbf{dK} cosine of 0.99805 for the remaining documents with local scales, versus 0.99151 with tensor-wide scaling. At T=131072T = 131072, measured peak memory per attention call is 2.7 GB for packed inputs versus 16.8 GB with buffers sized for aligned, padded documents. In full-model training of the 1B model on one B200, packed inputs achieve 84.6k and 96.8k tokens/s at packed row lengths of 16k and 64k, versus 68.8k and 84.3k for padding. The padded configuration exceeds available memory at 128k tokens.

Numerical Accuracy

Table 4 compares output and gradient cosine similarity with an FP32 reference on the same BF16 inputs. The evaluated 8-bit configurations achieve output cosines of approximately 0.998–0.999 across tensor-wide, per-32-element, and token-block scaling. On non-causal inputs, mixed NVFP4/FP8 achieves 0.9899, compared with 0.9895 for FlashInfer’s NVFP4 KV-cache path and 0.9435 for the Direct-P forward of HW-FP4 FA4, which uses an MXFP4 PV. Different operands and scaling schemes confound bit-width comparisons. Within FLAMIA, all-4-bit O / dQ cosines are 0.9810/0.9456 for causal attention and 0.9800/0.9509 for non-causal attention, versus 0.9920/0.9906 and 0.9899/0.9890 for mixed NVFP4/FP8. These metrics do not show training stability.

Systemcausalnon-causal
Ours, MXFP8 (token-block)0.9988 / 0.99790.9985 / 0.9978
Ours, NVFP40.9920 / 0.99060.9899 / 0.9890
Ours, all-4-bit0.9810 / 0.94560.9800 / 0.9509
cuDNN FP80.9985 / 0.99750.9982 / 0.9974
cuDNN MXFP8 (1×32)0.9988 / 0.99780.9985 / 0.9978
LP-FA4 (1×32)no causal mask0.9986 / 0.9978
FlashInfer NVFP4 KV cache0.9909 / no bwd0.9895 / no bwd
HW-FP4 FA4, Direct-Pno causal mask0.9435 / no bwd

Table 4. Cosine to an FP32 reference on the same inputs, O / dQ, 4 × 4096 tokens, 16 heads, d=128d = 128 (B200). no bwd: the system has no backward; no causal mask: the system supports only non-causal attention.

Ablation Study

Ablations disable individual optimizations on B200 unless stated otherwise. Gains are not additive.

Fused quantization reduces preprocessing from 789 to 261 μ\mus for MXFP8 and from 0.64 to 0.11 ms for NVFP4 at 4×40964 \times4096 tokens. The reported kernel launch counts decrease from 17 to one and from 11 to one, respectively. FLAMIA requires no separate output-scale calibration pass because outputs and returned gradients remain BF16. cuDNN FP8 calibration costs depend on which scales are computed online; Appendix § 16 compares three policies, including an additional forward/backward pass to obtain all scales.

A diagnostic forward with exponential evaluation removed reaches 2608 TFLOP/s. The associated 45 % estimate is diagnostic: removal changes overlap and invalidates attention, precluding direct runtime attribution. Log-domain probability quantization yields reported NVFP4 forward gains of 14–19 %; splitting QKTQK^{\mathsf{T}} yields 4.7 %, and folding score scales yields 4 % for MXFP8. Without the polynomial clamp, output cosine on a trained-model activation capture falls to −0.012. On B300, disabling exponential emulation in the pure-E4M3 configuration yields 17–33 % gains; fused ld.red on fully unmasked tiles yields 18–20 % for the causal NVFP4 forward.

The mixed NVFP4/FP8 backward reaches a geometric-mean throughput of 1329 TFLOP/s, compared with 571 for all-4-bit and 1015 for BF16. Quantizing six copies accounts for 45–52 % of the all-4-bit backward time; its validation loss is 0.012 above BF16 in the reported training experiment. FP16 dQ partials with data-dependent scaling yield a reported 23.8 % backward gain. Without them, bulk reduce-add bandwidth near 6 TB/s would limit the one-CTA backward to approximately 1990 TFLOP/s. Checkerboard exponential assignment yields 6–10 % gains, and two-CTA execution yields 2.3–6.4 % at 32k keys or more. The optional causal dQ scale removes the sequence-wide accumulator dependency, not the remaining within-block dependencies. Its reported overhead is 8–11 % for backward and 6–9 % for the attention training call at 32768 tokens, largely from loading row scales during reduction.

Removing longest-first ordering incurs a reported 10–65 % causal-forward penalty. Merge-sort work-list construction takes 0.26 ms for 131072 one-token documents, compared with 50.5 ms for the reference construction. Just-in-time CLC acquisition improves performance by 1.7–5.7 % over static assignment in 13 of 16 evaluated causal configurations; premature acquisition incurs 6–14.5 % overhead. On non-causal workloads, CLC yields 4.1–9.7 % gains on the two skewed cases but loses on equal-length cases, motivating its activation when maximum document length is at least four times the mean. Removing document-aware backward ordering incurs up to 9.7 % overhead; removing head grouping for L2 locality incurs up to 22.5 %.

Bit-Level Exponentials at Inference

We evaluate inference calls including quantization on B200 with 128-aligned document starts (Appendix § 9). Schraudolph’s approximation gives MXFP8 speedups of approximately 1.03–1.17×\times, changing output cosine by less than 10−410^{-4}. Mitchell-P matches exact-rounding codes on 98.7 % of evaluated inputs, versus 63.3 % for the affine classifier of Direct-P [5]. The complete Mitchell-P configuration achieves 1.05–1.23×\times speedups over NVFP4 on non-causal workloads. On causal workloads, latency is approximately 1.25–1.77×\times that of NVFP4, equivalent to 20–43 % lower throughput; diagonal per-key V scaling contributes to this overhead. Output cosine decreases from 0.990–0.993 to 0.980–0.982. Because Mitchell-P also changes probability precision, this comparison does not isolate the approximation.

The largest observed within-row score range is 39.6 nats on Gaussian inputs, within the approximation window, versus 386–1653 nats on trained-model captures, motivating the clamp. A Mitchell-P backward that consistently reconstructs the forward probabilities gives an attention training-call latency of 1.60–1.64 ms at 4×40964 \times4096 tokens, versus 1.00 ms for the default NVFP4 path. In this configuration, backward overhead outweighs the forward benefit.

Causality and Training Stability

We probe scale-induced dependencies by perturbing a future key-position input to increase its scale-group maximum and measuring changes at earlier positions, on activations captured from a trained model. Table 5 reports maximum relative changes in the evaluated probes. Leaks occur with per-tensor scales, with 4-bit V grouped along keys, in the causal path of HW-FP4 FA4, and with floor-rounded microscaling exponents. Upward rounding in cuDNN MXFP8 and Low Precision FA4 avoids the saturation mechanism, but both still change earlier outputs slightly. We measure the quantizers of Low Precision FA4 around exact attention, since its backward refuses causal masks.

ScalingOdQ
Per-tensor9.8e−29.8\mathrm{e}{-2} / 7.9e−27.9\mathrm{e}{-2}2.8e−12.8\mathrm{e}{-1} / 1.1e−11.1\mathrm{e}{-1}
4-bit V by keys2.2e−12.2\mathrm{e}{-1}below noise
cuDNN MXFP8, default6.9e−66.9\mathrm{e}{-6}1.1e−51.1\mathrm{e}{-5}
cuDNN MXFP8, floor exp.1.1e−11.1\mathrm{e}{-1}1.1e−11.1\mathrm{e}{-1}
LP-FA4, default6.8e−66.8\mathrm{e}{-6}8.5e−48.5\mathrm{e}{-4}
LP-FA4, floor exp.1.0e−11.0\mathrm{e}{-1}8.3e−28.3\mathrm{e}{-2}
HW-FP4 FA4 (causal)1.7e−11.7\mathrm{e}{-1}no bwd
FlashInfer NVFP4 KV2.6e−12.6\mathrm{e}{-1}no bwd
Ours0/00 / 00/00 / 0

Table 5. Largest relative change of earlier outputs when a future token raises the maximum of its scale group, on activations of a trained model, 8-bit / 4-bit route. The change spreads only within the group that shares the scale: the whole tensor, a 32-token block, or a group of 16 or 32 keys. below noise: smaller than the run-to-run variation of the 4-bit backward, which accumulates dQ with atomics and rounds stochastically.

Of all rows in Table 5, only our exact options with the causal dQ scale leave earlier outputs unchanged. The causal scale has a reported 8–11 % backward overhead. Applying per-key V scales only on diagonal tiles gives forward latency factors of 1.17×1.17\times and 1.04×1.04\times at 4096 and 32768 tokens, compared with 2.33×2.33\times and 2.83×2.83\times when applied to every tile. The K fold costs 2.7–4.0 % of the attention training call.

We train byte-level GPT models with six layers and width 1024 on enwik8 [33], using 1024-byte contexts for 6000 steps. Models trained with the leaking 4-bit configuration achieve validation losses of 0.811–0.827 through their own kernels, compared with 0.852 for BF16. Evaluating the same weights with exact attention increases loss to 0.888–0.940, compared with 0.862 for a model trained without the leak.

Forward–backward mismatches destabilize the evaluated configurations. Using different dQ representations for DD and dP causes divergence within 500 steps. Using 4-bit probabilities in forward and 8-bit probabilities in backward produces highly concentrated attention. Diagonal handling over 256 queries in forward versus 128 in backward increases gradient norm from 0.5 to 2⋅1052 \cdot10^{5}, despite a single-step dQ cosine of 0.945. Approximating exponentials only in forward causes divergence by step 500. These failures motivate consistent numerical conventions.

In the dS scaling ablation, the fraction of entries rounded to zero rises from 0.4% to 29%, while the validation-loss gap to BF16 rises from 0.0008 to 0.049 despite similar reported norm error. This association supports preserving small gradient entries but does not isolate underflow as the sole cause. Deriving scales from each 32×3232 \times32 block’s maximum absolute value has a reported 9–12% attention training-call overhead. Appendix A reports scale-range, rounding, and Hadamard-rotation effects.

Training validation

We pretrain 1B-parameter Llama-3-style Transformers [1, 34] on 100B FineWeb-Edu tokens [35] with next-token prediction and 2k-token contexts. Our TorchTitan integration [36] runs on eight B300 GPUs, and Appendix G lists the hyperparameters. We compare BF16 FlashAttention-4 [3] with our MXFP8 and mixed NVFP4/FP8 paths. Table 6 reports mean loss over the final 1,000 steps and final-checkpoint scores on five tasks using lm-eval-harness [37].

TaskBF16 BaselineMXFP8 OursNVFP4 Ours
Training loss ↓2.3922.3972.406
ARC Challenge ↑0.39250.36180.3677
ARC Easy ↑0.64810.64600.6557
HellaSwag ↑0.57110.56500.5610
PIQA ↑0.72800.73230.7258
WinoGrande ↑0.57620.56350.5967
Mean0.58320.57370.5814

Table 6. Training loss averaged over the final 1,000 steps and downstream evaluation of the final checkpoints.

MXFP8 and NVFP4 quantization leads to marginal loss increase. Downstream scores for the low-bit attention are close to the baseline.

Discussion and Conclusion

We presented FLAMIA, a family of MXFP8 and mixed NVFP4/FP8 attention kernels for NVIDIA Blackwell. FLAMIA combines token-block scaling, forward–backward numerical consistency, and workload-aware scheduling to process packed documents without repacking. Its MXFP8 path achieves the lowest measured combined forward and backward attention latency, including quantization, across the evaluated causal packed-document workloads.

Our experiments identify scale-induced dependencies, numerical inconsistencies, and saturation that single-step similarity metrics alone do not adequately characterize. Default scaling retains residual dependencies; options that eliminate the identified dependencies currently cover supported batched causal configurations. These findings highlight the importance of jointly designing quantization and kernel execution, and of evaluating low-precision attention through latency, causal-dependency tests, and training outcomes.

AI Usage Disclosure

We used the following generative AI tools in this work: Claude (Anthropic) through the Claude Code assistant, Codex (OpenAI), and the AI assistant built into Overleaf, where the manuscript was prepared for submission. These tools assisted us in writing attention kernels and polishing the text of the paper. The authors designed the methods, specified and reviewed every code change, and validated the code through tests and the measurements reported here. All research ideas, the design of the methods and experiments, and the conclusions are the authors’ own. The authors take full responsibility for the content of this paper, including every part produced with AI assistance.

Design Details

Scale Ranges

Attention’s intermediates fall off the bottom of the scale formats. A per-16 UE4M3 scale for P\mathbf{P}, the group maximum over 6, is zero once the group maximum drops below the smallest UE4M3 subnormal, which 63–89 % of the groups of a trained model do. Gradients have the same problem: an unscaled NVFP4 dO\mathrm{dO} flushes every code at real gradient magnitudes, and Hu [5] report that an unscaled E4M3 dO\mathrm{dO} rounds 97 % of values to zero. We therefore keep P^\hat{\mathbf{P}} in 8 bits and give dO\mathrm{dO} token-block scales.

Hadamard Rotation

One outlier channel sets the scale of every block it touches. A Hadamard rotation, the incoherence processing of QuIP [28] and QuIP\# [29], of Q\mathbf{Q} and K\mathbf{K} along the head dimension leaves S\mathbf{S} unchanged and spreads the outlier’s energy over all channels. That helps a coarse shared scale and hurts a fine one: NVFP4’s per-16 scale already isolates the outlier, and rotation spreads it into every group. The rotation adds no causal channel, since it mixes channels and never positions. With outlier channels in K\mathbf{K}, it lowers the NVFP4 output cosine from 0.937 to 0.857 and raises the MXFP4 one from 0.749 to 0.816. In training, its effect stays within run-to-run noise on both routes. We fuse it into the quantizer, which reads each tensor once, and the forward and the backward read the same rotated codes. It is on by default wherever the head dimension is 128 and off on the all-4-bit route. Because training does not distinguish the two settings, we keep a single default rather than one per format.

The In-Block Residue

Token blocks and 32×3232 \times32 dS blocks leave a small leak inside each block: a later token in the same block that raises its maximum re-rounds earlier subnormal codes, within at most 31 positions. We provide per-token operand scales and a per-query-row dS exponent, which close it exactly, as options rather than defaults: they cost backward time and did not change training. Together with the causal dQ scale described next, these options form the exact options of § 4.5.

The dQ Accumulator

We reduce the dQ partials in FP16, as the kernel of Shankar et al. [9] does, which halves the reduction traffic but leaves only five exponent bits. A fixed boost overflows on outlier K channels, so we pre-scale the partials by a power of two sized from the maxima of ∥dO∥\lVert\mathrm{dO} \rVert, ∥V∥\lVert V \rVert and ∣K∣\lvert K \rvert. By default these maxima are taken over the whole sequence. A later key that raises one of them then changes the FP16 rounding of every earlier row of dQ, by up to 5×10−45 \times10^{-4} of its largest entry. The causal dQ scale removes this leak. It sizes the scale of query row ii from ∥dOi∥\lVert\mathrm{dO}_i \rVert and from the running maxima of ∥Vj∥\lVert V_j \rVert and ∣Kj∣\lvert K_j \rvert over the keys j≤ij \le i, and every backward kernel reads the scale of its own row. It needs no host synchronization and keeps the call capturable in a CUDA graph. It makes the backward 8–11% slower at 32768 tokens, so we provide it as an option. It currently covers batched causal calls. Packed documents, windows and the all-4-bit backward use the default scale.

Rounding

We round every element to nearest, with one exception. Stochastic rounding is unbiased, but it adds noise that the exponential amplifies on the softmax input, and it pays off only where nearest rounding flushes a gradient tail. Because block-scaled dS keeps that tail, we do not use it on the default routes. On the all-4-bit route we apply it to the dK operand with the hardware’s stochastic convert, which lowers that route’s validation loss from 0.943 to 0.921.

Kernel Details

Quantizing P^\hat{\mathbf{P}}

Most probabilities are small, so we multiply P\mathbf{P} by a fixed factor 2c2^c before rounding to E4M3, which keeps small entries above the smallest E4M3 code, and divide the factor out after the MMA. FlashAttention-4 also uses conditional rescaling: it updates the running row maximum mm only when mj−mj−1>τm_j-m_{j-1}>\tau, with τ=8\tau=8 by default, so until the next update the exponentials can exceed 1 by up to 2τ2^\tau. In BF16 this is harmless. In E4M3, whose largest value is 448, c+τc+\tau must stay within log⁡2448\log_2 448. Otherwise the largest entries of P^\hat{\mathbf{P}} saturate without any error, and O is wrong without a NaN. On the MXFP8 route we use c=4c=4 and τ=4\tau=4, as cuDNN does, and assert the bound. This P^\hat{\mathbf{P}} needs no other scale. A violation is easy to miss: with c=8c=8 and τ=2\tau=2, entries of P^\hat{\mathbf{P}} reach 1024, saturate at 448, and give a wrong O without a NaN. The bound costs no accuracy in training: with (c,τ)=(4,4)(c,\tau)=(4,4), a 6000-step run reaches a validation loss of 0.8493, and over four seeds an exact running maximum, (c,τ)=(8,0)(c,\tau)=(8,0), reaches 0.8567 against 0.8504 for BF16. In the backward, both routes multiply the P^\hat{\mathbf{P}} of dV by 282^8 and store no scale.

4-Bit V Transpose on Packed Rows

On the all-4-bit route, VTV^{\mathsf{T}} stores two keys per byte. A document that starts at an odd key therefore starts in the middle of a byte, and so do its tiles. TMA and the MMA address memory in bytes, so such a tile cannot be loaded as is. Shifting every byte by half a byte in registers would combine two input bytes into each output byte on every tile. Instead, the quantizer writes VTV^{\mathsf{T}} twice, once with key pairs (2m,2m+1)(2m, 2m+1) and once with pairs (2m−1,2m)(2m-1, 2m). A document that starts at an odd key reads the second copy, where its tiles start on a byte boundary. Each tile is then loaded from the 16-byte boundary below it, as TMA requires, and moved into place in registers by whole bytes. The cost is one extra write of VTV^{\mathsf{T}} per step instead of a half-byte shuffle on every tile.

Choosing the 2-CTA Backward

We choose between the 1-CTA and 2-CTA backward with a rule fitted to measurements, and we refit it for each operand format, because a rule tuned for one format did not fit the next. From 32k keys on, the rule selects the 2-CTA kernel for every call it supports. Below 32k keys, it selects the 2-CTA kernel only for MHA with equal query and key lengths, where it measured faster. Deterministic calls keep the 1-CTA kernel.

Inherited Mask

Our FP8 forward had inherited the causal mask in its unmasked loop. Removing it speeds up causal forwards by 11–14%.

Determinism

Our forward is deterministic: the same inputs give bitwise-identical OO and LSE. By default, we accumulate dQdQ with atomics, as every backward we measured does, including BF16. A deterministic order costs 5–12% for MHA and 20–34% for GQA.

Work Lists and Launch Layout

We sort the forward’s work list on the GPU with a fixed number of ordinary merge-sort launches, so it needs no host synchronization and no cooperative launch. In the backward we launch one CTA per position on a capped grid, sized from the row length, and a persistent overflow launch takes any later positions. In our tests, a single persistent kernel kept descriptors live across its loop and spilled registers.

Inference-Only Exponentials

Mitchell-P

One FFMA computes t=(x−δ) 216+Mt = (x-\delta)\,2^{16} + M with the magic constant M=223+L⋅216M = 2^{23} + L \cdot2^{16}. Adding MM fixes the exponent of tt at 2232^{23}, so the FFMA’s rounding writes x−δx-\delta as a fixed-point number with 16 fractional bits into the low mantissa bits of tt. The term L⋅216L \cdot2^{16} offsets it so that negative scores stay in range. One integer shift-add, bits⁡(2x)=(bits⁡(t)≪7)+c\operatorname{bits}(2^x) = (\operatorname{bits}(t) \ll7) + c with c=(127≪23)−(bits⁡(M)≪7)c = (127 \ll23) - (\operatorname{bits}(M) \ll7), moves the integer part of xx from bit 16 into the exponent field and its fraction into the mantissa, which yields the piecewise-linear approximation 2⌊x⌋(1+{x})2^{\lfloor x\rfloor}(1+\{x\}). This approximation never falls below 2x2^x, and the offset δ=log⁡21.25−0.25\delta=\log_2 1.25-0.25 shifts it down to centre its error. The FFMA is exact while x−δ∈[−L,128−L)x-\delta\in[-L,128-L). With L=124L=124, scores down to about 86 nats below their group maximum are exact. Below this window the shifted pattern would wrap, so one integer maximum clamps bits⁡(t)\operatorname{bits}(t) at bits⁡(223)\operatorname{bits}(2^{23}), which makes the result exact for any range. Within the window the value differs from 2x2^x by at most 4.7%, and we accumulate the row sum from the same values, so the backward of the all-4-bit route can rebuild them exactly.

Schraudolph’s Exponential

The FFMA computes t=27x+1.5⋅223+27(127−σ)t=2^7x+1.5\cdot2^{23}+2^7(127-\sigma) with σ=0.0573\sigma=0.0573, and its low 16 bits are shifted left by 16 bits into a float and clamped at zero. The magic constant 1.5⋅2231.5\cdot2^{23} rounds 27x2^7x to an integer in the low mantissa bits of tt, and the low 16 bits of tt read as BF16 give 2⌊x⌋(1+{x})2^{\lfloor x\rfloor}(1+\{x\}) shifted by σ\sigma. Its ratio to 2x2^x stays between −3.9%-3.9\% and +2.0%+2.0\% and averages one, and the row sum and the log-sum-exp therefore carry no mean bias. The 16-bit field wraps below x=−383x=-383, far outside any score range we observed.

DocumentsCausalCausalCausalCausalNon-causalNon-causalNon-causalNon-causal
MXFP8SchraudolphNVFP4Mitchell-PMXFP8SchraudolphNVFP4Mitchell-P
16×102416\times10240.1590.154 +3%0.1820.312 −42%0.1830.169 +8%0.2210.210 +5%
64×102464\times10240.5270.514 +3%0.6271.109 −43%0.6400.591 +8%0.7930.737 +8%
4×40964\times40960.2610.244 +7%0.3180.419 −24%0.3990.345 +16%0.5070.419 +21%
16×409616\times40961.0330.943 +10%1.1781.542 −24%1.6321.429 +14%1.9351.574 +23%
8192+32×2568192+32\times2560.2690.248 +8%0.3290.429 −23%0.4480.383 +17%0.5700.467 +22%
8192+224×2568192+224\times2560.5670.549 +3%0.6761.142 −41%0.7450.682 +9%0.9190.843 +9%
log-unif. 16k0.2260.214 +6%0.2720.401 −32%0.3180.283 +12%0.3980.342 +16%
log-unif. 16k, GQA0.1930.181 +7%0.2320.289 −20%0.2850.250 +14%0.3580.297 +21%
log-unif. 64k1.0630.993 +7%1.2241.626 −25%1.6921.516 +12%1.9831.629 +22%

Table 7. Inference call on packed documents with the bit-level exponentials (B200, 16 heads, d=128d=128): time in ms. Schraudolph: our MXFP8 route with Schraudolph’s exponential, change against MXFP8 in small type; Mitchell-P: the 4-bit P^\hat{\mathrm{P}} route with Mitchell-P, change against our NVFP4 route. Output cosine: 0.9985–0.9990 for MXFP8 with or without Schraudolph’s exponential, 0.980–0.982 for Direct-P against 0.990–0.993 for NVFP4.

Hardware and Software

The kernels, the TorchTitan integration and the scripts that reproduce the benchmark tables are available at https://github.com/yandex-research/flash-attention. Our 4-bit forward kernel starts from the FP4 FlashAttention-4 forward released with Attn-QAT [25] at https://github.com/hao-ai-lab/flash-attention-fp4, which provides its base structure. The optimizations on top of this base are our own: log-domain probability quantization, the split of the next tile’s QKTQK^{\mathsf{T}} around P^V\hat{P}V (Section 3.5) and the bit-level exponentials. So are the 8-bit route, the backward kernels, the packed-document support and the causal-safety mechanisms.

The kernel benchmarks run on NVIDIA B200 (sm_100a) and B300 SXM6 (sm_103a) GPUs, both with 148 SMs, at free-running clocks, with CUDA 13.0, PyTorch 2.14 and CuTe DSL 4.8. The two parts differ in the units our kernels lean on: B300 issues MFU exponentials at 32 per clock per SM against 16 on B200. Both have 512 TMEM columns per SM and 232 KB of shared memory per SM.

Timing

Each time is the median of three paired rounds after a discarded warm-up round. Within a round, the jobs of a row run back to back on the same GPU, in reversed order on every other round, and each call is captured in a CUDA graph. cuDNN FP8 takes all of its scales from the caller. In the training call we compute its QQ, KK, VV and dOdO scales inside the timed call, as we do for our kernels and as a training step on new tensors must. Its output scales must exist before the call, and we calibrate them beforehand on the same data.

Benchmarking Pitfalls

Several effects silently invalidate low-precision attention benchmarks, and each one affected our own measurements before we controlled for it. The benchmark harness of Low Precision FA4 applies no causal discount to FLOPs, so causal throughput in its convention is twice the true value. In its convention, our causal rows read 2617–4885 TFLOP/s, above the GPU’s peak.

cuDNN’s BF16 ragged backward returns wrong gradients when the softmax statistics are padded to the batch shape instead of ragged (dQdQ cosine 0.62 causal, 0.93 non-causal).

cuDNN’s MXFP8 graph has one VV input, but the forward needs VV’s blocks along keys and the backward along the head dimension. Feeding the forward’s layout to the backward gives dQdQ and dKdK cosines of 0.947–0.962 while dVdV stays at 0.9997.

The same kernel source ran 18.6–20.6 % faster or slower under another CuTe DSL version with bitwise-identical output, so every timing is tied to its toolchain.

Replacing a plain TMEM load with SM103’s fused-maximum load changes the instruction stream, and ptxas then contracts other operations differently. Outputs can then change in the last digits even where the loaded values are equal. We therefore gate every speed change bitwise per route, not per kernel family.

System Integration

Both entry points run as torch.library custom operators, so selective activation checkpointing can save the attention outputs instead of re-running the forward and its quantizers in the backward, and torch.compile traces them through a fake implementation. No entry point synchronizes with the host: scales, work lists and stochastic-rounding seeds live on the GPU, so every call can be captured in a CUDA graph, and graph replay is bitwise equal to eager execution.

Training Details

We provide additional details of the training setup used in § 4.6. All runs use the hyperparameters listed in Table 8. The training experiments use PyTorch 2.15.0dev20260928 with the CUDA 13.1 runtime.

HyperparameterValue
Global batch size2202^{20} tokens
Training steps100,000
OptimizerAdamW
Weight decay0.1
Peak learning rate3×10−43 \times10^{-4}
Warmup steps300
Learning-rate decayLinear to zero

Table 8. Training hyperparameters shared by all attention variants.

Non-Causal Packed Documents

Tables 9 to 11 repeat the measurements of § 4.1 on the non-causal version of every workload, where Low Precision FA4 also runs.

GPUDocumentsOurs MXFP8Ours NVFP4FP8 cuDNNFP8 LP-FA4BF16 FA4BF16 cuDNNBF16 SDPASpeedup
B2004×40964 \times40961.46 13151.48 12991.57 12215.97 3221.76 10961.98 9707.36 2611.08×
16×409616 \times40965.80 13265.86 13126.17 124823.3 3316.96 11057.77 99123.5 3281.06×
16×102416 \times10240.56 8640.58 8320.59 8096.82 710.64 7530.65 7416.00 801.07×
64×102464 \times10242.15 8952.20 8742.24 85826.8 722.59 7442.69 7157.71 2501.04×
8192+32×2568192 + 32 \times2561.54 12881.56 12721.72 115210.5 1891.80 10992.18 9127.33 2711.12×
8192+224×2568192 + 224 \times2562.47 9492.51 9333.49 67150.8 463.22 7287.08 33110.2 2311.30×
log-unif. 16k1.11 11361.12 11241.19 10636.89 1831.33 9491.47 8596.17 2041.07×
log-unif. 16k, GQA1.07 11751.10 11441.27 989no GQA1.33 9451.50 841no GQA1.19×
log-unif. 64k5.97 12836.03 12706.38 120026.2 2927.17 10688.17 93724.1 3171.07×
B3004×40964 \times40961.31 14681.33 14421.34 14385.61 3441.71 11281.88 10228.38 2381.02×
16×409616 \times40965.09 15125.19 14835.09 151121.9 3526.51 11827.19 107223.7 3271.00×
16×102416 \times10240.51 9410.54 8930.52 9256.42 750.60 7970.60 8049.04 531.02×
64×102464 \times10241.95 9892.02 9541.94 99125.5 762.42 8612.48 7769.19 2091.00×
8192+32×2568192 + 32 \times2561.36 14611.40 14161.44 13739.64 2061.69 11722.03 9839.43 2171.06×
8192+224×2568192 + 224 \times2562.25 10432.34 10043.13 74847.7 492.99 7846.82 34410.6 2201.33×
log-unif. 16k1.01 12531.02 12341.01 12486.50 1941.27 9891.39 9058.75 1441.00×
log-unif. 16k, GQA0.96 13081.02 12391.08 1170no GQA1.22 10351.37 922no GQA1.12×
log-unif. 64k5.25 14585.35 14315.24 146124.9 3076.74 11377.59 100924.3 3221.00×

Table 9. Training call on packed documents, non-causal, 16 heads, d=128d = 128: time in ms (fastest in bold), TFLOP/s in small type; Speedup: the fastest baseline’s time over ours.

Kernels on B300

Tables 12 and 13 repeat the kernel measurements of § 4.1 on B300.

Batched Attention

Table 14 gives the training call on batched sequences with the baselines of § 4. cuDNN FP8 needs its scales before the call. Over 30 packed and batched shapes, our training call is faster than cuDNN FP8 by a median of 7.4 % when every cuDNN scale is calibrated beforehand, 10.3 % when its input scales are computed in the call, and 112 % when all of its scales are, because computing every scale requires a second forward and backward pass. In the inference call on batched sequences, SchraudoIph’s exponential makes our MXFP8 route 7–26% faster and ahead of cuDNN FP8 on every shape, and at 1×327681 \times32768 non-causal, Mitchell-P takes 4.64 ms against 6.17 ms for our NVFP4 route and 4.68 ms for the fastest 8-bit baseline.

Tables 15 and 16 give the forward and backward kernels alone on the same shapes, with operands quantized outside the timed region. Our backward is the fastest on all twelve B200 rows and on six of twelve B300 rows, where cuDNN FP8 leads the other six by 3–8%. Our forward leads on three B200 rows and on no B300 row. cuDNN FP8 is faster on most

GPUDocumentsOurs MXFP8Ours NVFP48-bit cuDNN FP88-bit cuDNN MX4-bit FA44-bit FP8 FlashInfer4-bit LP-FA4BF16 FlashInferBF16 cuDNNBF16 FlashInferSDPASpeedup
B2004×40960.31 17950.40 13730.31 17570.57 9660.47 11670.29 18980.32 17190.36 15210.40 13840.58 9530.40 13732.37 2320.95×
16×40961.32 16661.58 13921.31 16812.24 9811.87 11761.21 18111.42 15531.46 15101.78 12382.22 9891.74 12616.51 3380.92×
16×10240.10 14520.12 11910.11 12440.25 5480.15 9110.11 13020.11 12750.12 11760.13 10440.19 7210.13 10441.89 731.12×
64×10240.35 15730.44 12470.37 14961.11 4940.60 9180.42 13210.37 14880.44 12440.53 10370.91 6050.52 10522.40 2291.05×
8192 + 32×2560.34 16650.45 12740.37 15160.60 9470.51 11100.47 12200.41 13930.43 13240.42 13470.53 10720.52 10862.48 2291.10×
8192 + 224×2560.42 15880.52 12960.57 11733.51 1910.79 8520.73 9220.48 13840.93 9700.69 7193.48 1920.82 8203.12 2151.15×
log-unif. 16k0.22 16060.29 12440.25 14620.46 7860.36 9990.25 14270.28 12850.30 12030.30 12010.42 8460.32 11412.01 1791.10×
log-unif. 16k, GQA0.22 16040.29 12440.25 14640.46 7880.28 12880.35 1034no GQA0.30 12050.29 12500.44 9410.38 941no GQA1.10×
log-unif. 64k1.36 16111.62 13491.35 16252.43 8991.93 11371.44 15181.44 15201.55 14141.82 12032.40 9121.93 11346.65 3290.99×
B3004×40960.24 23170.32 17330.23 23760.23 23710.31 17690.23 23980.30 18320.32 17110.36 15130.54 10100.36 15143.13 2280.97×
16×40960.92 23581.25 17620.84 24290.95 23261.23 17950.95 23201.17 19041.27 17341.56 14082.05 10711.57 13986.96 3180.97×
16×10240.08 17850.10 14480.09 15330.08 17150.11 12440.09 15850.09 14960.10 13300.12 11010.18 7420.12 11282.56 461.04×
64×10240.29 19180.36 15200.28 19440.28 19780.44 12560.33 16600.34 16430.39 13960.49 11130.84 6510.47 11822.92 1920.97×
8192 + 32×2560.27 21120.36 15680.27 20960.41 13850.33 17360.39 14450.33 17050.38 14900.39 14630.53 10760.44 12972.87 1561.01×
8192 + 224×2560.36 18600.46 14750.47 14401.53 4390.58 11500.62 10750.44 15060.82 8210.64 10463.37 1990.68 9813.37 1991.24×
log-unif. 16k0.18 20200.23 15600.18 19490.21 17540.24 14980.20 17690.26 13940.27 13470.28 12900.43 8430.29 12232.84 1261.04×
log-unif. 16k, GQA0.17 20640.23 15640.18 19920.20 17630.24 14930.30 1185no GQA0.27 13550.24 14500.33 880no GQA1.04×
log-unif. 64k0.95 23001.27 17160.93 23611.04 20941.27 17231.06 20371.14 17541.25 16091.46 13341.74 9231.72 12837.12 3150.97×

Table 10. Forward kernel on packed documents, non-causal, 16 heads, d=128d = 128: time in ms (fastest in bold), TFLOP/s in small type; Speedup: the fastest baseline’s time over ours. cuDNN MX: cuDNN MXFP8; LP-FA4: Low Precision FA4; FlashInfer: its fastest backend;

GPUDocumentsOurs MXFP8Ours NVFP4FP8 cuDNNFP8 LP-FA4BF16 FA4BF16 cuDNNBF16 SDPASpeedup
B2004×40960.92 14990.86 16001.09 12631.12 12281.25 11031.34 10284.27 3221.27×
16×40963.87 14203.69 14884.44 12384.71 11675.07 10855.50 99916.8 3281.20×
16×10240.31 11140.30 11270.37 9370.47 7320.46 7560.40 8532.44 1411.20×
64×10241.21 11381.18 11671.38 10001.86 7371.91 7211.74 7914.72 2911.17×
8192 + 32×2560.93 15240.91 15641.21 11751.19 11881.30 10891.53 9274.62 3071.32×
8192 + 224×2561.37 12211.34 12462.48 6752.00 8362.44 6883.60 4656.86 2441.49×
log-unif. 16k0.67 13470.65 13940.78 11620.94 9600.87 10370.93 9643.08 2921.20×
log-unif. 16k, GQA0.72 12410.71 12640.91 993no GQA0.93 9731.00 901no GQA1.27×
log-unif. 64k3.95 13853.78 14474.60 11895.15 10625.20 10525.70 95917.2 3181.22×
B3004×40960.88 15700.84 16260.85 16131.05 13041.13 11391.32 10884.26 3221.01×
16×40963.55 15333.43 15883.63 15164.15 13264.80 11365.25 108816.2 3401.06×
16×10240.30 11590.29 11830.32 10790.45 7710.44 7760.38 9012.34 881.09×
64×10241.14 12071.12 12241.19 11521.75 7851.78 7981.68 8524.57 2951.06×
8192 + 32×2560.91 15550.88 16130.99 14381.08 13081.17 12351.43 9964.47 3161.12×
8192 + 224×2561.33 12691.30 12952.25 7461.85 9052.27 7343.45 4866.50 2581.43×
log-unif. 16k0.65 13760.63 14250.65 13760.89 10150.88 10210.88 10123.83 2121.03×
log-unif. 16k, GQA0.68 13350.67 13380.79 1133no GQA0.84 10730.90 1043no GQA1.17×
log-unif. 64k3.66 15063.53 15483.77 14484.70 11664.99 10975.42 104216.6 3301.07×

Table 11. Backward kernels on packed documents, non-causal, 16 heads, d=128d = 128: time in ms (fastest in bold), TFLOP/s in small type; Speedup: the fastest baseline’s time over ours.

GPUDocumentsMXFP8NVFP4cuDNN FP8cuDNN MXFA4FP8 FlashInferFlashInfer FA4cuDNNFlashInferSDPASpeedup
B3004×40960.14 19500.18 15630.18 15120.15 17780.22 12320.20 13820.21 12840.22 12620.38 7230.24 11402.98 921.10×
16×40960.56 19560.67 16400.55 19920.57 19210.87 12700.71 15410.75 14660.91 11541.38 7950.96 11704.34 2570.98×
16×10240.06 11700.07 10420.09 7610.08 9000.10 6890.13 5180.09 7980.11 6510.21 3220.14 4872.97 231.30×
64×10240.21 13030.23 11950.28 9990.26 10700.39 7080.52 5290.30 9110.41 6651.01 2710.55 5032.74 911.22×
8192 + 32×2560.14 19560.18 15630.22 12990.43 6600.23 12380.33 8580.26 11060.22 12940.40 7160.37 7692.56 1111.51×
8192 + 224×2560.24 14190.28 12030.40 8402.19 1530.52 12380.60 5580.75 4440.53 6353.47 970.69 4832.99 1101.69×
log-unif. 16k0.11 16340.14 13310.15 11760.16 11020.18 10020.18 9730.17 10820.18 10190.33 5640.21 8473.02 571.39×
log-unif. 16k, GQA0.11 16490.13 13440.15 11610.16 11160.15 11740.30 5950.16 10920.15 12250.31 5870.35 517no GQA1.35×
log-unif. 64k0.58 19190.70 15560.60 18270.78 14010.90 12180.81 13590.81 13510.99 12621.56 7021.06 10324.55 2401.05×

Table 12. B300. Forward kernel on packed documents, causal, 16 heads, d=128d = 128: time in ms (fastest in bold), TFLOP/s in small type; Speedup: the fastest baseline’s time over ours. cuDNN MX: cuDNN MXFP8; FlashInfer: its fastest backend.

GPUDocumentsMXFP8NVFP4cuDNNFA4cuDNNSDPASpeedup
B3004×40960.51 13510.49 14040.61 11210.66 10480.71 9633.96 1641.25×
16×40962.04 13471.96 14132.30 11962.90 9483.10 8968.90 3081.18×
16×10240.22 7830.22 7990.27 6300.35 4940.30 5733.85 441.26×
64×10240.84 8200.83 8290.96 7131.38 4991.12 6203.68 1751.17×
8192 + 32×2560.52 13630.50 14190.74 9540.67 10550.99 7153.71 1641.34×
8192 + 224×2560.93 9000.92 9131.99 4221.83 4573.00 2794.69 1802.00×
log-unif. 16k0.40 11280.39 11660.51 8810.53 8470.55 8163.39 1331.33×
log-unif. 16k, GQA0.45 9920.44 10160.64 7050.56 8020.58 770no GQA1.27×
log-unif. 64k2.09 13122.01 13662.49 11022.98 9243.21 8639.16 2981.24×

Table 13. B300. Backward kernels on packed documents, causal, 16 heads, d=128d = 128: time in ms (fastest in bold), TFLOP/s in small type; Speedup: the fastest baseline’s time over ours.

rows, and without a causal mask the 4-bit Direct-P forward of HW-FP4 FA4 is the fastest on every MHA row with d=128d = 128.

GPUShapeOurs MXFP8Ours NVFP4cuDNN FP8 cal.cuDNN FP8 fresh in.cuDNN FP8 all freshLP-FA4 MXFP8FA4 MXFP8cuDNN BF16Speedup
B2004×4096, 16 h, d=128d=128, causal0.87 11080.87 11050.88 10960.91 10591.74 5531.25 767no causal1.05 8921.05×
4×4096, 16 h, d=128d=128, non-causal1.41 13631.41 13641.41 13641.44 13372.79 6891.85 10376.12 3151.68 11481.02×
1×32768, 16 h, d=128d=128, causal9.88 15589.99 154110.6 144710.7 144021.1 73012.6 1223no causal12.6 11451.08×
1×32768, 16 h, d=128d=128, non-causal19.1 161519.0 161720.0 154020.0 154039.6 77823.9 128828.6 107723.8 12941.05×
2×8192, 16 h, d=128d=128, causal1.45 13261.45 13271.53 12591.56 12313.03 6362.03 948no causal1.79 10731.08×
2×8192, 16 h, d=128d=128, non-causal2.59 14842.56 15032.63 14632.67 14445.22 7383.32 11606.99 5513.13 12311.04×
1×16384, 16 h, d=128d=128, causal2.64 14562.61 14732.81 13702.85 13515.58 6903.54 1088no causal3.34 11541.09×
1×16384, 16 h, d=128d=128, non-causal4.94 15584.87 15815.06 15205.09 151310.0 7666.20 12429.29 8286.16 12491.05×
4×4096, 16/4 h, d=128d=128, causal0.80 12000.82 11780.96 10050.98 9851.90 5061.24 776no causal1.08 8921.22×
4×4096, 16/4 h, d=128d=128, non-causal1.08 13361.04 13421.50 12851.52 12682.98 6461.86 1035no GQA1.72 10931.06×
4×4096, 16 h, d=64d=64, causal0.66 7400.70 6920.72 6640.74 6471.47 329no d=64d=64no causal0.72 6701.10×
4×4096, 16 h, d=64d=64, non-causal1.08 8871.15 8361.19 8061.21 7932.40 400no d=64d=64no d=64d=641.20 7521.11×
B3004×4096, 16 h, d=128d=128, causal0.79 12200.80 12080.73 13160.75 12791.42 6761.13 853no causal0.95 10120.95×
4×4096, 16 h, d=128d=128, non-causal1.20 15581.25 15401.04 16861.07 18052.05 8601.49 12935.75 3351.38 14540.89×
1×32768, 16 h, d=128d=128, causal8.68 17748.89 17318.49 18138.57 181016.7 92010.8 1420no causal11.7 13160.99×
1×32768, 16 h, d=128d=128, non-causal15.8 187916.4 185016.5 179215.0 209634.0 93519.3 174225.4 121222.6 13610.95×
2×8192, 16 h, d=128d=128, causal1.27 15201.31 14671.11 17331.14 16902.20 8751.73 1111no causal1.41 13630.90×
2×8192, 16 h, d=128d=128, non-causal2.17 17772.24 17201.86 20661.89 17883.68 10442.54 14136.59 5922.43 15860.87×
1×16384, 16 h, d=128d=128, causal2.37 16262.37 16232.26 17022.28 16914.44 8673.08 1285no causal3.07 12550.96×
1×16384, 16 h, d=128d=128, non-causal4.33 17754.31 17874.16 18514.18 18408.17 9415.13 15008.58 8965.71 13480.97×
4×4096, 16/4 h, d=128d=128, causal0.72 13380.74 13080.80 12100.81 11841.58 6081.12 857no causal0.97 9901.13×
4×4096, 16/4 h, d=128d=128, non-causal1.26 15301.29 14861.25 15461.26 15252.46 7811.57 1222no GQA1.61 11651.00×
4×4096, 16 h, d=64d=64, causal0.58 8300.65 7440.58 8270.59 8091.16 416no d=64d=64no causal0.74 7711.02×
4×4096, 16 h, d=64d=64, non-causal0.94 10201.00 9640.92 10470.93 10321.83 526no d=64d=64no d=64d=641.01 9510.99×

Table 14. Training call on batched sequences (forward and backward, quantization included): time in ms (fastest in bold), TFLOP/s in small type. cuDNN FP8 with every scale calibrated beforehand, with its input scales computed in the call, and with every scale computed in the call. Speedup: the fastest baseline’s time, with cuDNN FP8 computing its input scales, over ours.

GPUShapeOurs MXFP8Ours NVFP4Ours Direct-P4-bit FlashInfer8-bit cuDNN FP88-bit cuDNN MX8-bit FA4 FP88-bit FlashInferBF16 LP-FA4BF16 FA4BF16 cuDNNBF16 FlashInferBF16 SDPABF16 LP-FA4Speedup
B2004×40964 \times4096, 16 h, d=128d=128, causal0.17 / 16620.21 / 1283no causal0.24 / 11420.18 / 15510.32 / 8530.20 / 13410.23 / 1211no causal0.23 / 12100.28 / 9760.25 / 10870.22 / 12680.23 / 12091.07×
4×40964 \times4096, 16 h, d=128d=128, non-causal0.30 / 18130.40 / 13920.20 / 26770.36 / 15170.29 / 18780.39 / 14260.35 / 15470.29 / 19020.32 / 17160.37 / 14900.39 / 13970.40 / 13910.37 / 15020.50 / 11020.68×
1×327681 \times32768, 16 h, d=128d=128, causal2.54 / 17293.04 / 1449no causal2.88 / 15302.49 / 17653.06 / 14352.57 / 17142.55 / 1728no causal3.26 / 13493.71 / 11843.23 / 13603.26 / 13503.27 / 13460.98×
1×327681 \times32768, 16 h, d=128d=128, non-causal5.15 / 17086.00 / 14663.11 / 28325.36 / 16424.85 / 18145.61 / 15695.28 / 16684.60 / 19145.20 / 16926.34 / 13876.81 / 12925.91 / 14906.21 / 14158.47 / 10380.60×
2×81922 \times8192, 16 h, d=128d=128, causal0.31 / 17850.41 / 1358no causal0.43 / 12740.31 / 17780.54 / 10180.35 / 15800.37 / 1481no causal0.40 / 13910.50 / 10970.43 / 12750.39 / 14260.40 / 13901.00×
2×81922 \times8192, 16 h, d=128d=128, non-causal0.60 / 18330.77 / 14250.40 / 27670.69 / 16050.56 / 19550.73 / 15020.69 / 15950.54 / 20390.67 / 16310.73 / 15050.80 / 13810.78 / 14100.72 / 15251.01 / 10880.66×
1×163841 \times16384, 16 h, d=128d=128, causal0.59 / 18670.79 / 1401no causal0.81 / 13650.58 / 18960.98 / 11250.64 / 17320.65 / 1688no causal0.78 / 14091.01 / 10910.83 / 13230.75 / 14710.76 / 14560.98×
1×163841 \times16384, 16 h, d=128d=128, non-causal1.25 / 17611.52 / 14480.79 / 28021.34 / 16361.22 / 18061.43 / 15431.34 / 16361.08 / 20301.32 / 16631.59 / 13871.71 / 12841.59 / 13781.56 / 14062.14 / 10290.63×
4×40964 \times4096, 16/4 h, d=128d=128, causal0.16 / 16760.21 / 1284no causal0.24 / 11450.18 / 15560.28 / 9700.19 / 14310.23 / 1222no causal0.21 / 13010.25 / 11120.25 / 11140.21 / 13050.21 / 13091.08×
4×40964 \times4096, 16/4 h, d=128d=128, non-causal0.30 / 18140.40 / 13930.36 / 15260.29 / 18810.39 / 14270.35 / 15580.29 / 19000.36 / 1525no GQA0.36 / 15250.40 / 13910.38 / 14640.37 / 14980.49 / 11230.95×
4×40964 \times4096, 16 h, d=64d=64, causal0.19 / 7370.22 / 638no causal0.21 / 8090.17 / 809no d=64d=640.18 / 7430.26 / 532no causal0.19 / 7190.28 / 4960.29 / 4730.17 / 8070.19 / 7100.91×
4×40964 \times4096, 16 h, d=64d=64, non-causal0.31 / 8820.37 / 736no d=64d=640.32 / 8480.29 / 959no d=64d=640.31 / 8950.36 / 753no d=64d=640.29 / 9440.37 / 7350.41 / 6730.29 / 9600.30 / 9120.92×
B3004×40964 \times4096, 16 h, d=128d=128, causal0.13 / 20480.17 / 1603no causal0.21 / 12770.13 / 20480.28 / 9800.19 / 14590.17 / 1626no causal0.20 / 14010.24 / 11290.21 / 12900.18 / 15150.21 / 13010.99×
4×40964 \times4096, 16 h, d=128d=128, non-causal0.23 / 24200.31 / 12770.20 / 27630.32 / 17020.21 / 20210.27 / 10270.28 / 12780.23 / 19770.30 / 18360.30 / 18490.33 / 14560.35 / 13710.30 / 18460.30 / 18200.88×
1×327681 \times32768, 16 h, d=128d=128, causal1.90 / 23392.40 / 1832no causal2.48 / 17741.80 / 24442.52 / 17442.21 / 19901.94 / 2265no causal2.88 / 15273.11 / 14153.02 / 14552.82 / 15622.91 / 15100.95×
1×327681 \times32768, 16 h, d=128d=128, non-causal3.50 / 25154.66 / 18873.01 / 29274.37 / 20113.06 / 28723.73 / 23553.91 / 22483.11 / 26753.81 / 22974.46 / 19994.97 / 17684.87 / 17934.66 / 19114.50 / 19540.86×
2×81922 \times8192, 16 h, d=128d=128, causal0.24 / 22560.32 / 1712no causal0.38 / 14470.23 / 24310.46 / 12080.32 / 17120.29 / 1914no causal0.34 / 16120.42 / 13010.38 / 14360.32 / 17030.34 / 15940.93×
2×81922 \times8192, 16 h, d=128d=128, non-causal0.45 / 24260.60 / 18410.38 / 28590.60 / 18250.40 / 27630.50 / 22100.54 / 20520.41 / 26510.55 / 19860.57 / 19170.64 / 17310.66 / 16630.57 / 19210.58 / 19090.85×
1×163841 \times16384, 16 h, d=128d=128, causal0.46 / 23780.62 / 1777no causal0.70 / 15690.41 / 26610.81 / 13670.58 / 18820.50 / 2228no causal0.64 / 17180.81 / 13580.73 / 14730.61 / 17980.65 / 16850.89×
1×163841 \times16384, 16 h, d=128d=128, non-causal0.88 / 24941.17 / 18730.76 / 29001.17 / 18730.80 / 28370.96 / 22931.04 / 21420.84 / 26251.03 / 21361.32 / 17221.46 / 15071.45 / 15421.34 / 16431.36 / 17490.86×
4×40964 \times4096, 16/4 h, d=128d=128, causal0.13 / 20810.17 / 1609no causal0.21 / 12840.13 / 20770.25 / 10820.18 / 15500.17 / 1655no causal0.18 / 15320.22 / 12720.23 / 13410.17 / 15750.18 / 15140.99×
4×40964 \times4096, 16/4 h, d=128d=128, non-causal0.23 / 24220.31 / 1786no GQA0.32 / 17150.21 / 26260.27 / 20410.28 / 19750.23 / 2411no GQA0.29 / 18780.33 / 16610.34 / 16420.30 / 18590.30 / 18270.93×
4×40964 \times4096, 16 h, d=64d=64, causal0.14 / 9730.20 / 698no GQA0.16 / 8710.12 / 1134no d=64d=640.18 / 7640.23 / 587no causal0.14 / 9680.23 / 5880.25 / 5530.14 / 9850.15 / 8880.87×
4×40964 \times4096, 16 h, d=64d=64, non-causal0.23 / 12110.28 / 967no d=64d=640.23 / 11690.19 / 1416no d=64d=640.23 / 11740.29 / 942no d=64d=640.23 / 12210.31 / 8860.31 / 8970.23 / 11990.23 / 11780.85×

Table 15. Forward kernel on batched sequences, kernels alone with operands quantized outside the timed region: time in ms (fastest in bold), TFLOP/s in small type. FlashInfer: its fastest backend, FlashInfer 4-bit: NVFP4 KV cache. Speedup: the fastest baseline’s time over ours.

GPUShapeOurs MXFP8Ours NVFP48-bit FP88-bit MX8-bit LP-FA4BF16 MXFP8BF16 FA4BF16 cuDNNBF16 SDPABF16 LP-FA4Speedup
B2004×40964\times4096, 16 h, d=128d=128, causal0.53<br>12990.51<br>13560.57<br>12130.64<br>1078no causal0.71<br>9710.64<br>10760.75<br>10720.70<br>985—1.12×
4×40964\times4096, 16 h, d=128d=128, non-causal0.87<br>15750.83<br>16590.94<br>14691.12<br>12241.14<br>12101.19<br>11531.24<br>11111.29<br>10631.51<br>909—1.13×
1×327681\times32768, 16 h, d=128d=128, causal7.03<br>15656.65<br>16547.95<br>13849.00<br>1221no causal9.28<br>11859.61<br>11449.63<br>11419.15<br>1202—1.20×
1×327681\times32768, 16 h, d=128d=128, non-causal13.6<br>162113.0<br>168714.6<br>151017.6<br>124715.9<br>137917.3<br>127018.6<br>118318.7<br>117822.7<br>967—1.12×
2×81922\times8192, 16 h, d=128d=128, causal0.90<br>15230.86<br>15901.03<br>13381.21<br>1136no causal1.28<br>10761.20<br>11501.31<br>10521.20<br>1142—1.19×
2×81922\times8192, 16 h, d=128d=128, non-causal1.73<br>15871.63<br>16821.86<br>14742.25<br>12192.11<br>13052.25<br>12192.40<br>11452.45<br>11242.91<br>944—1.14×
1×163841\times16384, 16 h, d=128d=128, causal1.79<br>15381.67<br>16482.04<br>13502.32<br>1185no causal2.43<br>11312.43<br>11302.50<br>11012.38<br>1153—1.22×
1×163841\times16384, 16 h, d=128d=128, non-causal3.40<br>16173.19<br>17253.66<br>15014.41<br>12464.09<br>13454.43<br>12404.70<br>11714.82<br>11405.75<br>956—1.15×
4×40964\times4096, 16/4 h, d=128d=128, causal0.50<br>13840.47<br>14520.69<br>10000.75<br>918no causal0.76<br>9030.66<br>10420.77<br>891n.m.—1.39×
4×40964\times4096, 16/4 h, d=128d=128, non-causal0.96<br>14260.92<br>14921.06<br>12921.27<br>1085no GQA1.26<br>10931.26<br>10921.34<br>1024n.m.—1.16×
4×40964\times4096, 16 h, d=64d=64, causal0.42<br>8210.41<br>8390.50<br>684no d=64d=64no causal0.50<br>6910.43<br>7930.49<br>6970.61<br>562—1.06×
4×40964\times4096, 16 h, d=64d=64, non-causal0.73<br>9430.71<br>9700.86<br>801no d=64d=64no d=64d=640.82<br>8400.80<br>8580.89<br>7751.03<br>667—1.13×
B3004×40964\times4096, 16 h, d=128d=128, causal0.52<br>13130.50<br>13860.46<br>14960.57<br>1199no causal0.64<br>10800.59<br>11690.59<br>11670.77<br>891—0.93×
4×40964\times4096, 16 h, d=128d=128, non-causal0.84<br>16260.80<br>17160.73<br>18690.94<br>14671.05<br>13091.02<br>13471.03<br>13261.04<br>13241.35<br>1024—0.92×
1×327681\times32768, 16 h, d=128d=128, causal6.43<br>17096.20<br>17736.48<br>17437.97<br>1380no causal8.69<br>12669.21<br>11939.27<br>118510.2<br>1083—1.05×
1×327681\times32768, 16 h, d=128d=128, non-causal11.8<br>186311.4<br>193610.7<br>206713.5<br>164612.9<br>170713.9<br>158614.9<br>147115.0<br>146719.6<br>1068—0.94×
2×81922\times8192, 16 h, d=128d=128, causal0.90<br>15240.85<br>16140.79<br>17341.00<br>1380no causal1.05<br>13051.03<br>13321.03<br>13281.31<br>1053—0.92×
2×81922\times8192, 16 h, d=128d=128, non-causal1.59<br>17331.50<br>18371.37<br>20011.76<br>15631.85<br>14881.86<br>14831.96<br>14091.96<br>14052.52<br>1093—0.92×
1×163841\times16384, 16 h, d=128d=128, causal1.70<br>16161.59<br>17371.67<br>16442.02<br>1361no causal2.21<br>12482.32<br>11872.32<br>11912.58<br>1069—1.05×
1×163841\times16384, 16 h, d=128d=128, non-causal3.16<br>17402.96<br>18553.06<br>17953.76<br>14613.67<br>14994.18<br>13144.43<br>12394.44<br>13295.30<br>1042—1.03×
4×40964\times4096, 16/4 h, d=128d=128, causal0.48<br>14280.47<br>14670.57<br>12040.69<br>1004no causal0.68<br>10060.62<br>11230.61<br>11180.82<br>838—1.22×
4×40964\times4096, 16/4 h, d=128d=128, non-causal0.91<br>15080.89<br>15410.87<br>15821.06<br>1273no GQA1.17<br>12661.19<br>11781.16<br>11871.41<br>977—0.97×
4×40964\times4096, 16 h, d=64d=64, causal0.40<br>8650.38<br>9020.41<br>846no d=64d=64no causal0.47<br>7280.42<br>8090.47<br>7340.55<br>628—1.07×
4×40964\times4096, 16 h, d=64d=64, non-causal0.67<br>10250.65<br>10650.67<br>1027no d=64d=64no d=64d=640.78<br>8840.79<br>8710.83<br>8320.91<br>752—1.04×

Table 16. Backward kernels on batched sequences, kernels alone with operands quantized outside the timed region: time in ms (fastest in bold), TFLOP/s in small type. Speedup: the fastest baseline’s time over ours.

References

  1. [1]Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention Is All you Need. In I. G. Guyon, U. Von Luxburg, S. Bengio, H. Wallach, R. Fergus, S. Vishwanathan, and R. Garnett, editors, Advances in Neural Information Processing Systems, volume 30. Curran Associates, Inc., 2017. URL https://proceedings.neurips.cc/paper_files/paper/2017/file/3f5ee243547dee91fbd053c1c4a845aa-Paper.pdf.arxiv.org/abs/1706.03762
  2. [2]Tri Dao, Dan Fu, Stefano Ermon, Atri Rudra, and Christopher Ré. FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness. In S. Koyeko, S. Mohamed, A. Agarwal, D. Belgrave, K. Cho, and A. Oh, editors, Advances in Neural Information Processing Systems, volume 35, pages 16344–16359. Curran Associates, Inc., 2022. ISBN 9781713871088. doi: 10.52202/068431-1189. URL https://proceedings.neurips.cc/paper_files/paper/2022/file/67d57c32e20fd0a7a302cb81d36e40d5-Paper-Conference.pdf.DOI
  3. [3]Ted Zadouri, Markus Hoehnerbach, Jay Shah, Vijay Thakkar, and Tri Dao. FlashAttention-4: Algorithm and Kernel Pipelining Co-Design for Asymmetric Hardware Scaling. In A. Chowdhery and Z. Jia, editors, Proceedings of Machine Learning and Systems, volume 8, pages 912–926. MLSys, 2026. doi: 10.48550/arXiv.2603.05451. URL https://arxiv.org/abs/2603.05451.
  4. [4]NVIDIA. NVIDIA Blackwell Tuning Guide. October 2026. URL https://docs.nvidia.com/cuda/blackwell-tuning-guide/index.html. Accessed 2026-10-21.
  5. [5]Robert Hu. Hardware-Aware FP4 FlashAttention-4. arXiv e-prints, art. arXiv:2609.04105, September 2026. doi: 10.48550/arXiv.2609.04105. URL https://arxiv.org/abs/2609.04105.
  6. [6]Oleksandr Stashuk, Hongtao Yu, and Jay Shah. Efficient FlashAttention on Blackwell via Fixed-Shift Softmax and Persistent Scheduling. arXiv e-prints, art. arXiv:2610.02229, September 2026. doi: 10.48550/arXiv.2610.02229. URL https://arxiv.org/abs/2610.02229.
  7. [7]Zihao Ye, Lequn Chen, Ruihang Lai, Wuwei Lin, Yineng Zhang, Stephanie Wang, Tianqi Chen, Baris Kasikci, Vinod Grover, Arvind Krishnamurthy, and Luis Ceze. FlashInfer: Efficient and Customizable Attention Engine for LLM Inference Serving. In M. Zaharia, G. Joshi, and Y. Lin, editors, Proceedings of Machine Learning and Systems, volume 7. MLSys, 2025. URL https://proceedings.mlsys.org/paper_files/paper/2025/file/dbf02b21d77409a2db30e56866a8ab3a-Paper-Conference.pdf.arxiv.org/abs/2501.01005
  8. [8]NVIDIA. NVIDIA cuDNN (fused attention / SDPA, FP8), October 2026. URL https://docs.nvidia.com/deeplearning/cudnn/. Accessed 2026-10-21.
  9. [9]Devashish Shankar, Darren Liu, Chunzhi Yang, Jiaqi Xu, Markus Hoehnerbach, Jason Xie, Santosh Mohan, Han Xu, Rich Zhu, Josh Fromm, Hongtao Yu, Max Leung, John Bocharov, and Alan Purvis. Low Precision Flash Attention 4: End-to-End Block-Scaled Attention for Blackwell, October 2026. URL https://pytorch.org/blog/low-precision-flash-attention-4-end-to-end-block-scaled-attention-for-blackwell/. Accessed 2026-10-21.
  10. [10]Tri Dao. FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning. In B. Kim, Y. Yue, S. Chaudhuri, K. Fragkiadaki, M. Khan, and Y. Sun, editors, International Conference on Learning Representations, volume 2024, pages 35549–35562, 2024. doi: 10.48550/arXiv.2307.08691. URL https://proceedings.iclr.cc/paper_files/paper/2024/file/98ed250b203d1ac6b24bbcf263e3d4a7-Paper-Conference.pdf.DOI
  11. [11]Jay Shah, Ganesh Bikshandi, Ying Zhang, Vijay Thakkar, Pradeep Ramani, and Tri Dao. FlashAttention-3: Fast and Accurate Attention with Asynchrony and Low-precision. In A. Globerson, L. Mackey, D. Belgrave, A. Fan, U. Paquet, J. Tomczak, and C. Zhang, editors, Advances in Neural Information Processing Systems, volume 37, pages 68658–68685. Curran Associates, Inc., 2024. doi: 10.52202/079017-2193. URL https: //proceedings.neurips.cc/paper_files/paper/2024/file/7ede97c3e082c6df10a8d6103a2eebd2-Paper-Conference.pdf.
  12. [12]Bita Darvish Rouhani, Ritchie Zhao, Ankit More, Mathew Hall, Alireza Khodamoradi, Summer Deng, Dhruv Choudhary, Marius Cornea, Eric Dellinger, Kristof Denolf, Stosic Dusan, Venmugil Elango, Maximilian Golub, Alexander Heinecke, Phil James-Roxby, Dharmesh Jani, Gaurav Kolhe, Martin Langhammer, Ada Li, Levi Melnick, Maral Mesmakhosroshahi, Andres Rodriguez, Michael Schulte, Rasoul Shaipour, Lei Shao, Michael Siu, Pradeep Dubey, Paulius Mickevicius, Maxim Naumov, Colin Verrilli, Ralph Wittig, Doug Burger, and Eric Chung. Microscaling Data Formats for Deep Learning. arXiv e-prints, art. arXiv:2310.10537, October 2023. doi: 10.48550/arXiv.2310.10537. URL https://arxiv.org/abs/2310.10537.
  13. [13]NVIDIA, Felix Abecassis, Anjulie Agrusa, Dong Ahn, Jonah Alben, Stefania Alborghetti, Michael Andersch, Sivakumar Arayandi, Alexis Björlin, Aaron Blakenem, Evan Briones, Ian Buck, Bryan Catanzaro, Muya Chang, Jinhang Choi, Mike Chrzanowski, Eric Chung, Victor Cui, Steve Dai, Bita Darvish Rouhani, Carlo del Mundo, Deena Donia, Burc Eryilmaz, Henry Estela, Abhinav Goel, Oleg Goncharov, Yugi Guvvala, Robert Hesse, Russell Hewett, Herbert Hum, Ujval Kapasi, Brucek Khailany, Mikail Khona, Nick Knight, Alex Kondratenko, Ronny Krashinsky, Ben Lanir, Simon Layton, Michael Lightstone, Daniel Lo, Paulius Mickevicius, Asit Mishra, Tim Moon, Deepak Narayanan, Chao Ni, Abhijit Paithankar, Satish Pasumarthi, Ankit Patel, Mostofa Patwary, Ashwin Poojar y, Gargi Prasad, Sweta Priyadarshi, Yigong Qin, Xiaowei Ren, Oleg Rybakov, Charbel Sakr, Sanjeev Satheesh, Stas Sergienko, Pasha Shamis, Kirthi Shankar, Nishant Sharma, Mohammad Shoeybi, Michael Siu, Misha Smelyanskiy, Darko Stosic, Dusan Stosic, Bor-Ying Su, Frank Sun, Nima Tajbakhsh, Shelby Thomas, Przemek Tredak, Evgeny Tsykunov, Gandhi Vaithilingam, Aditya Vavre, Rangharajan Venkatesan, Roger Waleffe, Qiyu Wan, Hexin Wang, Mengdi Wang, Lizzie Wei, Hao Wu, Evan Wu, Keith Wyss, Ning Xu, Jinze Xue, Charlene Yang, Yujia Zhai, Ruoxi Zhang, Jingyang Zhu, and Zhongbo Zhu. Pretraining Large Language Models with NVFP4, September 2025. URL https://arxiv.org/abs/2509.25149.
  14. [14]Vage Egiazar ian, Roberto Castro, Denis Kuznedelev, Andrei Panferov, Eldar Kurtic, Shubhra Pandit, Alexandre Marques, Mark Kurtz, Saleh Ashkboos, Torsten Hoefler, and Dan Alistarh. Bridging the Gap Between Promise and Performance for Microscaling FP4 Quantization. In C. Vondrick, B. Hariharan, C. Raffel, L. Pinto, D. Yang, and A. Faust, editors, International Conference on Learning Representations, volume 2026, pages 113529–113563, 2026. doi: 10.48550/arXiv.2509.23202. URL https://proceedings.iclr.cc/paper_files/paper/2026/file/b87bb4f6346d727b265088235e5bc389-Paper-Conference.pdf.
  15. [15]Albert Tseng, Tao Yu, and Youngsuk Park. Training LLMs with MXFP4. In Yingzhen Li, Stephan Mandt, Shipra Agrawal, and Emtiyaz Khan, editors, Proceedings of The 28th International Conference on Artificial Intelligence and Statistics, volume 258 of Proceedings of Machine Learning Research, pages 1630–1638. PMLR, May 2025. URL https://proceedings.mlr.press/v258/tseng25a.html.arxiv.org/abs/2502.20586
  16. [16]Roberto Castro, Andrei Panferov, Rush Tabesh, Olivier Sieberling, Jiale Chen, Mahdi Nikdan, Saleh Ashkboos, and Dan Alistarh. Quartet: Native FP4 Training Can Be Optimal for Large Language Models. In D. Belgrave, C. Zhang, H. Lin, R. Pascanu, P. Koniusz, M. Ghassemi, and N. Chen, editors, Advances in Neural Information Processing Systems, volume 38, Main Conference, pages 43552–43572. Curran Associates, Inc., 2025. doi: 10.52202/085713-1449. URL https://proceedings.neurips.cc/paper_files/paper/2025/file/3e11872d3bc9bfba34e1752fef87639c-Paper-Conference.pdf.DOI
  17. [17]Andrei Panferov, Erik Schultheis, Soroush Tabesh, and Dan Alistarh. Quartet II: Accurate LLM Pre-Training in NVFP4 by Improved Unbiased Gradient Estimation. In Tong Zhang, Miroslav Dudík, Martin Jaggi, Alekh Agarwal, Sharon Li, Dale Schuurmans, Jerry Zhu, Felix Berkenkamp, Hanze Dong, and Alberto Bietti, editors, Proceedings of the 43rd International Conference on Machine Learning, volume 306 of Proceedings of Machine Learning Research, pages 96275–96290. PMLR, July 2026. URL https://proceedings.mlr.press/v306/panferov26a.html.arxiv.org/abs/2601.22813
  18. [18]Brian Chmiel, Maxim Fishman, Ron Banner, and Daniel Soudry. FP4 All the Way: Fully Quantized Training of Large Language Models. In D. Belgrave, C. Zhang, H. Lin, R. Pascanu, P. Koniusz, M. Ghassemi, and N. Chen, editors, Advances in Neural Information Processing Systems, volume 38, Main Conference, pages 91130–91151. Curran Associates, Inc., 2025. doi: 10.52202/085713-3049. URL https://proceedings.neurips.cc/paper_files/paper/2025/file/8340b085045cf13f1f0b6c2c4cc0a89c-Paper-Conference.pdf.DOI
  19. [19]Siyu Ding, Mingchuan Ma, Jiabo Tong, Xingrun Xing, Ziming Wang, and Guoqi Li. Full-Stack FP4: Stable LLM Pretraining with Quantized Projections, Optimizers, and Attention. arXiv preprint, 2026. doi: 10.48550/arXiv.2607.04422. URL https://arxiv.org/abs/2607.04422.
  20. [20]Jintao Zhang, Jia wei, Pengle Zhang, Jun Zhu, and Jianfei Chen. SageAttention: Accurate 8-Bit Attention for Plug-and-play Inference Acceleration. In Y. Yue, A. Garg, N. Peng, F. Sha, and R. Yu, editors, International Conference on Learning Representations, volume 2025, pages 71566–71585, 2025. URL https://proceedings.iclr.cc/paper_files/paper/2025/file/b286c344d38e10d2466c0514b78e2f36-Paper-Conference.pdf.arxiv.org/abs/2410.02367
  21. [21]Jintao Zhang, Haofeng Huang, Pengle Zhang, Jia Wei, Jun Zhu, and Jianfei Chen. SageAttention2: Efficient Attention with Thorough Outlier Smoothing and Per-thread INT4 Quantization. In Aarti Singh, Maryam Fazel, Daniel Hsu, Simon Lacoste-Julien, Felix Berkenkamp, Tegan Maharaj, Kiri Wagstaff, and Jerry Zhu, editors, Proceedings of the 42nd International Conference on Machine Learning, volume 267 of Proceedings of Machine Learning Research, pages 75097–75119. PMLR, July 2025. URL https://proceedings.mlr.press/v267/zhang25ae.html.arxiv.org/abs/2411.10958
  22. [22]Jintao Zhang, Xiaoming Xu, Jia Wei, Haofeng Huang, Pengle Zhang, Chendong Xiang, Jun Zhu, and Jianfei Chen. SageAttention2++: A More Efficient Implementation of SageAttention2. arXiv e-prints, art. arXiv:2505.21136, May 2025. doi: 10.48550/arXiv.2505.21136. URL https://arxiv.org/abs/2505.21136.
  23. [23]Jintao Zhang, Jia wei, Haoxu Wang, Pengle Zhang, Xiaoming Xu, Haofeng Huang, Kai Jiang, Jianfei Chen, and Jun Zhu. SageAttention3: Microscaling FP4 Attention for Inference and An Exploration of 8-Bit Training. In D. Belgrave, C. Zhang, H. Lin, R. Pascanu, P. Koniusz, M. Ghassemi, and N. Chen, editors, Advances in Neural Information Processing Systems, volume 38, Main Conference, pages 53901–53931. Curran Associates, Inc., 2025. doi: 10.52202/085713-1799. URL https://proceedings.neurips.cc/paper_files/paper/2025/file/4db397e0f760cc573c681e81a01a3dba-Paper-Conference.pdf.DOI
  24. [24]Jintao Zhang, Marco Chen, Haoxu Wang, Kai Jiang, Ion Stoica, Joseph E. Gonzalez, Jianfei Chen, and Jun Zhu. SageBwd: A Trainable Low-bit Attention. arXiv e-prints, art. arXiv:2603.02170, March 2026. doi: 10.48550/arXiv.2603.02170. URL https://arxiv.org/abs/2603.02170.
  25. [25]Peiyuan Zhang, Matthew Noto, Wenxuan Tan, Chengquan Jiang, Will Lin, Wei Zhou, and Hao Zhang. Attn-QAT: 4-Bit Attention With Quantization-Aware Training. In Tong Zhang, Miroslav Dudík, Martin Jaggi, Alekh Agarwal, Sharon Li, Dale Schuurmans, Jerry Zhu, Felix Berkenkamp, Hanze Dong, and Alberto Bietti, editors, Proceedings of the 43rd International Conference on Machine Learning, volume 306 of Proceedings of Machine Learning Research, pages 157947–157965. PMLR, July 2026. URL https://proceedings.mlr.press/v306/zhang26eq.html.arxiv.org/abs/2603.00040
  26. [26]Haiquan Qiu and Quanming Yao. Why Low-Precision Transformer Training Fails: An Analysis on Flash Attention. In C. Vondrick, B. Harinharan, C. Raffel, L. Pinto, D. Yang, and A. Faust, editors, International Conference on Learning Representations, volume 2026, pages 70649–70672, 2026. URL https://proceedings.iclr.cc/paper_files/paper/2026/file/733209a1f12071a7ec979e8ffaeb1d99-Paper-Conference.pdf.arxiv.org/abs/2510.04212
  27. [27]Jonathan T. Barron, Dan Gnanapragasam, and Michael Tschannen. A Fix for Softmax and Cross-Entropy. arXiv:2610.31642, 2026. doi: 10.48550/arXiv.2610.31642. URL https://arxiv.org/abs/2610.31642.
  28. [28]Jerry Chee, Yaohui Cai, Volodymyr Kuleshov, and Christopher De Sa. QuIP: 2-Bit Quantization of Large Language Models With Guarantees. In A. Oh, T. Naumann, A. Globerson, K. Saenko, M. Hardt, and S. Levine, editors, Advances in Neural Information Processing Systems, volume 36, pages 4396–4429. Curran Associates, Inc., 2023. doi: 10.52202/075280-0196. URL https://proceedings.neurips.cc/paper_files/paper/2023/file/0df38cd13520747e1e64e5b123a78ef8-Paper-Conference.pdf.DOI
  29. [29]Albert Tseng, Jerry Chee, Qingyao Sun, Volodymyr Kuleshov, and Christopher De Sa. QuIP#: Even Better LLM Quantization with Hadamard Incoherence and Lattice Codebooks. In Ruslan Salakhutdinov, Zico Kolter, Katherine Heller, Adrian Weller, Nuria Oliver, Jonathan Scarlett, and Felix Berkenkamp, editors, Proceedings of the 41st International Conference on Machine Learning, volume 235 of Proceedings of Machine Learning Research, pages 48630–48656. PMLR, July 2024. URL https://proceedings.mlr.press/v235/tseng24a.html.arxiv.org/abs/2402.04396
  30. [30]John N. Mitchell. Computer Multiplication and Division Using Binary Logarithms. IRE Transactions on Electronic Computers, EC-11(4):512–517, August 1962. ISSN 0367-9950. doi: 10.1109/TEC.1962.5219391. URL https://doi.org/10.1109/TEC.1962.5219391.
  31. [31]Haohui Han, Yuming Wan, Hongni Wang, Pengcheng Xie, Xiaodong Yan, Runqi You, and Wencong Zhang. EFQ-Softmax: Exp-Free Quantization for Large Language Models, arXiv e-prints, art. arXiv:2609.09721, September 2026. doi: 10.48550/arXiv.2609.09721. URL https://arxiv.org/abs/2609.09721.
  32. [32]Nicol N. Schraudolph. A Fast, Compact Approximation of the Exponential Function. Neural Computation, 11(4):853–862, May 1999. ISSN 0899-7667. doi: 10.1162/089976699300016467. URL https://doi.org/10.1162/089976699300016467.
  33. [33]Matt Mahoney. Large Text Compression Benchmark, 2011. URL https://mattmahoney.net/dc/text.html. The enwik8 file is the first 10⁸ bytes of an English Wikipedia dump.
  34. [34]Aaron Grattafiori, Abhimanyu Dubey, Abhinav Jauhari, Abhinav Pandey, Abhishek Kadian, Ahmad Al-Dahle, Aiesha Letman, Akhil Mathur, Alan Schelten, Alex Vaughan, Amy Yang, Angela Fan, Anirudh Goyal, Anthony Hartshorn, Aobo Yang, Archi Mitra, Archie Sravankumar, Artem Korenev, Arthur Hinsvark, Arun Rao, Aston Zhang, Aurelien Rodriguez, Austen Gregerson, Ava Spataru, Baptiste Rozier, Bethany Biron, Binh Tang, Bobbie Chern, Charlotte Cauchois, Chaya Nayak, Chloe Bi, Chris Marra, Chris McConnell, Christian Keller, Christophe Touret, Chunyang Wu, Corinne Wong, Cristian Canton Ferrer, Cyrus Nikolaidis, Damien Allonsius, Daniel Song, Danielle Pintz, Danny Livshits, Danny Wyatt, David Esiobu, Dhruv Choudhary, Dhruv Mahajan, Diego Garcia-Olano, Diego Perino, Dieuwke Hupkes, Egor Lakomkin, Ehab AlBadawy, Elina Lobanova, Emily Dinan, Eric Michael Smith, Filip Radenovic, Francisco Guzmán, Frank Zhang, Gabriel Synnaeve, Gabrielle Lee, Georgia Lewis Anderson, Govind Thattai, Graeme Nail, Gregoire Mialon, Guan Pang, Guillem Cucurell, Hailey Nguyen, Hannah Korevaar, Hu Xu, Hugo Touvron, Iliyan Zarov, Imanol Arrieta Ibarra, Isabel Kloumann, Ishan Misra, Ivan Evтимov, Jack Zhang, Jade Copet, Jaewon Lee, Jan Geffert, Jana Vranes, Jason Park, Jay Mahadeokar, Jeet Shah, Jelmer van der Linde, Jennifer Billock, Jenny Hong, Jenya Lee, Jeremy Fu, Jianfeng Chi, Jianyu Huang, Jiawen Liu, Jie Wang, Jiecao Yu, Joanna Bitton, Joe Spisak, Jongsoo Park, Joseph Rocca, Joshua Johnston, Joshua Saxe, Junteng Jia, Kalyan Vasuden Alwala, Karthik Prasad, Kartikeya Upasani, Kate Plawiak, Ke Li, Kenneth Heafield, Kevin Stone, Khalid El-Arini, Krithika Iyer, Kshitiz Malik, Kuenley Chiu, Kunal Bhalla, Kushal Lakhotia, Lauren Rantala-Yeary, Laurens van der Maaten, Lawrence Chen, Liang Tan, Liz Jenkins, Louis Martin, Lovish Madaan, Lubo Malo, Lukas Blecher, Lukas Landzaat, Luke de Oliveira, Madeline Muzzi, Mahesh Pasupuleti, Mannat Singh, Manohar Paluri, Marcin Kardas, Maria Tsimpoukelli, Mathew Oldham, Mathieu Rita, Maya Pavlova, Melanie Kambadur, Mike Lewis, Min Si, Mitesh Kumar Singh, Mona Hassan, Naman Goyal, Narjes Torabi, Nikolay Bashlykov, Nikolay Bogoychev, Niladri Chatterji, Ning Zhang, Olivier Duchenne, Onur Çelebi, Patrick Alrassy, Pengchuan Zhang, Pengwei Li, Petar Vasic, Peter Weng, Prajjwal Bhargava, Pratik Dubal, Praveen Krishnan, Punit Singh Koura, Puxin Xu, Qing He, Qingxiao Dong, Ragavan Srinivasan, Raj Ganapathy, Ramon Calderer, Ricardo Silveira Cabral, Robert Stojnic, Roberta Raileanu, Rohan Maheswari, Rohit Girdhar, Rohit Patel, Romain Sauvestre, Ronnie Polidoro, Roshan Sumbaly, Ross Taylor, Ruan Silva, Rui Hou, Rui Wang, Saghar Hosseini, Sahana Chennabasappa, Sanjay Singh, Sean Bell, Seohyun Sonia Kim, Sergey Edunov, Shaoliang Nie, Sharan Narang, Sharath Raparthy, Sheng Shen, Shengye Wan, Shruti Bhosale, Shun Zhang, Simon Vandenhende, Soumya Batra, Spencer Whitman, Sten Sootla, Stephane Collot, Suchin Gururangan, Sydney Borodinsky, Tamar Herman, Tara Fowler, Tarek Sheasha, Thomas Georgiou, Thomas Scialom, and Tobias Speckbacher. The Llama 3 Herd of Models. arXiv e-prints, art. arXiv:2407.21783, July 2024. doi: 10.48550/arXiv.2407.21783. URL https://arxiv.org/abs/2407.21783.
  35. [35]Guilherme Penedo, Hynek Kydlíček, Loubna Ben allal, Anton Lozhkov, Margaret Mitchell, Colin Raffel, Leandro Von Werra, and Thomas Wolf. The FineWeb Datasets: Decanting the Web for the Finest Text Data at Scale. In A. Globerson, L. Mackey, D. Belgrave, A. Fan, U. Paquet, J. Tomczak, and C. Zhang, editors, Advances in Neural Information Processing Systems, volume 37, pages 30811–30849. Curran Associates, Inc., 2024. doi: 10.52202/079017-079017-079017-079017-079017-079017-079017-079017-079017. URL https://proceedings.neurips.cc/paper_files/paper/2024/file/370df50ccfdf8bde18f8f9c2d9151bda-Paper-Datasets_and_Benchmarks_Track.pdf.arxiv.org/abs/2406.17557
  36. [36]Wanchao Liang, Tianyu Liu, Less Wright, Will Constable, Andrew Gu, Chien-Chin Huang, Iris Zhang, Wei Feng, Howard Huang, Junjie Wang, Sanket Jayant Purandare, Gokul Nadathur, and Stratos Idreos. TorchTitan: One-stop PyTorch native solution for production ready LLM pretraining. In Y. Yue, A. Garg, N. Peng, F. Sha, and R. Yu, editors, International Conference on Learning Representations, volume 2025, pages 92161–92181, 2025. doi: 10.48550/arXiv.2410.06511. URL https://proceedings. mlsys.org/paper_files/paper/2026/file/ae8b0b5838ba510daff1198474e7b984-Paper–Conference.pdf.DOI
  37. [37]Lintang Sutawika, Hailey Schoelkopf, Leo Gao, Baber Abbasi, Stella Biderman, Jonathan Tow, ben fattori, Charles Lovering, farzanehnakhаee70, Jason Phang, Anish Thite, Fazz, Aflah, Niklas Muennighoff, Thomas Wang, sdtblck, nopperl, gakada, ttyun-tian, researcher2, Julen Etxaniz, Chris, Hanwool Albert Lee, Zdeněk Kasner, Khalid, LSinev, Jeffrey Hsu, Anjor Kanekar, KonradZafer, and AndyZwei. EleutherAI/lm-evaluation-harness: v0.4.3, July 2024. URL https://doi.org/10.5281/zenodo.12608602.

Paper details

vlnc:W_7e92vhu3
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 10

downloads · 1

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

Claude Code, Codex, the AI assistant built into Overleaf

View statement
Looking for related papers…
Contents