SAM-Lightening: A Lightweight Segment Anything Model with Dilated Flash Attention to Achieve 30 times Acceleration
Yanfei Song, Bangzheng Pu, Peng Wang, Hongxu Jiang, Dong Dong,, Yongxiang Cao, Yiqing Shen

TL;DR
SAM-Lightening introduces a re-engineered attention mechanism that significantly accelerates segmentation inference speed while reducing memory usage, making SAM more practical for real-world applications.
Contribution
It proposes Dilated Flash Attention and a progressive distillation method to enhance SAM's efficiency without retraining from scratch.
Findings
Achieves 7 ms inference per image of size 1024x1024
30.1 times faster than vanilla SAM
Uses only 244MB memory, 3.5% of vanilla SAM
Abstract
Segment Anything Model (SAM) has garnered significant attention in segmentation tasks due to their zero-shot generalization ability. However, a broader application of SAMs to real-world practice has been restricted by their low inference speed and high computational memory demands, which mainly stem from the attention mechanism. Existing work concentrated on optimizing the encoder, yet has not adequately addressed the inefficiency of the attention mechanism itself, even when distilled to a smaller model, which thus leaves space for further improvement. In response, we introduce SAM-Lightening, a variant of SAM, that features a re-engineered attention mechanism, termed Dilated Flash Attention. It not only facilitates higher parallelism, enhancing processing efficiency but also retains compatibility with the existing FlashAttention. Correspondingly, we propose a progressive distillation…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsData Visualization and Analytics · Image Enhancement Techniques · CCD and CMOS Imaging Sensors
MethodsSPEED: Separable Pyramidal Pooling EncodEr-Decoder for Real-Time Monocular Depth Estimation on Low-Resource Settings · Segment Anything Model
