HilbertA: Hilbert-Curve–Aligned Sparse Attention for 2D Structured Data
Abstract
Designing sparse attention for 2D image data in diffusion and vision-language models requires reconciling spatial locality with hardware-efficient execution: handcrafted 2D sparsity patterns preserve spatial structure but often induce uncoalesced memory access, limiting practical speedups on modern GPUs. We present HilbertA, a 2D-aware sparse attention mechanism that reorders image tokens along a Hilbert curve, converting local spatial neighborhoods into contiguous memory segments for efficient GPU execution. To enable communication beyond local tiles, HilbertA shifts attention windows along the Hilbert-ordered sequence across layers and uses a small central shared region, preserving contiguous access while supporting cross-tile information flow. Across diffusion and vision-language models, HilbertA delivers consistent efficiency gains while maintaining competitive quality, achieving up to 4.16× attention acceleration and 1.44× end-to-end speedup on Flux.1-dev, and up to 2.30× attention acceleration with 1.57× faster time-to-first-token on Qwen3-VL-8B inference.
Lay Summary
HilbertA is a method for making large image and vision-language models faster. These models spend much of their time computing attention between image regions. Existing sparse-attention methods reduce the amount of computation, but often access GPU memory inefficiently, so the real speedup is limited. HilbertA solves this by reordering image regions along a Hilbert curve, which keeps nearby regions close together while making memory access more contiguous and GPU-friendly. It also shifts attention windows across layers so information can still move between different parts of the image. Experiments on diffusion and vision-language models show that HilbertA reduces latency while maintaining comparable image quality and benchmark performance, making high-resolution visual inference more efficient and practical.