FreqFormer: Hierarchical Frequency-Domain Attention with Adaptive Spectral Routing for Long-Sequence Video Diffusion Transformers
Organizations: Beijing University of Posts and Telecommunications
Abstract
Long-sequence video diffusion transformers hit a quadratic self-attention cost that dominates runtime and memory for very long token sequences. Most efficient attention methods use one approximation everywhere, yet video features are spectrally structured: low frequencies carry global layout and coarse motion; high frequencies carry texture and fine detail. We present FreqFormer, a frequency-aware heterogeneous attention framework. Token features are split into spectral bands with different operators: dense global attention on compressed low-frequency content, structured block-sparse attention on mid frequencies, and sliding-window local attention on high frequencies. A lightweight spectral routing network allocates heads across bands using layer statistics and the diffusion timestep, shifting compute toward global structure early in denoising and detail later. Cross-band summary tokens provide cheap residual exchange. FreqFormer is paired with a fused GPU execution plan that co-schedules dense, sparse, and local branches to cut kernel launches and memory traffic. We give a consistent complexity model, an orthonormal-decomposition view of approximation, and simulation-based systems numbers (throughput, arithmetic intensity, memory traffic, duration scaling). In simulations from 64K to 1M tokens, FreqFormer substantially reduces estimated attention FLOPs and KV-related memory traffic versus dense attention while keeping a hardware-friendly pattern, supporting spectrally structured heterogeneous attention as a practical direction for long-video diffusion transformers.
Figures & tables
| Sequence length | Dense attention FLOPs | FreqFormer attention FLOPs | Transform FLOPs | FreqFormer total FLOPs | Reduction vs. dense |
|---|---|---|---|---|---|
| 65,536 | 549,755,813,888 | 1,625,366,528 | 603,979,776 | 2,229,346,304 | 246.59 |
| 131,072 | 2,199,023,255,552 | 4,056,154,112 | 1,308,622,848 | 5,364,776,960 | 409.90 |
| 262,144 | 8,796,093,022,208 | 11,314,446,336 | 2,818,572,288 | 14,133,018,624 | 622.37 |
| 524,288 | 35,184,372,088,832 | 35,026,370,560 | 6,040,797,184 | 41,067,167,744 | 856.82 |
| 1,048,576 | 140,737,488,355,328 | 119,789,838,336 | 12,884,901,888 | 132,674,740,224 | 1,060.70 |
| Sequence length | Dense traffic (bytes) | Dense traffic (GiB) | FreqFormer traffic (bytes) | FreqFormer traffic (GiB) | Reduction |
|---|---|---|---|---|---|
| 65,536 | 8,589,934,592 | 8.0000 | 25,396,352 | 0.0237 | 338.24 |
| 131,072 | 34,359,738,368 | 32.0000 | 63,377,408 | 0.0590 | 542.14 |
| 262,144 | 137,438,953,472 | 128.0000 | 176,788,224 | 0.1647 | 777.19 |
| 524,288 | 549,755,813,888 | 512.0000 | 547,287,040 | 0.5097 | 1,004.51 |
| 1,048,576 | 2,199,023,255,552 | 2048.0000 | 1,871,716,224 | 1.7434 | 1,174.87 |
| Sequence length | Dense intensity (FLOPs/byte) | FreqFormer intensity, attention only | FreqFormer intensity, total incl. transform |
|---|---|---|---|
| 65,536 | 64.0000 | 64.0000 | 87.7795 |
| 131,072 | 64.0000 | 64.0000 | 84.6479 |
| 262,144 | 64.0000 | 64.0000 | 79.9413 |
| 524,288 | 64.0000 | 64.0000 | 75.0369 |
| 1,048,576 | 64.0000 | 64.0000 | 70.8834 |
| Sequence length | Dense time (ms) | Dense tokens/s | FreqFormer fused time (ms) | FreqFormer fused tokens/s | Speedup |
|---|---|---|---|---|---|
| 65,536 | 2.2295 | 29,394,504 | 0.0150 | 4,380,358,757 | 148.88 |
| 131,072 | 8.9010 | 14,725,078 | 0.0277 | 4,731,245,487 | 321.32 |
| 262,144 | 35.5808 | 7,367,735 | 0.0631 | 4,154,190,984 | 564.13 |
| 524,288 | 142.2997 | 3,684,042 | 0.1721 | 3,046,840,209 | 826.74 |
| 1,048,576 | 569.1758 | 1,842,470 | 0.5426 | 1,932,867,888 | 1,049.31 |
| Sequence length | Dense time (ms) | Dense tokens/s | FreqFormer fused time (ms) | FreqFormer fused tokens/s | Speedup |
|---|---|---|---|---|---|
| 65,536 | 16.8952 | 3,878,940 | 0.0755 | 867,932,971 | 223.76 |
| 131,072 | 67.5313 | 1,941,019 | 0.1718 | 762,937,288 | 393.06 |
| 262,144 | 270.0756 | 970,624 | 0.4409 | 594,572,465 | 612.55 |
| 524,288 | 1,080.2525 | 485,350 | 1.2679 | 413,507,370 | 851.97 |
| 1,048,576 | 4,320.9607 | 242,668 | 4.0815 | 256,918,161 | 1,058.67 |
| Sequence length | Fused time (ms) | Separate time (ms) | Fused tokens/s | Separate tokens/s | Fused speedup |
|---|---|---|---|---|---|
| 65,536 | 0.0150 | 0.0418 | 4,380,358,757 | 1,568,832,675 | 2.7922 |
| 131,072 | 0.0277 | 0.0549 | 4,731,245,487 | 2,386,088,877 | 1.9828 |
| 262,144 | 0.0631 | 0.0903 | 4,154,190,984 | 2,904,091,006 | 1.4304 |
| 524,288 | 0.1721 | 0.1993 | 3,046,840,209 | 2,630,809,117 | 1.1581 |
| 1,048,576 | 0.5426 | 0.5698 | 1,932,867,888 | 1,840,580,903 | 1.0501 |
| Duration (s) | Tokens | Dense time (ms) | FreqFormer time (ms) | Speedup |
|---|---|---|---|---|
| 5 | 65,536 | 2.2295 | 0.0150 | 148.88 |
| 10 | 131,072 | 8.9010 | 0.0277 | 321.32 |
| 20 | 262,144 | 35.5808 | 0.0631 | 564.13 |
| 40 | 524,288 | 142.2997 | 0.1721 | 826.74 |
| 80 | 1,048,576 | 569.1758 | 0.5426 | 1,049.31 |
| 120 | 1,572,864 | 1,280.6289 | 1.1234 | 1,139.90 |
Diffusion Model Inference Acceleration
Diffusion model inference acceleration reduces the time and compute needed to generate or reconstruct outputs while preserving quality.
See all 506 papers