Manuscript Offprint

arXiv:2610.08772

Backend-Agnostic Sparse Attention for Fast High-Resolution Visual Generation

Liao Ma, Jiayi Song, Yunfeng Wu, Songhua Liu, Peilin Zhao

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

ABSTRACT

Diffusion Transformers (DiTs) have achieved strong performance in image and video generation, but the quadratic complexity of full attention makes high-resolution generation computationally expensive. Window attention offers an efficient alternative, yet existing methods face a practical trade-off: partitioned window attention typically achieves computational efficiency consistent with its theoretical complexity. However, isolated windows block cross-window interaction, often introducing visible grid-like artifacts in the generated results. Fine-grained sliding-window attention effectively restores interactions across neighboring windows and improves visual quality. However, its irregular computation patterns create a substantial gap between theoretical and practical speedups and require specialized kernels tailored to each hardware backend. To tackle these challenges, we propose BASA, a backend-agnostic sparse attention, which brings the best of both worlds: visual quality and practical acceleration. Specifically, BASA replaces visual self-attention with shifted local-window attention. By introducing a structured window-shifting scheme across DiT blocks, we allow tokens divided by window boundaries in one layer to communicate in the following layers, thereby achieving global information exchange and eliminating window-induced visual artifacts. Notably, our design introduces no additional irregular operators or customized kernels, making it readily deployable on existing attention backends and closing the gap between theoretical sparsity and practical acceleration. Experiments demonstrate that BASA achieves measured speedups exceeding 90% of the

∗^{*}Corresponding author.

theoretical estimates on FLUX and delivers a 4.52×4.52\times attention speedup on Wan while maintaining competitive generation quality.

1 INTRODUCTION

Diffusion models have achieved strong performance in image and video generation (Ho et al., 2020; Rombach et al., 2022). By combining diffusion modeling with the contextual capacity of Transformers (Vaswani et al., 2017), Diffusion Transformers (DiTs) have emerged as a dominant backbone for modern image (Peebles & Xie, 2023; Bao et al., 2023; Chen et al., 2024b; Esser et al., 2024) and video generation (Kong et al., 2024; Wan Team et al., 2025). However, the quadratic complexity of Transformer self-attention makes dense attention increasingly costly when pre-trained visual generation models are extended to higher resolutions.

Window attention offers a natural alternative by restricting self-attention to local regions. Conventional partitioned window attention, as in Swin (Liu et al., 2021), divides tokens into regular non-overlapping windows. This structured pattern can be efficiently executed by existing dense attention operators, allowing measured acceleration to closely track theoretical savings. However, isolated windows block direct cross-boundary interaction, disrupting continuous textures and structures and producing visible grid-like artifacts, especially under substantial resolution extrapolation.

Fine-grained sliding-window attention instead uses overlapping local neighborhoods to improve cross-boundary interaction and local continuity. CLEAR (Liu et al., 2025) uses conv-like linearization to preserve locality, attention formulation, and raw visual features for pre-trained image DiTs, while STA (Zhang et al., 2025b) uses sliding spatiotemporal tiles to exploit redundancy and locality in video attention. However, fine-grained sliding-window attention presents two practical challenges. First, irregular computational patterns incur indexing and memory-access overhead, creating a substantial gap between theoretical and measured speedups. Second, efficient execution often relies on specialized kernels tailored to individual hardware backends, increasing implementation costs and limiting portability.

These limitations call for a sparse attention design that combines cross-window communication, regular computation, and backend portability. Fig. 2 illustrates the quality–efficiency trade-off: regular partitioned windows provide strong practical acceleration but exhibit boundary artifacts, whereas fine-grained sliding windows improve visual continuity with smaller measured speed gains. The key question is therefore how to enable cross-window communication while retaining regular window computation and avoiding backend-specific custom kernels.

To this end, we propose BASA, a backend-agnostic sparse attention mechanism for efficient high-resolution image and video generation. BASA retains regular local windows but varies their spatial partition offsets across DiT blocks and denoising steps. Tokens separated by one partition can thus interact under subsequent partitions, enabling cross-window information propagation while preserving regular attention computation within each block. BASA further augments each query window with spatially pooled global K/V memory to provide low-cost scene-level context. For video, content-adaptive routing retrieves a small number of relevant uncompressed spatial windows, preserving fine-grained long-range information and the full temporal extent of each selected region.

We evaluate BASA on FLUX.1-dev (Esser et al., 2024) and Wan2.1-T2V-1.3B (Wan Team et al., 2025) for high-resolution image and video generation. BASA substantially reduces attention computation and inference latency while maintaining competitive visual quality and temporal consistency, achieving 4.52×4.52\times attention speedup on Wan and reducing FLUX attention latency to about 9 ms.

Our contributions are summarized as follows:

• We propose BASA, a backend-agnostic sparse attention framework that addresses the trade-off between hardware-efficient regular sparsity and effective cross-window communication in high-resolution visual generation. BASA enables practical acceleration without relying on customized sparse kernels.

• We further develop a structured sparse attention design combining shifted local windows with K/V-pooled global memory, and extend it to video with content-adaptive true-window routing. Varying window partitions promote cross-window information propagation, while

Figure

(a) Swin

Fast acceleration but severe

window boundary artifacts

(b) CLEAR

High fidelity

but limited speed gain

(c) BASA

Faithful reconstruction

and efficient

(d) Latency and FLOPS

Figure 2: Motivation for BASA. Swin-style window attention (Liu et al., 2021) provides fast inference but introduces severe window boundary artifacts. CLEAR (Liu et al., 2025) preserves high visual fidelity, while its practical speed gain is relatively limited. BASA preserves faithful reconstruction while achieving efficient inference, providing a favorable quality–efficiency trade-off.

global memory and routed windows provide efficient long-range context. Dense-teacher adaptation is further used to reduce sparse–dense discrepancy.

• Experiments demonstrate that BASA achieves substantial practical acceleration while maintaining competitive generation quality. BASA realizes over 90% of its theoretical speedup on FLUX and achieves up to 4.52×4.52\times attention speedup on Wan.

References (39)