cs.CVOct 3, 2026

FLASHSWIN: Unlocking Large Windows and Dense Tokens in Swin Vision Transformers with Memory Efficient Attention

Authors: Tushar Kataria, Gerald Sabin, Ponnuswamy Sadayappan, Shireen Y. Elhabian

Organizations: Scientific Computing and Imaging Institute, University of Utah, Salt Lake City, UT, USA · Kahlert School of Computing, University of Utah, Salt Lake City, UT, USA · RNET Technologies, Dayton, OH, USA

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 M2×M2M^2\times M^2 score matrix per window, incurring O(M4)O(M^4) 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(M=8,16M=8,16), coarse-token regime with patch size 4×44\times4 (p=4p=4), 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 O(M4)O(M^4) to O(M2)O(M^2). This enables higher token density and larger receptive fields without inflating memory overhead. Training memory is flat across window sizes: at a 32×3232\times32 window, FLASHSWIN-T requires only 12.412.4,GB, unchanged from 8×88\times8, compared to 70/9070/90,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 (p=2,M=32p=2,M=32), the same Tiny model reaches 84.1%84.1\% ImageNet-1K, 44.144.1 COCO box AP, and 47.2847.28 ADE20K mIoU---gains of +1.3+1.3, +5.1+5.1, and +1.82+1.82 over SwinV2-T at M=16M=16, respectively. At fixed M=32M=32, halving the patch size yields roughly 3×3\times larger gains in boundary quality than in mIoU.

Figures & tables

Explore similar work

CardsList
  1. Gated-SwinRMT: Unifying Swin Windowed Attention with Retentive Manhattan Decay via Input-Dependent Gating

    Apr 7, 2026Dipan Maity, Suman Mondal, Arindam RoyVision TransformerGated Attention

  2. QFlash: Bridging Quantization and Memory Efficiency in Vision Transformer Attention

    Apr 28, 2026Sehyeon Oh, Yongin Kwon, Jemin LeeSoftmax AttentionGPU Acceleration

  3. Sliding-window beats linear attention

    Aug 28, 2026Alexia Jolicoeur-Martineau, Rhea Sanjay Sukthanker, Pashmina Cameron +1KV CachingLLM Inference Acceleration