FLASHSWIN: Unlocking Large Windows and Dense Tokens in Swin Vision Transformers with Memory Efficient Attention
Tushar Kataria, Gerald Sabin, Ponnuswamy Sadayappan, Shireen Y. Elhabian
Abstract
High-resolution vision backbones have long been forced to trade away local token density to afford larger receptive fields. Hierarchical Swin transformers impose this compromise because standard windowed attention materializes an score matrix per window, incurring memory as windows or token grids grow. Furthermore, Swin adds a learned relative-position bias elementwise to attention scores, requiring full materialization of the score matrix and its gradient. This keeps Swin and SwinV2 trapped in a small-window(), coarse-token regime with patch size (), limiting performance for fine-grained tasks. We introduce FLASHSWIN, which replaces standard windowed attention with a FlashAttention implementation that computes exact softmax attention without materializing the score matrix, reducing per-window memory from to . This enables higher token density and larger receptive fields without inflating memory overhead. Training memory is flat across window sizes: at a window, FLASHSWIN-T requires only \,GB, unchanged from , compared to \,GB for SwinV2/V1-T. However, applying FlashAttention directly to Swin creates a trade-off: bypassing the score matrix precludes Swin's additive relative-position bias, forfeiting spatial information in exchange for memory efficiency. FLASHSWIN restores position information as window-local learnable 2D RoPE, making large windows and dense token grids both affordable and accurate. At matched scale, FLASHSWIN-T outperforms Swin variants. With dense tokens and wide windows (), the same Tiny model reaches ImageNet-1K, COCO box AP, and ADE20K mIoU---gains of , , and over SwinV2-T at , respectively. At fixed , halving the patch size yields roughly larger gains in boundary quality than in mIoU.
Create a lesson
Related papers
LightVLN: Efficient Aerial Vision-and-Language Navigation with Compact Memory and History-Guided Local Aggregation
Shared title terminologycs.CVYiming Zhao, Tianshun Li, Jingle He et al.
Decoding the Functional Roles of Register and High-Norm Patch Tokens in Vision Transformers
Shared title terminologycs.CVNeel Varma, Andrew Rufail, Dipika Khullar et al.
Read Before You Use: Improving Visual Memory Utilization in Vision-Language Models
Shared title terminologycs.CVJunseok Kim, Kyungmin Min, Kyomin Jung
What Is Redundant at High Resolution? Efficient Attention and Feed-Forward Design for All-in-One Image Restoration
Shared title terminologycs.CVDongheon Lee, DongJae Lee, Sewhan Chun et al.
Vision Transformer Ensembles for Panoramic Street Segmentation
Shared title terminologycs.CVYunus Serhat Bıçakçı
LoDEOT: Low-Dimensional and Efficient Offset Tokens for Building Footprint Extraction from Off-Nadir Imagery
Shared title terminologycs.CVKai Li, Zigan Zhou, Zhenyang Li et al.