Abstract
Mamba-based vision models have gained extensive attention as a result of being computationally more efficient than attention-based models. However, spatial redundancy still exists in these models, represented by token and block redundancy. For token redundancy, we analytically find that early token pruning methods will result in inconsistency between training and inference or introduce extra computation for inference. Therefore, we customize token pruning to fit the Mamba structure by rearranging the pruned sequence before feeding it into the next Mamba block. For block redundancy, we allow each image to select SSM blocks dynamically based on an empirical observation that the inference speed of Mamba-based vision models is largely affected by the number of SSM blocks. Our proposed method, Dynamic Vision Mamba (DyVM), effectively reduces FLOPs with minor performance drops. We achieve a reduction of 35.2% FLOPs with only a loss of accuracy of 1.7% on Vim-S. It also generalizes well across different Mamba vision model architectures and different vision tasks.
Introduction: Addressing Spatial Redundancy
While Vision Transformers (ViTs) have dominated computer vision, Vision Mambas (based on State Space Models or SSMs) have recently emerged as a more efficient alternative due to their linear scaling with sequence length. However, like their Transformer cousins, Vision Mambas suffer from significant spatial redundancy. They typically expend equal computational effort on every pixel, regardless of whether it belongs to a high-contrast foreground object or a redundant background.
Existing token pruning methods developed for ViTs do not translate directly to the Mamba architecture. In ViTs, tokens can be masked out (zeroed). However, Mamba is recurrent-like; information flows through hidden states from one token to the next. Simply masking a token during training but removing it during inference changes the "distance" and information flow between the remaining tokens, leading to a performance-killing mismatch.
Methodology: The DyVM Approach
The proposed Dynamic Vision Mamba (DyVM) attacks redundancy at two distinct levels:
1. Token-Level Pruning (Rearrange & Reinsert)
To bridge the training-inference gap, DyVM avoids simple masking. During training, a learnable predictor identifies "unimportant" tokens. The sequence is then rearranged, moving preserved tokens to the front and pruned tokens to the back, while maintaining the class token's relative position. This ensures that during training, the "important" tokens encounter the same sequence structure they will face during inference when pruned tokens are physically deleted.
2. Block-Level Selection
The authors observed that the number of SSM blocks (scanning modules) is a primary driver of throughput. DyVM incorporates a "block selector" using the Gumbel-Softmax trick to make differentiable decisions: determining whether a specific image should pass through the forward block, the backward block, both, or neither.
3. Knowledge Distillation
A teacher-student framework is employed to maintain performance. The original unpruned Mamba model acts as a teacher, guiding the DyVM model to maintain feature consistency despite the reduced token and block count.
Key Insights and Results
A critical finding of this work is the relationship between FLOPs and actual hardware throughput. In Mamba architectures, FLOPs can be a deceptive metric.
As shown in the figure above, removing an SSM block might only reduce FLOPs by a small percentage, but it can significantly increase throughput (images processed per second) by removing the sequential bottleneck of the scan operation.
On the Vim-Small (Vim-S) architecture, DyVM achieved:
- 35.2% FLOP reduction with only a 1.7% drop in top-1 accuracy on ImageNet-1K.
- 34% Throughput improvement on a V100 GPU, outperforming previous state-of-the-art methods like HiddenAlign.
- Strong Generalization across video understanding (Kinetics-400) and semantic segmentation (ADE20K).
Conclusion and Future Work
DyVM demonstrates that Mamba's efficiency can be further enhanced by dynamically adapting to the input's complexity. While highly effective for classification and video, dense tasks like semantic segmentation require "stopping updates" rather than full pruning to preserve spatial maps. Future research may explore making the timing of pruning dynamic or further optimizing the "rearrange" step for specific hardware kernels to unlock even greater speedups.
Summary updated