TL;DR
AdaCluster is a training-free, adaptive clustering framework designed to accelerate Video Diffusion Transformers (DiTs) by introducing role-aware sparse attention. By applying angle-based clustering to queries and layer-wise adaptive Euclidean clustering to keys, it dynamically identifies and computes only the most critical attention tokens. This approach achieves up to a 4.31× end-to-end inference speedup on a single GPU while maintaining high visual fidelity.
What Problem Does This Paper Address?
Diffusion Transformer (DiT) models have become the state-of-the-art paradigm for high-fidelity video generation. However, their practical deployment is severely bottlenecked by inference latency. Because video sequence lengths scale with both spatial resolution and frame count, the input can easily reach tens or hundreds of thousands of tokens. The core bottleneck is the attention mechanism, which scales quadratically ($O(N^2)$) with this sequence length.
Prior attempts to introduce "sparse attention" (computing attention only for a subset of critical tokens) fall into two traps:
- Static Sparsity: Using fixed, predefined attention patterns that lack generality and miss dynamic, content-dependent interactions.
- Uniform Dynamic Sparsity: Treating queries and keys identically by applying uniform Euclidean clustering across all layers. This ignores the distinct mathematical roles queries and keys play and overlooks the fact that token distributions vary drastically from layer to layer.
Methods
AdaCluster introduces a role-aware "cluster-then-select" pipeline tailored specifically to how queries and keys behave in DiT architectures:
-
Angle-Based Query Clustering: The authors observe that the relative magnitude of query-key attention scores is independent of query vector length. By normalizing query vectors onto a unit sphere, the distribution becomes significantly more compact, allowing for a much higher compression ratio using angle-similarity preserving clustering.
Query vector distributions before and after normalization. -
Layer-Wise Adaptive Key Clustering: Key tokens require Euclidean-level similarity because both vector direction and length impact the final attention matrix. Since token dispersion varies heavily across layers, AdaCluster uses a Multi-stage K-means algorithm. Scattered layers receive more clusters, concentrated layers receive fewer, and extremely hard-to-compress layers are automatically skipped in favor of vanilla full attention.
Visualization of Multi-stage K-means clustering. -
Temporal Consistency Initialization: Because DiT denoising steps change gradually, cluster centers from step $t$ are used to initialize step $t+1$, drastically reducing clustering overhead during the iterative generation process.
- TensorQuest Core Optimization: To efficiently select critical key clusters for a given query, the authors adapt the Quest algorithm. By mathematically reformulating the bounding equations into standard matrix multiplications, they shift the workload from standard GPU CUDA cores to high-throughput Tensor Cores, speeding up the selection phase by up to 5×.
Datasets
The framework was evaluated on video generation tasks using text prompts from the PenguinVideoBenchmark. The authors tested AdaCluster across three prominent open-source DiT models:
- CogVideoX-2B
- HunyuanVideo
- Wan-2.1-T2V-1.3B
Evaluation metrics included similarity metrics relative to full-attention models (PSNR, SSIM, LPIPS) and overall video quality metrics via the VBench suite (imaging quality, background/subject consistency, and temporal flicker).
Key Insights and Ideas
- Asymmetric Roles of Q & K: Queries and keys shouldn't be treated equally. Queries can be aggressively compressed via angular normalization without losing the relative ranking of attention weights, whereas keys preserve critical information in their magnitude.
-
Heterogeneity Across Layers: A fixed cluster budget across an entire network is highly inefficient. As visualized via PCA in the paper, some layers exhibit highly concentrated token clusters while others are completely dispersed. Dynamic cluster assignment prevents accuracy degradation in complex layers while maximizing speedups in simple ones.
Token distribution visualization across different layers showing high heterogeneity. -
Hardware-Aware Algorithm Design: Even mathematically elegant sparse selection methods can bottleneck inference if they rely on element-wise operations. Reformulating selection bounds into matrix multiplications allows modern hardware (Tensor Cores) to do what it does best.
Key Results
Tested on a single NVIDIA A40 GPU, AdaCluster consistently outperformed state-of-the-art dynamic sparse attention baselines like SpargeAttn and SVG2:
- Inference Speedups: AdaCluster achieved an end-to-end acceleration of 1.67× to 4.31× for video resolutions at or above 720p.
-
Fidelity Preservation: On HunyuanVideo (1280×720 resolution, 81 frames), AdaCluster dropped total generation time from 1639 seconds to 973 seconds while maintaining an excellent PSNR of 30.58dB and minimal visual degradation.
Performance and visual comparison between Full Attention and AdaCluster on HunyuanVideo. -
Scalability: As sequence lengths grew (up to 176.4K tokens), the speedup advantage of AdaCluster became more pronounced due to the inherent sparsity of longer sequences.
Limitations and Future Work
- Hard-to-Compress Layers: To balance accuracy, the authors manually set a threshold (
kmax) ensuring the top 15% most complex layers default back to full attention. Finding a way to sparsify these dense layers without quality loss remains an open challenge. - Model-Specific Visual Drops: While performance was stable on Wan-2.1 and HunyuanVideo, CogVideoX experienced a noticeable drop in image quality metrics, which the authors partially attribute to the base model's inherent limitations.
- Orthogonal Enhancements: The paper notes that AdaCluster is entirely training-free and operates orthogonally to network quantization or low-bit precision methods; combining adaptive clustering with quantization is a promising avenue for future hardware optimization.
Summary updated