Efficient AI Computing,
Transforming the Future.

Radial Attention: O(nlogn) Sparse Attention for Long Video Generation with 2–4× Speedups in Training and Inference

TL;DR

A sparse attention mechanism with O(nlogn) computational complexity for long video generation. It can speed up both training and inference by 2–4×. The code is available at https://github.com/mit-han-lab/radial-attention

Related Projects

Background

Radial Attention Teaser

Diffusion models have achieved remarkable success in video generation. However, scaling them to long videos remains challenging due to the high computational cost introduced by the additional temporal dimension. Self-attention mechanisms, with their quadratic complexity in sequence length, make both training and inference prohibitively expensive on long sequences.

To address this limitation, we propose Radial Attention—a sparse attention mechanism inspired by the physical principle of energy decay. Radial Attention reduces the complexity from quadratic to \( \mathcal{O}(n \log n) \), offering a significantly more efficient alternative to standard dense attention. Compared to linear attention, it more effectively preserves essential spatiotemporal correlations.

Inspiration behind Radial Attention

In the physical world, the energy of signals and waves decays over space and time. We observed a similar phenomenon in video diffusion models’ attention: post-softmax scores diminish with increasing spatial and temporal distance between tokens, as shown in the above figure. We term this Spatiotemporal Energy Decay and model it as an exponential function of both spatial and temporal distances. Inspired by this, we design Radial Attention to translate energy decay into exponentially decaying compute density.

How Radial Attention Works

Radial Attention uses a static pre-defined attention mask where each token attends to spatially nearby tokens, with the attention window size shrinking with temporal distance. This design focuses computational resources on the most relevant interactions while maintaining the efficiency.

Temporal Density Decay

Radial Attention

Along the temporal dimension, Radial Attention applies an exponential decay rule. The compute density between tokens in frame \( i \) and frame \( j \) is set to \( \left( \frac{1}{2} \right)^{\left\lfloor \log_2 \left( \max\left( |i - j|, 1 \right) \right) \right\rfloor} \). This creates a structured pattern where the attention map is divided into diagonal bands centered on the main diagonal, as in the above figure (a). Each band's width doubles relative to the previous one, ensuring that the total computation per band remains bounded by a constant.

Spatial Density Decay

Radial Attention

Most attention energy is concentrated on tokens at similar spatial locations across frames. Radial Attention preserves these high-energy interactions using diagonal-like structures within each frame-to-frame attention block. The diagonal width for attention between frame \( i \) and frame \( j \) is given by \( \left\lfloor \frac{s}{2^{\left\lfloor \log_2 \left( \max\left(|i - j|, 1\right) \right) \right\rfloor}} \right\rfloor \). As the temporal distance increases, the computed diagonal width shrinks.

Hardware-friendly Block Sparsity

To ensure efficient execution on modern hardware, attention is computed over blocks rather than individual 1×1 tokens. Our implementation uses a block size of 128×128.

Low-Rank Adaptation for Length Extension

Radial Attention also helps reduce training complexity when adapting models for longer videos. Because it preserves the original softmax attention, the pre-trained weights remain largely reusable, requiring only minimal fine-tuning. To further reduce training overhead, we incorporate Low-Rank Adaptation (LoRA) into the attention mechanism. Specifically, LoRA is applied to the query, key, value, and output projections of the attention layers, enabling efficient fine-tuning with significantly reduced memory and computational costs. Empirically, we find that LoRA fine-tuning with Radial Attention not only minimizes overhead but also improves video quality by refining only the most critical weights and concentrating attention more effectively.

Performance

Radial Attention

Radial Attention reduces the computational complexity of attention from \( \mathcal{O}(n^2) \) to \( \mathcal{O}(n \log n) \). When generating a 500-frame 720p video with HunyuanVideo, it reduces the attention computation by 9×, achieves 3.7× speedup, and saves 4.6× tuning costs.

Video Quality

Radial Attention

teaser

Radial Attention accelerates pre-trained HunyuanVideo by 1.9× at its default video length while maintaining comparable video quality. When generating 4× longer videos, it reduces tuning costs by up to 4.4× and speeds up inference by up to 3.7× versus dense attention.

Compatibility with Existing LoRAs

Radial Attention

teaser

A key advantage of Radial Attention is its seamless compatibility with pre-trained LoRAs. As demonstrated above, applying Radial Attention to the 8-step FusionX LoRA results in an additional 1.6× speedup, reducing the latency of generating a 4s 720P video to 84s on a single H100.

Furthermore, LoRAs trained for extended-length generation with Radial Attention can also be combined with existing style LoRAs. As shown in the above figure, this combination maintains visual quality while enabling longer video generation.