arXiv:2610.31911cs.CLOct 2026

Manuscript Offprint

arXiv:2610.31911

LazyFlash: Forward-Dense, Backward-Sparse Attention for Accelerated Long-Context Fine-Tuning

Keqi Deng, Ruchao Fan, Jinyu Li

ABSTRACT

As large language models (LLMs) process increasingly long sequences, attention becomes a major computational bottleneck. Sparse attention mostly targets inference, yet many methods still train densely or cannot support sparse training, and their added complexity makes sparsity hard to turn into wall-clock speedups, leaving dense attention widely used in practice. This paper introduces LazyFlash, a forward-dense, backward-sparse attention method built on the observation that attention training is dominated by the backward pass. LazyFlash keeps the forward pass exactly dense, so the trained model remains a standard dense model that existing systems such as vLLM can serve without any change. For the backward pass, LazyFlash proposes a gradient-aware block sparsification design that ranks query blocks by their attention-output gradient norms and skips those contributing negligibly to parameter updates, turning the dense backward into a block-sparse one. A gradient-mass budget adapts the amount of skipped computation to each head and training step, while importance sampling preserves the dense gradient in expectation. These designs are implemented inside the tiled FlashAttention backward kernel, where skipped blocks are never loaded or computed, translating gradient sparsity into real wall-clock acceleration. Experiments on long-context text and speech LLMs show that LazyFlash maintains downstream performance while achieving up to 5.7×5.7\times attention-backward speedup over FlashAttention and 1.7×1.7\times end-to-end training speedup.

1 INTRODUCTION

Large language models (LLMs) have rapidly expanded their context windows from a few thousand to hundreds of thousands of tokens (Achiam et al., 2023; Dubey et al., 2024; Comanici et al., 2025), and self-attention remains the central component behind this capability. Despite a long line of efficient alternatives, standard full attention is still the dominant choice in mainstream LLMs, since it preserves exact token interactions and is backed by highly optimized kernels. Its cost, however, grows quadratically with sequence length, which makes attention the dominant cost of long-context training: doubling the context quadruples the leading attention computation. FlashAttention and its successors (Dao et al., 2022; Dao, 2024; Shah et al., 2024) have largely removed the memory bottleneck by tiling the computation so that the full attention matrix is never materialized in high-bandwidth memory (HBM), and they have become the standard attention implementation for LLM training. These kernels, however, reduce memory traffic rather than arithmetic, so the quadratic FLOPs remain and further gains from kernel-level engineering are increasingly incremental. The same pressure is not confined to text. Speech and audio LLMs increasingly train on hours-long recordings (Park et al., 2025; Peng et al., 2025; Deng et al., 2026), where a single utterance already spans tens of thousands of positions. Accelerating long-context attention training is therefore a shared challenge across modalities rather than a text-only concern.

Sparse attention is a natural candidate for reducing this cost, but most existing methods target inference rather than training. Training-free approaches (Zhang et al., 2023; Tang et al., 2024; Xiao et al., 2024) select a small subset of the KV cache at decoding time and leave training entirely dense, offering no training-side savings. Trainable sparse attention instead incorporates sparsity into the forward pass so that the model adapts to sparse decoding. Native Sparse Attention (NSA)

(Yuan et al., 2025b) is designed for pre-training from scratch and departs substantially from standard attention, so its gains do not carry over to models that keep standard attention. SeerAttention (Gao et al., 2025) and DeepSeek Sparse Attention (DSA) (Liu et al., 2025) learn their sparse selection by distilling from the dense attention distribution, which requires dense attention to be computed as the target during training and therefore precludes any training-time saving. Mixture of Block Attention (MoBA) (Lu et al., 2025) comes closer to a trainable accelerator, but its block selection introduces extra computation on top of the sparse attention itself, and decoding the resulting model densely creates a train-inference mismatch that can degrade quality. More broadly, the additional importance estimation, top-k selection, and irregular sparse kernels mean that theoretical FLOP reductions do not always translate into wall-clock gains unless the context is extremely long, which is why dense attention remains widely used in deployment. Although sparsity is well aligned with the intrinsic structure of attention, how to exploit it to accelerate the training of standard attention, rather than its inference, remains an open challenge.

This paper proposes LazyFlash, a backward-sparse attention method that accelerates the training of standard attention. Attention is sparse in both its forward and its backward computation, but prior work has concentrated almost entirely on the forward side, even though the backward pass accounts for most of the training cost. LazyFlash therefore leaves the forward computation dense and exact and introduces sparsity only in the backward pass, implemented on top of FlashAttention. Since the forward pass is untouched, the trained model remains an ordinary dense-attention model and can be served directly by mature inference frameworks such as vLLM (Kwon et al., 2023), which is of practical value because no change to the deployment pipeline is required. LazyFlash operates at the granularity of query blocks aligned with the FlashAttention (Dao, 2024) tiling, and measures the contribution of each block to the attention gradient from the norm of its output gradient. Blocks whose contribution is negligible are dropped, so their tiles are never loaded or computed in the backward kernel. Rather than fixing the skip ratio in advance, LazyFlash sets a budget on the fraction of gradient mass that may be discarded, so that the resulting sparsity adapts to how concentrated the gradients are at each step. Within this budget, blocks are kept by sampling with probability proportional to their gradient contribution and are rescaled accordingly, which keeps the estimated gradient unbiased. Experiments on long-context text and long-form speech LLMs show that LazyFlash matches the quality of dense training while reducing the attention backward time by up to 5.7×5.7\times and the overall training time by up to 1.7×1.7\times.

The main contributions of this paper can be summarized in four parts:

• LazyFlash, a forward-dense and backward-sparse attention method that speeds up long-context fine-tuning while keeping the forward pass exact, so the trained model remains a standard dense model that needs no change at inference.

• A block selection method that scores each query block by the norm of its output gradient and skips the blocks that barely contribute, with a gradient-mass budget that sets the skip ratio from the gradient distribution rather than from a fixed threshold.

• An importance sampling scheme that keeps blocks with probability proportional to their gradient contribution and rescales them accordingly, so the gradient estimate stays unbiased instead of repeatedly dropping the same blocks.

• A FlashAttention backward kernel supporting both dense and variable-length inputs, reaching up to 5.7×5.7\times faster attention backward and 1.7×1.7\times faster end-to-end training on text and speech LLMs.

References (28)